Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 71 lines (62 sloc) 1.79 KB
def require_without_bundler(gem, file)
return require(file) unless defined?(::Bundler)
if gem_path = Dir.glob("{#{Gem.path.join(',')}}/gems/#{gem}*").first
$LOAD_PATH << "#{gem_path}/lib"
require file
else
raise LoadError, "Gem #{gem} not found via require_without_bundler"
end
end
begin
# nice history and color
require_without_bundler 'blackwinter-wirble', 'wirble' # blackwinter branch has history_uniq fixes
Wirble::History::DEFAULTS[:history_uniq] = 'reverse'
Wirble.init
Wirble.colorize
rescue LoadError => e
# No wirble use defaults to get at least history
require 'irb/ext/save-history'
IRB.conf[:USE_READLINE] = true
IRB.conf[:SAVE_HISTORY] = 10000
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history"
end
# simple prompt
IRB.conf[:PROMPT_MODE] = :SIMPLE
#Show Rails output
# quick-and-dirty possibility to redirect the logger-output to console
# http://techspeak.plainlystated.com/2009/03/watching-your-logs-from-console.html
# dynamic_logger_switcher.rb
#
# Created by Roman Heinrich on 2009-06-05.
# Copyright 2009 DaWanda. All rights reserved.
#
def show_rails_log
unless @log_buffer_size
@log_file = Rails.logger.instance_variable_get("@log")
@log_level = Rails.logger.level
@log_buffer_size = Rails.logger.auto_flushing
end
Rails.logger.flush
Rails.logger.instance_variable_set("@log", STDOUT)
Rails.logger.level = Logger::DEBUG
Rails.logger.auto_flushing = 1
nil
end
def hide_rails_log
if @log_buffer_size
Rails.logger.instance_variable_set("@log", @log_file)
Rails.logger.level = @log_level
Rails.logger.auto_flushing = @log_buffer_size
end
nil
end
class Time
def self.benchmark
t = Time.now.to_f
yield
Time.now.to_f - t
end
end
def sql(query)
ActiveRecord::Base.connection.select_all(query)
end