Skip to content

Instantly share code, notes, and snippets.

@conradwt
Created May 1, 2012 16:43
Show Gist options
  • Save conradwt/2569520 to your computer and use it in GitHub Desktop.
Save conradwt/2569520 to your computer and use it in GitHub Desktop.
require 'rubygems' rescue nil
require 'wirble'
require 'hirb'
require 'awesome_print'
# Wirble options.
Wirble.init
Wirble.colorize
# Hirb options. (active record output format in table)
Hirb.enable :output => {"ActiveRecord::Base" => {:class => :auto_table, :ancestor => true, :options => {:vertical => true}}}
# IRB options.
IRB.conf[:AUTO_INDENT] = true
IRB.conf[:SAVE_HISTORY] = 1000
IRB.conf[:EVAL_HISTORY] = 200
$LOAD_PATH << '.'
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
unless IRB.version.include?('DietRB')
IRB::Irb.class_eval do
def output_value
ap @context.last_value
end
end
else # MacRuby
IRB.formatter = Class.new(IRB::Formatter) do
def inspect_object(object)
object.ai
end
end.new
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment