Created
June 29, 2011 02:09
-
-
Save hrstt/1052803 to your computer and use it in GitHub Desktop.
.irbrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' rescue nil | |
require 'wirble' | |
require 'hirb' | |
require 'ap' | |
# load wirble | |
Wirble.init | |
Wirble.colorize | |
# load hirb | |
Hirb::View.enable | |
IRB.conf[:AUTO_INDENT] = true | |
if ENV.include?('RAILS_ENV') | |
if !Object.const_defined?('RAILS_DEFAULT_LOGGER') | |
require 'logger' | |
Object.const_set('RAILS_DEFAULT_LOGGER', Logger.new(STDOUT)) | |
end | |
def sql(query) | |
ActiveRecord::Base.connection.select_all(query) | |
end | |
if ENV['RAILS_ENV'] == 'test' | |
require 'test/test_helper' | |
end | |
# for rails 3 | |
elsif defined?(Rails) && !Rails.env.nil? | |
if Rails.logger | |
Rails.logger =Logger.new(STDOUT) | |
ActiveRecord::Base.logger = Rails.logger | |
end | |
if Rails.env == 'test' | |
require 'test/test_helper' | |
end | |
else | |
# nothing to do | |
end | |
# annotate column names of an AR model | |
def show(obj) | |
y(obj.send("column_names")) | |
end | |
puts "> all systems are go wirble/hirb/ap/show <" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment