pry 0.9.4pre1 → 0.9.4pre2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +23 -0
- data/CONTRIBUTORS +13 -11
- data/README.markdown +2 -0
- data/Rakefile +16 -2
- data/TODO +8 -0
- data/lib/pry.rb +58 -9
- data/lib/pry/command_context.rb +11 -0
- data/lib/pry/command_processor.rb +43 -6
- data/lib/pry/command_set.rb +14 -4
- data/lib/pry/completion.rb +5 -5
- data/lib/pry/config.rb +6 -2
- data/lib/pry/default_commands/context.rb +83 -35
- data/lib/pry/default_commands/documentation.rb +37 -31
- data/lib/pry/default_commands/easter_eggs.rb +5 -0
- data/lib/pry/default_commands/input.rb +13 -10
- data/lib/pry/default_commands/introspection.rb +54 -40
- data/lib/pry/default_commands/shell.rb +9 -5
- data/lib/pry/helpers/base_helpers.rb +16 -5
- data/lib/pry/helpers/command_helpers.rb +41 -17
- data/lib/pry/helpers/text.rb +2 -1
- data/lib/pry/history.rb +61 -0
- data/lib/pry/plugins.rb +19 -8
- data/lib/pry/pry_class.rb +25 -62
- data/lib/pry/pry_instance.rb +105 -120
- data/lib/pry/version.rb +1 -1
- data/pry.gemspec +15 -14
- data/test/helper.rb +31 -0
- data/test/test_command_set.rb +7 -2
- data/test/test_completion.rb +7 -3
- data/test/test_default_commands/test_context.rb +185 -1
- data/test/test_default_commands/test_documentation.rb +10 -0
- data/test/test_default_commands/test_input.rb +16 -11
- data/test/test_default_commands/test_introspection.rb +10 -0
- data/test/test_default_commands/test_shell.rb +18 -0
- data/test/test_pry.rb +189 -40
- data/test/test_pry_history.rb +13 -13
- data/test/test_pry_output.rb +44 -0
- data/test/test_special_locals.rb +35 -0
- metadata +171 -162
@@ -11,7 +11,7 @@ class Pry
|
|
11
11
|
target = target()
|
12
12
|
|
13
13
|
opts = Slop.parse!(args) do |opt|
|
14
|
-
opt.banner = "Usage: show-doc [OPTIONS] [METH]\n" \
|
14
|
+
opt.banner = "Usage: show-doc [OPTIONS] [METH 1] [METH 2] [METH N]\n" \
|
15
15
|
"Show the comments above method METH. Tries instance methods first and then methods by default.\n" \
|
16
16
|
"e.g show-doc hello_method"
|
17
17
|
|
@@ -28,25 +28,26 @@ class Pry
|
|
28
28
|
|
29
29
|
next if opts.help?
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
31
|
+
args = [nil] if args.empty?
|
32
|
+
args.each do |method_name|
|
33
|
+
meth_name = method_name
|
34
|
+
if (meth = get_method_object(meth_name, target, opts.to_hash(true))).nil?
|
35
|
+
output.puts "Invalid method name: #{meth_name}. Type `show-doc --help` for help"
|
36
|
+
next
|
37
|
+
end
|
36
38
|
|
37
|
-
|
38
|
-
|
39
|
+
doc, code_type = doc_and_code_type_for(meth)
|
40
|
+
next if !doc
|
39
41
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
if meth.respond_to?(:parameters)
|
42
|
+
next output.puts("No documentation found.") if doc.empty?
|
43
|
+
doc = process_comment_markup(doc, code_type)
|
44
|
+
output.puts make_header(meth, code_type, doc)
|
45
|
+
output.puts "#{text.bold("visibility: ")} #{method_visibility(meth).to_s}"
|
45
46
|
output.puts "#{text.bold("signature: ")} #{signature_for(meth)}"
|
46
47
|
output.puts
|
48
|
+
render_output(opts.flood?, false, doc)
|
49
|
+
doc
|
47
50
|
end
|
48
|
-
render_output(opts.flood?, false, doc)
|
49
|
-
doc
|
50
51
|
end
|
51
52
|
|
52
53
|
alias_command "?", "show-doc", ""
|
@@ -88,11 +89,9 @@ class Pry
|
|
88
89
|
output.puts "Visibility: " + method_visibility(meth).to_s
|
89
90
|
output.puts "Type: " + (meth.is_a?(Method) ? "Bound" : "Unbound")
|
90
91
|
output.puts "Arity: " + meth.arity.to_s
|
92
|
+
output.puts "Method Signature: " + signature_for(meth)
|
91
93
|
|
92
|
-
|
93
|
-
output.puts "Method Signature: " + signature_for(meth)
|
94
|
-
end
|
95
|
-
|
94
|
+
output.puts "Source location: " + (meth.source_location ? meth.source_location.join(":") : "Not found.")
|
96
95
|
end
|
97
96
|
|
98
97
|
command "gist-method", "Gist a method to github. Type `gist-method --help` for more info.", :requires_gem => "gist" do |*args|
|
@@ -144,21 +143,28 @@ class Pry
|
|
144
143
|
end
|
145
144
|
|
146
145
|
helpers do
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
146
|
+
|
147
|
+
# paraphrased from awesome_print gem
|
148
|
+
def signature_for(method)
|
149
|
+
if method.respond_to?(:parameters)
|
150
|
+
|
151
|
+
args = method.parameters.inject([]) do |arr, (type, name)|
|
152
|
+
name ||= (type == :block ? 'block' : "arg#{arr.size + 1}")
|
153
|
+
arr << case type
|
154
|
+
when :req then name.to_s
|
155
|
+
when :opt, :rest then "*#{name}"
|
156
|
+
when :block then "&#{name}"
|
157
|
+
else '?'
|
158
|
+
end
|
157
159
|
end
|
160
|
+
else
|
161
|
+
args = (1..method.arity.abs).map { |i| "arg#{i}" }
|
162
|
+
args[-1] = "*#{args[-1]}" if method.arity < 0
|
158
163
|
end
|
159
|
-
"#{meth.name}(#{param_strings.join(", ")})"
|
160
|
-
end
|
161
164
|
|
165
|
+
"#{method.name}(#{args.join(', ')})"
|
166
|
+
end
|
167
|
+
|
162
168
|
def method_visibility(meth)
|
163
169
|
if meth.owner.public_instance_methods.include? meth.name
|
164
170
|
:public
|
@@ -54,9 +54,9 @@ e.g amend-line puts 'hello again' # no line number modifies immediately preced
|
|
54
54
|
|
55
55
|
alias_command(/%.?(-?\d+)?(?:\.\.(-?\d+))?/, /amend-line.?(-?\d+)?(?:\.\.(-?\d+))?/, "")
|
56
56
|
|
57
|
-
command "play", "Play back a string or a method or a file as input. Type `play --help` for more information." do |*args|
|
57
|
+
command "play", "Play back a string variable or a method or a file as input. Type `play --help` for more information." do |*args|
|
58
58
|
opts = Slop.parse!(args) do |opt|
|
59
|
-
opt.banner "Usage: play [OPTIONS] [--help]\nDefault action (no options) is to play the provided string\ne.g `play
|
59
|
+
opt.banner "Usage: play [OPTIONS] [--help]\nDefault action (no options) is to play the provided string variable\ne.g `play _in_[20] --lines 1..3`\ne.g `play -m Pry#repl --lines 1..-1`\ne.g `play -f Rakefile --lines 5`"
|
60
60
|
|
61
61
|
opt.on :l, :lines, 'The line (or range of lines) to replay.', true, :as => Range
|
62
62
|
opt.on :m, :method, 'Play a method.', true
|
@@ -65,8 +65,6 @@ e.g amend-line puts 'hello again' # no line number modifies immediately preced
|
|
65
65
|
opt.on :h, :help, "This message." do
|
66
66
|
output.puts opt
|
67
67
|
end
|
68
|
-
|
69
|
-
opt.on_noopts { _pry_.input = StringIO.new(arg_string) }
|
70
68
|
end
|
71
69
|
|
72
70
|
if opts.m?
|
@@ -82,9 +80,7 @@ e.g amend-line puts 'hello again' # no line number modifies immediately preced
|
|
82
80
|
range = (0..-2) if opts.o?
|
83
81
|
|
84
82
|
_pry_.input = StringIO.new(Array(code.each_line.to_a[range]).join)
|
85
|
-
|
86
|
-
|
87
|
-
if opts.f?
|
83
|
+
elsif opts.f?
|
88
84
|
file_name = File.expand_path(opts[:f])
|
89
85
|
next output.puts "No such file: #{opts[:f]}" if !File.exists?(file_name)
|
90
86
|
text_array = File.readlines(file_name)
|
@@ -92,12 +88,19 @@ e.g amend-line puts 'hello again' # no line number modifies immediately preced
|
|
92
88
|
range = (0..-2) if opts.o?
|
93
89
|
|
94
90
|
_pry_.input = StringIO.new(Array(text_array[range]).join)
|
91
|
+
else
|
92
|
+
code = target.eval(args.first)
|
93
|
+
|
94
|
+
range = opts.l? ? one_index_range_or_number(opts[:l]) : (0..-1)
|
95
|
+
range = (0..-2) if opts.o?
|
96
|
+
|
97
|
+
eval_string << Array(code.each_line.to_a[range]).join
|
95
98
|
end
|
96
99
|
end
|
97
100
|
|
98
101
|
command "hist", "Show and replay Readline history. Type `hist --help` for more info. Aliases: history" do |*args|
|
99
102
|
# exclude the current command from history.
|
100
|
-
history =
|
103
|
+
history = Pry.history.to_a[0..-2]
|
101
104
|
|
102
105
|
opts = Slop.parse!(args) do |opt|
|
103
106
|
opt.banner "Usage: hist [--replay START..END] [--clear] [--grep PATTERN] [--head N] [--tail N] [--help] [--save [START..END] file.txt]\n"
|
@@ -132,7 +135,7 @@ e.g amend-line puts 'hello again' # no line number modifies immediately preced
|
|
132
135
|
:unless => :grep do |limit|
|
133
136
|
|
134
137
|
limit ||= 10
|
135
|
-
offset = history.size-limit
|
138
|
+
offset = history.size - limit
|
136
139
|
offset = offset < 0 ? 0 : offset
|
137
140
|
|
138
141
|
list = history.last limit
|
@@ -170,7 +173,7 @@ e.g amend-line puts 'hello again' # no line number modifies immediately preced
|
|
170
173
|
opt.on "save", "Save history to a file. --save [start..end] output.txt. Pry commands are excluded from saved history.", true, :as => Range
|
171
174
|
|
172
175
|
opt.on :c, :clear, 'Clear the history', :unless => :grep do
|
173
|
-
|
176
|
+
Pry.history.clear
|
174
177
|
output.puts 'History cleared.'
|
175
178
|
end
|
176
179
|
|
@@ -9,7 +9,7 @@ class Pry
|
|
9
9
|
target = target()
|
10
10
|
|
11
11
|
opts = Slop.parse!(args) do |opt|
|
12
|
-
opt.banner "Usage: show-method [OPTIONS] [METH]\n" \
|
12
|
+
opt.banner "Usage: show-method [OPTIONS] [METH 1] [METH 2] [METH N]\n" \
|
13
13
|
"Show the source for method METH. Tries instance methods first and then methods by default.\n" \
|
14
14
|
"e.g: show-method hello_method"
|
15
15
|
|
@@ -29,30 +29,33 @@ class Pry
|
|
29
29
|
|
30
30
|
next if opts.help?
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
32
|
+
args = [nil] if args.empty?
|
33
|
+
args.each do |method_name|
|
34
|
+
meth_name = method_name
|
35
|
+
if (meth = get_method_object(meth_name, target, opts.to_hash(true))).nil?
|
36
|
+
output.puts "Invalid method name: #{meth_name}. Type `show-method --help` for help"
|
37
|
+
next
|
38
|
+
end
|
37
39
|
|
38
|
-
|
39
|
-
|
40
|
+
code, code_type = code_and_code_type_for(meth)
|
41
|
+
next if !code
|
40
42
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
43
|
+
output.puts make_header(meth, code_type, code)
|
44
|
+
if Pry.color
|
45
|
+
code = CodeRay.scan(code, code_type).term
|
46
|
+
end
|
45
47
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
48
|
+
start_line = false
|
49
|
+
if opts.l?
|
50
|
+
start_line = meth.source_location ? meth.source_location.last : 1
|
51
|
+
end
|
50
52
|
|
51
|
-
|
53
|
+
start_line = opts.b? ? 1 : start_line
|
52
54
|
|
53
55
|
|
54
|
-
|
55
|
-
|
56
|
+
render_output(opts.flood?, start_line, code)
|
57
|
+
code
|
58
|
+
end
|
56
59
|
end
|
57
60
|
|
58
61
|
alias_command "show-source", "show-method", ""
|
@@ -108,13 +111,14 @@ class Pry
|
|
108
111
|
command "edit", "Invoke the default editor on a file. Type `edit --help` for more info" do |*args|
|
109
112
|
opts = Slop.parse!(args) do |opt|
|
110
113
|
opt.banner "Usage: edit [OPTIONS] [FILE]\n" \
|
111
|
-
"Edit the method FILE in an editor.\
|
112
|
-
"
|
114
|
+
"Edit the method FILE in an editor.\nWhen no file given, opens editor with contents of input buffer and evals after closing." \
|
115
|
+
"\nEnsure #{text.bold("Pry.config.editor")} is set to your editor of choice.\n" \
|
113
116
|
"e.g: edit sample.rb"
|
114
117
|
|
115
118
|
opt.on :r, "reload", "Eval file content after editing (evals at top level)"
|
116
|
-
opt.on :
|
117
|
-
opt.on :
|
119
|
+
opt.on :n, "no-reload", "Do not automatically reload the file after editing (only applies to --ex and -t)."
|
120
|
+
opt.on :ex, "Open an editor at the line and file that generated the most recent Exception, reloads file after editing."
|
121
|
+
opt.on :t, "temp", "Open a temporary file in an editor with contents of input buffer and eval it in current context after closing (same as `edit` with no args)"
|
118
122
|
opt.on :p, "play", "Use the pry `play` command to eval the file content after editing."
|
119
123
|
opt.on :l, "line", "Specify line number to jump to in file", true, :as => Integer
|
120
124
|
opt.on :h, :help, "This message." do
|
@@ -123,26 +127,32 @@ class Pry
|
|
123
127
|
end
|
124
128
|
next if opts.h?
|
125
129
|
|
126
|
-
|
127
|
-
|
128
|
-
should_reload = opts[:r]
|
130
|
+
should_reload_at_top_level = opts[:r]
|
131
|
+
should_reload_locally = false
|
129
132
|
|
130
133
|
if opts.ex?
|
131
|
-
next output.puts "No Exception found." if
|
134
|
+
next output.puts "No Exception found." if _pry_.last_exception.nil?
|
135
|
+
|
136
|
+
if is_core_rbx_path?(_pry_.last_exception.file)
|
137
|
+
file_name = rbx_convert_path_to_full(_pry_.last_exception.file)
|
138
|
+
else
|
139
|
+
file_name = _pry_.last_exception.file
|
140
|
+
end
|
132
141
|
|
133
|
-
|
134
|
-
line = Pry.last_exception.line
|
142
|
+
line = _pry_.last_exception.line
|
135
143
|
next output.puts "Exception has no associated file." if file_name.nil?
|
136
144
|
next output.puts "Cannot edit exceptions raised in REPL." if Pry.eval_path == file_name
|
137
|
-
|
145
|
+
|
146
|
+
should_reload_at_top_level = opts[:n] ? false : true
|
147
|
+
|
148
|
+
elsif opts.t? || args.first.nil?
|
138
149
|
file_name = Tempfile.new(["tmp", ".rb"]).tap(&:close).path
|
139
|
-
|
140
|
-
|
141
|
-
|
150
|
+
File.open(file_name, "w") { |f| f.puts eval_string } if !eval_string.empty?
|
151
|
+
line = eval_string.lines.count + 1
|
152
|
+
should_reload_locally = opts[:n] ? false : true
|
142
153
|
else
|
143
|
-
|
144
|
-
|
145
|
-
line = opts[:l].to_i
|
154
|
+
file_name, line = File.expand_path(args.first).split(/:/)
|
155
|
+
line = line ? line.to_i : opts[:l].to_i
|
146
156
|
end
|
147
157
|
|
148
158
|
invoke_editor(file_name, line)
|
@@ -152,9 +162,13 @@ class Pry
|
|
152
162
|
silence_warnings do
|
153
163
|
_pry_.input = StringIO.new(File.readlines(file_name).join)
|
154
164
|
end
|
155
|
-
elsif
|
165
|
+
elsif should_reload_locally
|
166
|
+
silence_warnings do
|
167
|
+
eval_string.replace(File.read(file_name))
|
168
|
+
end
|
169
|
+
elsif should_reload_at_top_level
|
156
170
|
silence_warnings do
|
157
|
-
|
171
|
+
TOPLEVEL_BINDING.eval(File.read(file_name), file_name)
|
158
172
|
end
|
159
173
|
end
|
160
174
|
end
|
@@ -165,7 +179,7 @@ class Pry
|
|
165
179
|
opts = Slop.parse!(args) do |opt|
|
166
180
|
opt.banner "Usage: edit-method [OPTIONS] [METH]\n" \
|
167
181
|
"Edit the method METH in an editor.\n" \
|
168
|
-
"Ensure #{text.bold("Pry.editor")} is set to your editor of choice.\n" \
|
182
|
+
"Ensure #{text.bold("Pry.config.editor")} is set to your editor of choice.\n" \
|
169
183
|
"e.g: edit-method hello_method"
|
170
184
|
|
171
185
|
opt.on :M, "instance-methods", "Operate on instance methods."
|
@@ -188,7 +202,7 @@ class Pry
|
|
188
202
|
next
|
189
203
|
end
|
190
204
|
|
191
|
-
next output.puts "Error: No editor set!\nEnsure that #{text.bold("Pry.editor")} is set to your editor of choice." if !Pry.editor
|
205
|
+
next output.puts "Error: No editor set!\nEnsure that #{text.bold("Pry.config.editor")} is set to your editor of choice." if !Pry.config.editor
|
192
206
|
|
193
207
|
if is_a_c_method?(meth)
|
194
208
|
output.puts "Error: Can't edit a C method."
|
@@ -50,12 +50,16 @@ class Pry
|
|
50
50
|
|
51
51
|
opt.on :ex, "Show a window of N lines either side of the last exception (defaults to 5).", :optional => true, :as => Integer do |window_size|
|
52
52
|
window_size ||= 5
|
53
|
-
ex =
|
53
|
+
ex = _pry_.last_exception
|
54
54
|
next if !ex
|
55
55
|
start_line = (ex.line - 1) - window_size
|
56
56
|
start_line = start_line < 0 ? 0 : start_line
|
57
57
|
end_line = (ex.line - 1) + window_size
|
58
|
-
|
58
|
+
if is_core_rbx_path?(ex.file)
|
59
|
+
file_name = rbx_convert_path_to_full(ex.file)
|
60
|
+
else
|
61
|
+
file_name = ex.file
|
62
|
+
end
|
59
63
|
end
|
60
64
|
|
61
65
|
opt.on :l, "line-numbers", "Show line numbers."
|
@@ -93,7 +97,7 @@ class Pry
|
|
93
97
|
|
94
98
|
contents = contents.lines.each_with_index.map do |line, idx|
|
95
99
|
l = idx + start_line
|
96
|
-
if l == (
|
100
|
+
if l == (_pry_.last_exception.line - 1)
|
97
101
|
" =>#{line}"
|
98
102
|
else
|
99
103
|
" #{line}"
|
@@ -101,8 +105,8 @@ class Pry
|
|
101
105
|
end.join
|
102
106
|
|
103
107
|
# header for exceptions
|
104
|
-
output.puts "\n#{Pry::Helpers::Text.bold('Exception:')}
|
105
|
-
output.puts "#{Pry::Helpers::Text.bold('From:')} #{file_name} @ line #{
|
108
|
+
output.puts "\n#{Pry::Helpers::Text.bold('Exception:')} #{_pry_.last_exception.class}: #{_pry_.last_exception.message}\n--"
|
109
|
+
output.puts "#{Pry::Helpers::Text.bold('From:')} #{file_name} @ line #{_pry_.last_exception.line}\n\n"
|
106
110
|
end
|
107
111
|
|
108
112
|
set_file_and_dir_locals(file_name)
|
@@ -36,10 +36,11 @@ class Pry
|
|
36
36
|
|
37
37
|
def set_file_and_dir_locals(file_name)
|
38
38
|
return if !target
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
39
|
+
_pry_.last_file = File.expand_path(file_name)
|
40
|
+
_pry_.inject_local("_file_", _pry_.last_file, target)
|
41
|
+
|
42
|
+
_pry_.last_dir = File.dirname(_pry_.last_file)
|
43
|
+
_pry_.inject_local("_dir_", _pry_.last_dir, target)
|
43
44
|
end
|
44
45
|
|
45
46
|
def stub_proc(name, options)
|
@@ -86,6 +87,16 @@ class Pry
|
|
86
87
|
27
|
87
88
|
end
|
88
89
|
|
90
|
+
# are we on Jruby platform?
|
91
|
+
def jruby?
|
92
|
+
defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /jruby/
|
93
|
+
end
|
94
|
+
|
95
|
+
# are we on rbx platform?
|
96
|
+
def rbx?
|
97
|
+
defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /rbx/
|
98
|
+
end
|
99
|
+
|
89
100
|
# a simple pager for systems without `less`. A la windows.
|
90
101
|
def simple_pager(text, output=output())
|
91
102
|
text_array = text.lines.to_a
|
@@ -109,7 +120,7 @@ class Pry
|
|
109
120
|
end
|
110
121
|
|
111
122
|
# FIXME! Another JRuby hack
|
112
|
-
if
|
123
|
+
if jruby?
|
113
124
|
simple_pager(text, output)
|
114
125
|
else
|
115
126
|
lesspipe { |less| less.puts text }
|
@@ -40,11 +40,14 @@ class Pry
|
|
40
40
|
end
|
41
41
|
|
42
42
|
########### RBX HELPERS #############
|
43
|
+
def is_core_rbx_path?(path)
|
44
|
+
rbx? &&
|
45
|
+
path.start_with?("kernel")
|
46
|
+
end
|
47
|
+
|
43
48
|
def rbx_core?(meth)
|
44
|
-
defined?(RUBY_ENGINE) &&
|
45
|
-
RUBY_ENGINE =~ /rbx/ &&
|
46
49
|
meth.source_location &&
|
47
|
-
meth.source_location.first
|
50
|
+
is_core_rbx_path?(meth.source_location.first)
|
48
51
|
end
|
49
52
|
|
50
53
|
def rvm_ruby?(path)
|
@@ -70,6 +73,28 @@ class Pry
|
|
70
73
|
end
|
71
74
|
end
|
72
75
|
|
76
|
+
def rbx_convert_path_to_full(path)
|
77
|
+
if rvm_ruby?(Rubinius::BIN_PATH)
|
78
|
+
rbx_rvm_convert_path_to_full(path)
|
79
|
+
else
|
80
|
+
rbx_std_convert_path_to_full(path)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def rbx_rvm_convert_path_to_full(path)
|
85
|
+
ruby_name = File.dirname(Rubinius::BIN_PATH).split("/").last
|
86
|
+
source_path = File.join(File.dirname(File.dirname(File.dirname(Rubinius::BIN_PATH))), "src", ruby_name)
|
87
|
+
file_name = File.join(source_path, path)
|
88
|
+
raise "Cannot find rbx core source" if !File.exists?(file_name)
|
89
|
+
file_name
|
90
|
+
end
|
91
|
+
|
92
|
+
def rbx_std_convert_path_to_full(path)
|
93
|
+
file_name = File.join(Rubinius::BIN_PATH, "..", path)
|
94
|
+
raise "Cannot find rbx core source" if !File.exists?(file_name)
|
95
|
+
file_name
|
96
|
+
end
|
97
|
+
|
73
98
|
def rbx_core_path_line_for(meth)
|
74
99
|
if rvm_ruby?(Rubinius::BIN_PATH)
|
75
100
|
rvm_rbx_core_path_line_for(meth)
|
@@ -79,21 +104,14 @@ class Pry
|
|
79
104
|
end
|
80
105
|
|
81
106
|
def std_rbx_core_path_line_for(meth)
|
82
|
-
file_name
|
83
|
-
raise "Cannot find rbx core source" if !File.exists?(file_name)
|
84
|
-
|
107
|
+
file_name = rbx_std_convert_path_to_full(meth.source_location.first)
|
85
108
|
start_line = meth.source_location.last
|
86
109
|
|
87
110
|
[file_name, start_line]
|
88
111
|
end
|
89
112
|
|
90
113
|
def rvm_rbx_core_path_line_for(meth)
|
91
|
-
|
92
|
-
source_path = File.join(File.dirname(File.dirname(File.dirname(Rubinius::BIN_PATH))), "src", ruby_name)
|
93
|
-
|
94
|
-
file_name = File.join(source_path, meth.source_location.first)
|
95
|
-
raise "Cannot find rbx core source" if !File.exists?(file_name)
|
96
|
-
|
114
|
+
file_name = rbx_rvm_convert_path_to_full(meth.source_location.first)
|
97
115
|
start_line = meth.source_location.last
|
98
116
|
|
99
117
|
[file_name, start_line]
|
@@ -333,19 +351,25 @@ class Pry
|
|
333
351
|
end
|
334
352
|
|
335
353
|
def invoke_editor(file, line)
|
336
|
-
if Pry.editor.respond_to?(:call)
|
337
|
-
editor_invocation = Pry.editor.call(file, line)
|
354
|
+
if Pry.config.editor.respond_to?(:call)
|
355
|
+
editor_invocation = Pry.config.editor.call(file, line)
|
338
356
|
else
|
339
|
-
editor_invocation = "#{Pry.editor} #{start_line_syntax_for_editor(file, line)}"
|
357
|
+
editor_invocation = "#{Pry.config.editor} #{start_line_syntax_for_editor(file, line)}"
|
340
358
|
end
|
341
359
|
|
342
|
-
|
360
|
+
if jruby?
|
361
|
+
require 'spoon'
|
362
|
+
pid = Spoon.spawnp(*editor_invocation.split)
|
363
|
+
Process.waitpid(pid)
|
364
|
+
else
|
365
|
+
run ".#{editor_invocation}"
|
366
|
+
end
|
343
367
|
end
|
344
368
|
|
345
369
|
def start_line_syntax_for_editor(file_name, line_number)
|
346
370
|
file_name = file_name.gsub(/\//, '\\') if RUBY_PLATFORM =~ /mswin|mingw/
|
347
371
|
|
348
|
-
case Pry.editor
|
372
|
+
case Pry.config.editor
|
349
373
|
when /^[gm]?vi/, /^emacs/, /^nano/, /^pico/, /^gedit/, /^kate/
|
350
374
|
"+#{line_number} #{file_name}"
|
351
375
|
when /^mate/, /^geany/
|