-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
37 additions
and
90 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,40 @@ | ||
if defined?(::Bundler) | ||
global_gemset = ENV['GEM_PATH'].split(':').grep(/ruby.*@global/).first | ||
if global_gemset | ||
all_global_gem_paths = Dir.glob("#{global_gemset}/gems/*") | ||
all_global_gem_paths.each do |p| | ||
gem_path = "#{p}/lib" | ||
$LOAD_PATH << gem_path | ||
end | ||
end | ||
end | ||
|
||
require 'rubygems' rescue nil | ||
require 'wirble' | ||
require 'awesome_print' | ||
#!/usr/bin/ruby | ||
require 'irb/completion' | ||
require 'irb/ext/save-history' | ||
require 'rubygems' | ||
|
||
# load wirble | ||
Wirble.init | ||
Wirble.colorize | ||
|
||
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 | ||
IRB.conf[:SAVE_HISTORY] = 1000 | ||
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb_history" | ||
|
||
# load hirb | ||
IRB.conf[:PROMPT_MODE] = :SIMPLE | ||
|
||
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' | ||
class Object | ||
# list methods which aren't in superclass | ||
def local_methods(obj = self) | ||
(obj.methods - obj.class.superclass.instance_methods).sort | ||
end | ||
|
||
# for rails 3 | ||
elsif defined?(Rails) && !Rails.env.nil? && defined?(ActiveRecord) | ||
if Rails.logger | ||
Rails.logger =Logger.new(STDOUT) | ||
ActiveRecord::Base.logger = Rails.logger | ||
end | ||
if Rails.env == 'test' | ||
require 'test/test_helper' | ||
# print documentation | ||
# | ||
# ri 'Array#pop' | ||
# Array.ri | ||
# Array.ri :pop | ||
# arr.ri :pop | ||
def ri(method = nil) | ||
unless method && method =~ /^[A-Z]/ # if class isn't specified | ||
klass = self.kind_of?(Class) ? name : self.class.name | ||
method = [klass, method].compact.join('#') | ||
end | ||
puts `ri '#{method}'` | ||
end | ||
else | ||
# nothing to do | ||
end | ||
|
||
if defined?(Mongoid) | ||
Mongoid.config.logger = Logger.new($stdout) | ||
def me | ||
User.find_by_login(ENV['USER'].strip) | ||
end | ||
|
||
# annotate column names of an AR model | ||
def show(obj) | ||
y(obj.send("column_names")) | ||
def r | ||
reload! | ||
end | ||
|
||
puts "> all systems are go wirble/hirb/ap/show <" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,23 @@ | ||
# Taken from https://github.com/adamyonk/dotfiles ;) | ||
|
||
# Load rbenv & set the proper rbenv $PATH nonsense (this is important or everything fails) | ||
eval "$(rbenv init -)" | ||
PATH="$HOME/.rbenv/bin:$PATH" | ||
source /usr/local/opt/chruby/share/chruby/chruby.sh | ||
source /usr/local/share/chruby/chruby.sh | ||
source /usr/local/opt/chruby/share/chruby/auto.sh | ||
chruby 2.1.3 | ||
|
||
# # Load chruby | ||
# source /usr/local/share/chruby/chruby.sh | ||
# source /usr/local/share/chruby/auto.sh | ||
# chruby 1.9.3 | ||
|
||
# Load unicorn | ||
#function bbu() { | ||
# if [[ -z $1 ]]; then | ||
# UNICORN_PORT=3000; | ||
# else | ||
# UNICORN_PORT=$1; | ||
# fi | ||
# bin/unicorn -E development -c /usr/local/etc/unicorn.rb -1 127.0.0.1:$UNICORN_PORT | ||
#} | ||
|
||
alias rake='noglob rake' | ||
alias bundle='noglob bundle' | ||
alias be='bundle exec' | ||
alias bi='bundle install' | ||
alias fr='bundle exec foreman run bundle exec' | ||
|
||
#alias killall=exec "kill -QUIT $(ps aux | grep "postgres\|redis\|mailcatcher\|sphinx\|unicorn" | awk '{print $2}' | xargs)" | ||
|
||
# This might not be good to have on non-dev machines | ||
#export RUBY_HEAP_MIN_SLOTS=1000000 | ||
#export RUBY_HEAP_SLOTS_INCREMENT=1000000 | ||
#export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1 | ||
#export RUBY_GC_MALLOC_LIMIT=1000000000 | ||
#export RUBY_HEAP_FREE_MIN=500000 | ||
|
||
alias pg-up='pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log' | ||
alias nginx-up="sudo nginx -c /usr/local/etc/nginx/nginx.conf" | ||
alias nginx-down="sudo nginx -s stop" | ||
alias redis-up='redis-server /usr/local/etc/redis.conf > /dev/null &' | ||
alias redis-down='killall redis-server' | ||
alias pc_precompile='bundle exec rake assets:precompile RAILS_ENV=development RAILS_ASSETS_NODIGEST=true' | ||
#alias pg-up='pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log' | ||
#alias nginx-up="sudo nginx -c /usr/local/etc/nginx/nginx.conf" | ||
#alias nginx-down="sudo nginx -s stop" | ||
#alias redis-up='redis-server /usr/local/etc/redis.conf > /dev/null &' | ||
#alias redis-down='killall redis-server' | ||
#alias pc_precompile='bundle exec rake assets:precompile RAILS_ENV=development RAILS_ASSETS_NODIGEST=true'= |