forked from basiszwo/dotfiles
/
irbrc
executable file
·51 lines (41 loc) · 1.51 KB
/
irbrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/ruby
require 'rubygems'
# require 'irb/completion'
# require 'irb/ext/history'
require 'irb/ext/save-history'
#History configuration
# IRB.conf[:SAVE_HISTORY] = 100
# IRB.conf[:HISTORY_FILE] = "~/.irb_history"
IRB.conf[:SAVE_HISTORY] = 200
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-history"
%w[rubygems].each do |gem|
begin
require gem
rescue LoadError
end
end
begin
require 'awesome_print'
AwesomePrint.irb!
rescue LoadError => err
warn "Couldn't load awesome_print: #{err}"
end
# #console logging
script_console_running = ENV.include?('RAILS_ENV') && IRB.conf[:LOAD_MODULES] && IRB.conf[:LOAD_MODULES].include?('console_with_helpers')
rails_running = ENV.include?('RAILS_ENV') && !(IRB.conf[:LOAD_MODULES] && IRB.conf[:LOAD_MODULES].include?('console_with_helpers'))
irb_standalone_running = !script_console_running && !rails_running
if script_console_running
require 'logger'
Object.const_set(:RAILS_DEFAULT_LOGGER, Logger.new(STDOUT))
end
# IRB.conf[:PROMPT_MODE] = :DEFAULT
if ENV.include?('RAILS_ENV') && ENV["RAILS_ENV"] == 'development'
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Base.connection_pool.clear_reloadable_connections!
elsif defined?(Rails) && ENV["RAILS_ENV"] == 'development'
Rails.logger = Logger.new(STDOUT)
ActiveRecord::Base.connection_pool.clear_reloadable_connections!
end
# project_specific_irbrc = File.join(Rails.root, ".irbrc")
# puts "Loading project specific .irbrc ..."
# load(project_specific_irbrc) if File.exists?(project_specific_irbrc)