Created
May 8, 2014 19:12
-
-
Save seeRead/c434575b78a223e68eac to your computer and use it in GitHub Desktop.
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
# gem install pp awesome_print map_by_method what_methods duration wirble ori awesome_print | |
# Interactive Ruby console configuration | |
# use x = _ to assign to last output | |
# use ; to prevent return of data | |
# use 'method' to determine where a method is defined | |
# e.g. User.method(:acts_as_commentable) | |
IRB_START_TIME = Time.now | |
# Print to yaml format with "y" | |
require 'yaml' | |
# Pretty printing | |
#require 'pp' #included in ruby 2 | |
# Ability to load rubygem modules | |
require 'rubygems' | |
require 'awesome_print' #via ap | |
# Tab completion | |
require 'irb/completion' | |
# Save irb sessions to history file | |
require 'irb/ext/save-history' | |
# Not stdlib | |
require 'map_by_method' | |
require 'what_methods' | |
# For printing time in session | |
require 'duration' | |
# For coloration | |
require 'wirble' | |
# for ri | |
require 'ori' | |
# config: https://github.com/dadooda/ori/blob/master/README_RI_CORE.md | |
# Include line numbers and indent levels: | |
IRB.conf[:PROMPT][:SHORT] = { | |
:PROMPT_C=>"%03n:%i* ", | |
:RETURN=>"%s\n", | |
:PROMPT_I=>"%03n:%i> ", | |
:PROMPT_N=>"%03n:%i> ", | |
:PROMPT_S=>"%03n:%i%l " | |
} | |
IRB.conf[:PROMPT_MODE] = :SHORT | |
# Adds readline functionality | |
IRB.conf[:USE_READLINE] = true | |
# Auto indents suites | |
IRB.conf[:AUTO_INDENT] = true | |
# Where history is saved | |
IRB.conf[:HISTORY_FILE] = File::expand_path("~/.irbhistory") | |
# How many lines to save | |
IRB.conf[:SAVE_HISTORY] = 1000 | |
# Turn turn on colorization, off other wirble wierdness | |
Wirble.init(:skip_prompt => true, :skip_history => true) | |
Wirble.colorize | |
# Quick benchmarking facility | |
# Based on rue's irbrc => http://pastie.org/179534 | |
def quick(repetitions=100, &block) | |
require 'benchmark' | |
Benchmark.bmbm do |b| | |
b.report {repetitions.times &block} | |
end | |
nil | |
end | |
# Return only the methods not present on basic objects | |
# or use myobj.ri //. :own | |
class Object | |
def own_methods | |
(self.methods - Object.instance_methods).sort | |
end | |
end | |
# Prints how long the session has been open upon exit | |
at_exit { puts Duration.new(Time.now - IRB_START_TIME) } | |
# SQL love | |
if ENV.include?('RAILS_ENV') && !Object.const_defined?('RAILS_DEFAULT_LOGGER') | |
require 'logger' | |
RAILS_DEFAULT_LOGGER = Logger.new(STDOUT) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment