-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathirbrc
110 lines (96 loc) · 2.4 KB
/
irbrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
begin
# use pry meta-gem
require 'pry'
require 'pry-plus'
#require 'jazz_hands'
IRB = Pry
Pry.start
exit
rescue LoadError => e
warn "=> unable to load pry"
end
=begin
next_irbrc_candidates = %w{.irbrc irb.rc _irbrc}
next_irbrc_candidates += $irbrc if defined? $irbrc
next_irbrc_candidates.each do |cand|
begin
load cand if File.exists?(cand) unless File.expand_path(cand) == File.expand_path(__FILE__)
break
rescue
end
end
require 'pp'
alias p pp
unless defined? ETC_IRBRC_LOADED
require 'irb/completion'
IRB.conf[:PROMPT_MODE] = :SIMPLE if IRB.conf[:PROMPT_MODE] == :DEFAULT
require 'irb/ext/save-history'
IRB.conf[:SAVE_HISTORY] = 100
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-history"
IRB.conf[:USE_READLINE] = true
IRB.conf[:AUTO_INDENT]=true
ETC_IRBRC_LOADED=true
end
class Object
def my_methods
base_object = case self
when Class then Class.new
when Module then Module.new
else Object.new
end
(methods - base_object.methods).sort
end
if RUBY_VERSION =~ /^1\.9/
def wtf?(name)
if m = method(name)
m.source_location.join(':') if m.source_location
end
end
else
def wtf?(name)
if m = method(name)
[m.__file__, m.__line__].join(':')
end
end
end
end
#ruby 1.9 only
def source_for(object, method_sym)
if object.respond_to?(method_sym, true)
method = object.method(method_sym)
elsif object.is_a?(Module)
method = object.instance_method(method_sym)
end
location = method.source_location
`mvim #{location[0]} +#{location[1]}` if location
#`subl #{location[0]}:#{location[1]}` if location
location
rescue
nil
end
=end
if ENV['RAILS_ENV'] || defined? Rails
require 'logger'
logger = Logger.new(STDOUT)
# Log to STDOUT if in Rails 3
if defined?(Rails) && Rails.respond_to?(:logger=)
Rails.logger = logger
ActiveRecord::Base.logger = logger if defined? ActiveRecord::Base
Mongoid.logger = logger if defined? Mongoid
else # Rails 2
RAILS_DEFAULT_LOGGER = logger
end
def greg
Person.find_by_email("[email protected]")
end
def set_greg_roles
p = greg
ep = p.external_person
ep.password = "password"
ep.password_confirmation = "password"
puts "Saving ExternalPerson with new password"
ep.save!
p.roles.clear
p.roles << Role.all
end
end