pry 0.9.0pre3-java → 0.9.4pre2-java
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/CHANGELOG +84 -6
- data/CONTRIBUTORS +13 -0
- data/README.markdown +23 -183
- data/Rakefile +22 -19
- data/TODO +36 -6
- data/bin/pry +12 -1
- data/lib/pry.rb +60 -12
- data/lib/pry/command_context.rb +21 -0
- data/lib/pry/command_processor.rb +62 -16
- data/lib/pry/command_set.rb +25 -11
- data/lib/pry/commands.rb +0 -3
- data/lib/pry/completion.rb +6 -6
- data/lib/pry/config.rb +25 -5
- data/lib/pry/default_commands/basic.rb +27 -6
- data/lib/pry/default_commands/context.rb +84 -35
- data/lib/pry/default_commands/documentation.rb +69 -31
- data/lib/pry/default_commands/easter_eggs.rb +5 -0
- data/lib/pry/default_commands/input.rb +193 -56
- data/lib/pry/default_commands/introspection.rb +98 -50
- data/lib/pry/default_commands/ls.rb +51 -21
- data/lib/pry/default_commands/shell.rb +57 -13
- data/lib/pry/extended_commands/experimental.rb +0 -32
- data/lib/pry/extended_commands/user_command_api.rb +33 -2
- data/lib/pry/helpers/base_helpers.rb +30 -10
- data/lib/pry/helpers/command_helpers.rb +75 -16
- data/lib/pry/helpers/text.rb +12 -11
- data/lib/pry/history.rb +61 -0
- data/lib/pry/plugins.rb +23 -12
- data/lib/pry/pry_class.rb +51 -50
- data/lib/pry/pry_instance.rb +129 -119
- data/lib/pry/version.rb +1 -1
- data/pry.gemspec +46 -0
- data/test/helper.rb +37 -3
- data/test/test_command_processor.rb +62 -19
- data/test/test_command_set.rb +40 -2
- data/test/test_completion.rb +27 -0
- 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 +207 -11
- data/test/test_default_commands/test_introspection.rb +20 -1
- data/test/test_default_commands/test_shell.rb +18 -0
- data/test/test_pry.rb +261 -45
- data/test/test_pry_history.rb +82 -0
- data/test/test_pry_output.rb +44 -0
- data/test/test_special_locals.rb +35 -0
- metadata +185 -159
@@ -3,33 +3,110 @@ class Pry
|
|
3
3
|
|
4
4
|
Input = Pry::CommandSet.new do
|
5
5
|
|
6
|
-
command "!", "Clear the input buffer. Useful if the parsing process goes wrong and you get stuck in the read loop." do
|
6
|
+
command "!", "Clear the input buffer. Useful if the parsing process goes wrong and you get stuck in the read loop.", :use_prefix => false do
|
7
7
|
output.puts "Input buffer cleared!"
|
8
8
|
eval_string.replace("")
|
9
9
|
end
|
10
10
|
|
11
|
-
command "show-input", "Show the current
|
12
|
-
render_output(false,
|
11
|
+
command "show-input", "Show the contents of the input buffer for the current multi-line expression." do
|
12
|
+
render_output(false, 1, Pry.color ? CodeRay.scan(eval_string, :ruby).term : eval_string)
|
13
13
|
end
|
14
14
|
|
15
|
-
command(/amend-line
|
16
|
-
|
15
|
+
command(/amend-line.?(-?\d+)?(?:\.\.(-?\d+))?/, "Amend a line of input in multi-line mode. Type `amend-line --help` for more information. Aliases %",
|
16
|
+
:interpolate => false, :listing => "amend-line") do |*args|
|
17
|
+
start_line_number, end_line_number, replacement_line = *args
|
18
|
+
|
19
|
+
opts = Slop.parse!(args.compact) do |opt|
|
20
|
+
opt.banner %{Amend a line of input in multi-line mode. `amend-line N`, where the N in `amend-line N` represents line to replace.
|
21
|
+
|
22
|
+
Can also specify a range of lines using `amend-line N..M` syntax. Passing '!' as replacement content deletes the line(s) instead. Aliases: %N
|
23
|
+
e.g amend-line 1 puts 'hello world! # replace line 1'
|
24
|
+
e.g amend-line 1..4 ! # delete lines 1..4
|
25
|
+
e.g amend-line 3 >puts 'goodbye' # insert before line 3
|
26
|
+
e.g amend-line puts 'hello again' # no line number modifies immediately preceding line
|
27
|
+
}
|
28
|
+
opt.on :h, :help, "This message." do
|
29
|
+
output.puts opt
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
next if opts.h?
|
34
|
+
next output.puts "No input to amend." if eval_string.empty?
|
35
|
+
|
17
36
|
replacement_line = "" if !replacement_line
|
18
37
|
input_array = eval_string.each_line.to_a
|
19
|
-
|
20
|
-
|
38
|
+
|
39
|
+
end_line_number = start_line_number.to_i if !end_line_number
|
40
|
+
line_range = start_line_number ? (one_index_number(start_line_number.to_i)..one_index_number(end_line_number.to_i)) : input_array.size - 1
|
41
|
+
|
42
|
+
# delete selected lines if replacement line is '!'
|
43
|
+
if arg_string == "!"
|
44
|
+
input_array.slice!(line_range)
|
45
|
+
elsif arg_string.start_with?(">")
|
46
|
+
insert_slot = Array(line_range).first
|
47
|
+
input_array.insert(insert_slot, arg_string[1..-1] + "\n")
|
48
|
+
else
|
49
|
+
input_array[line_range] = arg_string + "\n"
|
50
|
+
end
|
21
51
|
eval_string.replace input_array.join
|
52
|
+
run "show-input"
|
53
|
+
end
|
54
|
+
|
55
|
+
alias_command(/%.?(-?\d+)?(?:\.\.(-?\d+))?/, /amend-line.?(-?\d+)?(?:\.\.(-?\d+))?/, "")
|
56
|
+
|
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
|
+
opts = Slop.parse!(args) do |opt|
|
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
|
+
|
61
|
+
opt.on :l, :lines, 'The line (or range of lines) to replay.', true, :as => Range
|
62
|
+
opt.on :m, :method, 'Play a method.', true
|
63
|
+
opt.on :f, "file", 'The file to replay in context.', true
|
64
|
+
opt.on :o, "open", 'When used with the -m switch, it plays the entire method except the last line, leaving the method definition "open". `amend-line` can then be used to modify the method.'
|
65
|
+
opt.on :h, :help, "This message." do
|
66
|
+
output.puts opt
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
if opts.m?
|
71
|
+
meth_name = opts[:m]
|
72
|
+
if (meth = get_method_object(meth_name, target, {})).nil?
|
73
|
+
output.puts "Invalid method name: #{meth_name}."
|
74
|
+
next
|
75
|
+
end
|
76
|
+
code, _ = code_and_code_type_for(meth)
|
77
|
+
next if !code
|
78
|
+
|
79
|
+
range = opts.l? ? one_index_range_or_number(opts[:l]) : (0..-1)
|
80
|
+
range = (0..-2) if opts.o?
|
81
|
+
|
82
|
+
_pry_.input = StringIO.new(Array(code.each_line.to_a[range]).join)
|
83
|
+
elsif opts.f?
|
84
|
+
file_name = File.expand_path(opts[:f])
|
85
|
+
next output.puts "No such file: #{opts[:f]}" if !File.exists?(file_name)
|
86
|
+
text_array = File.readlines(file_name)
|
87
|
+
range = opts.l? ? one_index_range_or_number(opts[:l]) : (0..-1)
|
88
|
+
range = (0..-2) if opts.o?
|
89
|
+
|
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
|
98
|
+
end
|
22
99
|
end
|
23
100
|
|
24
|
-
|
101
|
+
command "hist", "Show and replay Readline history. Type `hist --help` for more info. Aliases: history" do |*args|
|
102
|
+
# exclude the current command from history.
|
103
|
+
history = Pry.history.to_a[0..-2]
|
25
104
|
|
26
|
-
|
27
|
-
|
28
|
-
history = Readline::HISTORY.to_a
|
29
|
-
opt.banner "Usage: hist [--replay START..END] [--clear] [--grep PATTERN] [--head N] [--tail N] [--help]\n"
|
105
|
+
opts = Slop.parse!(args) do |opt|
|
106
|
+
opt.banner "Usage: hist [--replay START..END] [--clear] [--grep PATTERN] [--head N] [--tail N] [--help] [--save [START..END] file.txt]\n"
|
30
107
|
|
31
108
|
opt.on :g, :grep, 'A pattern to match against the history.', true do |pattern|
|
32
|
-
pattern = Regexp.new arg_string.split(/
|
109
|
+
pattern = Regexp.new arg_string.strip.split(/ /, 2).last.strip
|
33
110
|
history.pop
|
34
111
|
|
35
112
|
history.map!.with_index do |element, index|
|
@@ -41,64 +118,67 @@ class Pry
|
|
41
118
|
stagger_output history.compact.join "\n"
|
42
119
|
end
|
43
120
|
|
44
|
-
opt.on :head, 'Display the first N items of history',
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
121
|
+
opt.on :head, 'Display the first N items of history',
|
122
|
+
:optional => true,
|
123
|
+
:as => Integer,
|
124
|
+
:unless => :grep do |limit|
|
125
|
+
|
126
|
+
limit ||= 10
|
127
|
+
list = history.first limit
|
128
|
+
lines = text.with_line_numbers list.join("\n"), 0
|
129
|
+
stagger_output lines
|
51
130
|
end
|
52
131
|
|
53
|
-
opt.on :t, :tail, 'Display the last N items of history',
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
offset = offset < 0 ? 0 : offset
|
132
|
+
opt.on :t, :tail, 'Display the last N items of history',
|
133
|
+
:optional => true,
|
134
|
+
:as => Integer,
|
135
|
+
:unless => :grep do |limit|
|
58
136
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
137
|
+
limit ||= 10
|
138
|
+
offset = history.size - limit
|
139
|
+
offset = offset < 0 ? 0 : offset
|
140
|
+
|
141
|
+
list = history.last limit
|
142
|
+
lines = text.with_line_numbers list.join("\n"), offset
|
143
|
+
stagger_output lines
|
63
144
|
end
|
64
145
|
|
65
|
-
opt.on :s, :show, 'Show the history corresponding to the history line (or range of lines).',
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
146
|
+
opt.on :s, :show, 'Show the history corresponding to the history line (or range of lines).',
|
147
|
+
true,
|
148
|
+
:as => Range,
|
149
|
+
:unless => :grep do |range|
|
150
|
+
|
151
|
+
start_line = range.is_a?(Range) ? range.first : range
|
152
|
+
lines = text.with_line_numbers Array(history[range]).join("\n"), start_line
|
153
|
+
stagger_output lines
|
71
154
|
end
|
72
155
|
|
73
|
-
opt.on :e, :exclude, 'Exclude pry commands from the history.' do
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
"#{text.blue index}: #{element}"
|
78
|
-
end
|
156
|
+
opt.on :e, :exclude, 'Exclude pry commands from the history.', :unless => :grep do
|
157
|
+
history.map!.with_index do |element, index|
|
158
|
+
unless command_processor.valid_command? element
|
159
|
+
"#{text.blue index}: #{element}"
|
79
160
|
end
|
80
|
-
stagger_output history.compact.join "\n"
|
81
161
|
end
|
162
|
+
stagger_output history.compact.join "\n"
|
82
163
|
end
|
83
164
|
|
84
|
-
opt.on :r, :replay, 'The line (or range of lines) to replay.',
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
165
|
+
opt.on :r, :replay, 'The line (or range of lines) to replay.',
|
166
|
+
true,
|
167
|
+
:as => Range,
|
168
|
+
:unless => :grep do |range|
|
169
|
+
actions = Array(history[range]).join("\n") + "\n"
|
170
|
+
_pry_.input = StringIO.new(actions)
|
89
171
|
end
|
90
172
|
|
91
|
-
opt.on
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
173
|
+
opt.on "save", "Save history to a file. --save [start..end] output.txt. Pry commands are excluded from saved history.", true, :as => Range
|
174
|
+
|
175
|
+
opt.on :c, :clear, 'Clear the history', :unless => :grep do
|
176
|
+
Pry.history.clear
|
177
|
+
output.puts 'History cleared.'
|
96
178
|
end
|
97
179
|
|
98
|
-
opt.on :h, :help, 'Show this message.', :tail => true do
|
99
|
-
|
100
|
-
output.puts opt.help
|
101
|
-
end
|
180
|
+
opt.on :h, :help, 'Show this message.', :tail => true, :unless => :grep do
|
181
|
+
output.puts opt.help
|
102
182
|
end
|
103
183
|
|
104
184
|
opt.on_empty do
|
@@ -106,6 +186,63 @@ class Pry
|
|
106
186
|
stagger_output lines
|
107
187
|
end
|
108
188
|
end
|
189
|
+
|
190
|
+
# FIXME: hack to save history (this must be refactored)
|
191
|
+
if opts["save"]
|
192
|
+
file_name = nil
|
193
|
+
hist_array = nil
|
194
|
+
|
195
|
+
case opts["save"]
|
196
|
+
when Range
|
197
|
+
hist_array = Array(history[opts["save"]])
|
198
|
+
next output.puts "Must provide a file name." if !args.first
|
199
|
+
file_name = File.expand_path(args.first)
|
200
|
+
when String
|
201
|
+
hist_array = history
|
202
|
+
file_name = File.expand_path(opts["save"])
|
203
|
+
end
|
204
|
+
|
205
|
+
output.puts "Saving history in #{file_name} ..."
|
206
|
+
# exclude pry commands
|
207
|
+
hist_array.reject! do |element|
|
208
|
+
command_processor.valid_command?(element)
|
209
|
+
end
|
210
|
+
|
211
|
+
File.open(file_name, 'w') do |f|
|
212
|
+
f.write hist_array.join("\n")
|
213
|
+
end
|
214
|
+
|
215
|
+
output.puts "... history saved."
|
216
|
+
end
|
217
|
+
|
218
|
+
end
|
219
|
+
|
220
|
+
alias_command "history", "hist", ""
|
221
|
+
|
222
|
+
helpers do
|
223
|
+
def one_index_number(line_number)
|
224
|
+
if line_number > 0
|
225
|
+
line_number - 1
|
226
|
+
elsif line_number < 0
|
227
|
+
line_number
|
228
|
+
else
|
229
|
+
line_number
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
def one_index_range(range)
|
234
|
+
Range.new(one_index_number(range.begin), one_index_number(range.end))
|
235
|
+
end
|
236
|
+
|
237
|
+
def one_index_range_or_number(range_or_number)
|
238
|
+
case range_or_number
|
239
|
+
when Range
|
240
|
+
one_index_range(range_or_number)
|
241
|
+
else
|
242
|
+
one_index_number(range_or_number)
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
109
246
|
end
|
110
247
|
|
111
248
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
|
1
3
|
class Pry
|
2
4
|
module DefaultCommands
|
3
5
|
|
@@ -7,11 +9,13 @@ class Pry
|
|
7
9
|
target = target()
|
8
10
|
|
9
11
|
opts = Slop.parse!(args) do |opt|
|
10
|
-
opt.banner "Usage: show-method [OPTIONS] [METH]\n" \
|
12
|
+
opt.banner "Usage: show-method [OPTIONS] [METH 1] [METH 2] [METH N]\n" \
|
11
13
|
"Show the source for method METH. Tries instance methods first and then methods by default.\n" \
|
12
14
|
"e.g: show-method hello_method"
|
13
15
|
|
14
16
|
opt.on :l, "line-numbers", "Show line numbers."
|
17
|
+
opt.on :b, "base-one", "Show line numbers but start numbering at 1 (useful for `amend-line` and `play` commands)."
|
18
|
+
|
15
19
|
opt.on :M, "instance-methods", "Operate on instance methods."
|
16
20
|
opt.on :m, :methods, "Operate on methods."
|
17
21
|
opt.on :f, :flood, "Do not use a pager to view text longer than one screen."
|
@@ -25,27 +29,33 @@ class Pry
|
|
25
29
|
|
26
30
|
next if opts.help?
|
27
31
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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
|
33
39
|
|
34
|
-
|
35
|
-
|
40
|
+
code, code_type = code_and_code_type_for(meth)
|
41
|
+
next if !code
|
36
42
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
43
|
+
output.puts make_header(meth, code_type, code)
|
44
|
+
if Pry.color
|
45
|
+
code = CodeRay.scan(code, code_type).term
|
46
|
+
end
|
41
47
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
48
|
+
start_line = false
|
49
|
+
if opts.l?
|
50
|
+
start_line = meth.source_location ? meth.source_location.last : 1
|
51
|
+
end
|
52
|
+
|
53
|
+
start_line = opts.b? ? 1 : start_line
|
46
54
|
|
47
|
-
|
48
|
-
|
55
|
+
|
56
|
+
render_output(opts.flood?, start_line, code)
|
57
|
+
code
|
58
|
+
end
|
49
59
|
end
|
50
60
|
|
51
61
|
alias_command "show-source", "show-method", ""
|
@@ -98,18 +108,83 @@ class Pry
|
|
98
108
|
end
|
99
109
|
end
|
100
110
|
|
111
|
+
command "edit", "Invoke the default editor on a file. Type `edit --help` for more info" do |*args|
|
112
|
+
opts = Slop.parse!(args) do |opt|
|
113
|
+
opt.banner "Usage: edit [OPTIONS] [FILE]\n" \
|
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" \
|
116
|
+
"e.g: edit sample.rb"
|
117
|
+
|
118
|
+
opt.on :r, "reload", "Eval file content after editing (evals at top level)"
|
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)"
|
122
|
+
opt.on :p, "play", "Use the pry `play` command to eval the file content after editing."
|
123
|
+
opt.on :l, "line", "Specify line number to jump to in file", true, :as => Integer
|
124
|
+
opt.on :h, :help, "This message." do
|
125
|
+
output.puts opt
|
126
|
+
end
|
127
|
+
end
|
128
|
+
next if opts.h?
|
129
|
+
|
130
|
+
should_reload_at_top_level = opts[:r]
|
131
|
+
should_reload_locally = false
|
132
|
+
|
133
|
+
if opts.ex?
|
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
|
141
|
+
|
142
|
+
line = _pry_.last_exception.line
|
143
|
+
next output.puts "Exception has no associated file." if file_name.nil?
|
144
|
+
next output.puts "Cannot edit exceptions raised in REPL." if Pry.eval_path == file_name
|
145
|
+
|
146
|
+
should_reload_at_top_level = opts[:n] ? false : true
|
147
|
+
|
148
|
+
elsif opts.t? || args.first.nil?
|
149
|
+
file_name = Tempfile.new(["tmp", ".rb"]).tap(&:close).path
|
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
|
153
|
+
else
|
154
|
+
file_name, line = File.expand_path(args.first).split(/:/)
|
155
|
+
line = line ? line.to_i : opts[:l].to_i
|
156
|
+
end
|
157
|
+
|
158
|
+
invoke_editor(file_name, line)
|
159
|
+
set_file_and_dir_locals(file_name)
|
160
|
+
|
161
|
+
if opts[:p]
|
162
|
+
silence_warnings do
|
163
|
+
_pry_.input = StringIO.new(File.readlines(file_name).join)
|
164
|
+
end
|
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
|
170
|
+
silence_warnings do
|
171
|
+
TOPLEVEL_BINDING.eval(File.read(file_name), file_name)
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
101
176
|
command "edit-method", "Edit a method. Type `edit-method --help` for more info." do |*args|
|
102
177
|
target = target()
|
103
178
|
|
104
179
|
opts = Slop.parse!(args) do |opt|
|
105
180
|
opt.banner "Usage: edit-method [OPTIONS] [METH]\n" \
|
106
181
|
"Edit the method METH in an editor.\n" \
|
107
|
-
"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" \
|
108
183
|
"e.g: edit-method hello_method"
|
109
184
|
|
110
185
|
opt.on :M, "instance-methods", "Operate on instance methods."
|
111
186
|
opt.on :m, :methods, "Operate on methods."
|
112
|
-
opt.on :n, "no-reload", "Do not automatically reload the method's file after
|
187
|
+
opt.on :n, "no-reload", "Do not automatically reload the method's file after editing."
|
113
188
|
opt.on "no-jump", "Do not fast forward editor to first line of method."
|
114
189
|
opt.on :c, :context, "Select object context to run under.", true do |context|
|
115
190
|
target = Pry.binding_for(target.eval(context))
|
@@ -127,7 +202,7 @@ class Pry
|
|
127
202
|
next
|
128
203
|
end
|
129
204
|
|
130
|
-
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
|
131
206
|
|
132
207
|
if is_a_c_method?(meth)
|
133
208
|
output.puts "Error: Can't edit a C method."
|
@@ -139,40 +214,13 @@ class Pry
|
|
139
214
|
file, line = path_line_for(meth)
|
140
215
|
set_file_and_dir_locals(file)
|
141
216
|
|
142
|
-
|
143
|
-
editor_invocation = Pry.editor.call(file, line)
|
144
|
-
else
|
145
|
-
# only use start line if -n option is not used
|
146
|
-
start_line_syntax = opts["no-jump"] ? "" : start_line_for_editor(line)
|
147
|
-
editor_invocation = "#{Pry.editor} #{start_line_syntax} #{file}"
|
148
|
-
end
|
149
|
-
|
150
|
-
run ".#{editor_invocation}"
|
217
|
+
invoke_editor(file, opts["no-jump"] ? 0 : line)
|
151
218
|
silence_warnings do
|
152
|
-
load file if !opts.n?
|
219
|
+
load file if !opts.n? && !Pry.config.disable_auto_reload
|
153
220
|
end
|
154
221
|
end
|
155
222
|
end
|
156
223
|
|
157
|
-
helpers do
|
158
|
-
|
159
|
-
def start_line_for_editor(line_number)
|
160
|
-
case Pry.editor
|
161
|
-
when /^[gm]?vi/, /^emacs/, /^nano/, /^pico/, /^gedit/, /^kate/
|
162
|
-
"+#{line_number}"
|
163
|
-
when /^mate/, /^geany/
|
164
|
-
"-l #{line_number}"
|
165
|
-
else
|
166
|
-
if RUBY_PLATFORM =~ /mswin|mingw/
|
167
|
-
""
|
168
|
-
else
|
169
|
-
"+#{line_number}"
|
170
|
-
end
|
171
|
-
end
|
172
|
-
end
|
173
|
-
|
174
|
-
end
|
175
|
-
|
176
224
|
end
|
177
225
|
end
|
178
226
|
end
|