pry 0.9.6.1-i386-mingw32 → 0.9.6.2-i386-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +5 -0
- data/Rakefile +6 -6
- data/lib/pry.rb +0 -3
- data/lib/pry/command_context.rb +0 -1
- data/lib/pry/command_set.rb +0 -2
- data/lib/pry/default_commands/basic.rb +7 -5
- data/lib/pry/default_commands/context.rb +3 -5
- data/lib/pry/default_commands/documentation.rb +79 -28
- data/lib/pry/default_commands/input.rb +7 -3
- data/lib/pry/default_commands/introspection.rb +52 -33
- data/lib/pry/default_commands/shell.rb +2 -2
- data/lib/pry/extended_commands/experimental.rb +6 -2
- data/lib/pry/helpers/base_helpers.rb +1 -1
- data/lib/pry/helpers/command_helpers.rb +247 -11
- data/lib/pry/version.rb +1 -1
- data/pry.gemspec +15 -15
- data/test/test_command_helpers.rb +69 -1
- data/test/test_command_set.rb +28 -29
- data/test/test_default_commands/test_introspection.rb +25 -0
- metadata +22 -27
- data/lib/pry/method.rb +0 -184
- data/lib/pry/rbx_method.rb +0 -20
- data/lib/pry/rbx_path.rb +0 -34
- data/test/test_method.rb +0 -72
data/CHANGELOG
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
27/9/2011 version 0.9.6.2 HOTFIX release
|
2
|
+
* downgrading to CodeRay 0.9.8 due to problems with 1.0 and rails (autoloading problem) see #280 on pry and #6 on CodeRay
|
3
|
+
* also added (as a minor feature) cirwin's implementation of edit --in
|
4
|
+
* added early break/exit for objectpath errors (the 'cd 34/@hello/bad_path/23')
|
5
|
+
|
1
6
|
19/9/2011 version 0.9.6
|
2
7
|
* restored previous behavior of command-line switches (allowing "-rfilename")
|
3
8
|
* removed -p option (--play) from edit command
|
data/Rakefile
CHANGED
@@ -21,11 +21,11 @@ def apply_spec_defaults(s)
|
|
21
21
|
s.executables = ["pry"]
|
22
22
|
s.files = `git ls-files`.split("\n")
|
23
23
|
s.test_files = `git ls-files -- test/*`.split("\n")
|
24
|
-
s.add_dependency("ruby_parser","
|
25
|
-
s.add_dependency("coderay","
|
24
|
+
s.add_dependency("ruby_parser","~>2.0.5")
|
25
|
+
s.add_dependency("coderay","~>0.9.8")
|
26
26
|
s.add_dependency("slop","~>2.1.0")
|
27
|
-
s.add_dependency("method_source","
|
28
|
-
s.add_development_dependency("bacon","
|
27
|
+
s.add_dependency("method_source","~>0.6.5")
|
28
|
+
s.add_development_dependency("bacon","~>1.1.0")
|
29
29
|
s.add_development_dependency("open4", "~>1.0.1")
|
30
30
|
s.add_development_dependency("rake", "~>0.9")
|
31
31
|
end
|
@@ -70,7 +70,7 @@ end
|
|
70
70
|
namespace :jruby do
|
71
71
|
spec = Gem::Specification.new do |s|
|
72
72
|
apply_spec_defaults(s)
|
73
|
-
s.add_dependency("spoon", "
|
73
|
+
s.add_dependency("spoon", "~>0.0.1")
|
74
74
|
s.platform = "java"
|
75
75
|
end
|
76
76
|
|
@@ -85,7 +85,7 @@ end
|
|
85
85
|
namespace v do
|
86
86
|
spec = Gem::Specification.new do |s|
|
87
87
|
apply_spec_defaults(s)
|
88
|
-
s.add_dependency("win32console", "
|
88
|
+
s.add_dependency("win32console", "~>1.3.0")
|
89
89
|
s.platform = "i386-#{v}"
|
90
90
|
end
|
91
91
|
|
data/lib/pry.rb
CHANGED
@@ -173,9 +173,6 @@ if RUBY_PLATFORM =~ /mswin/ || RUBY_PLATFORM =~ /mingw/
|
|
173
173
|
end
|
174
174
|
|
175
175
|
require "pry/version"
|
176
|
-
require "pry/rbx_method"
|
177
|
-
require "pry/rbx_path"
|
178
|
-
require "pry/method"
|
179
176
|
require "pry/history_array"
|
180
177
|
require "pry/helpers"
|
181
178
|
require "pry/history"
|
data/lib/pry/command_context.rb
CHANGED
data/lib/pry/command_set.rb
CHANGED
@@ -28,15 +28,17 @@ class Pry
|
|
28
28
|
end
|
29
29
|
|
30
30
|
command "reload-method", "Reload the source file that contains the specified method" do |meth_name|
|
31
|
-
meth =
|
32
|
-
|
31
|
+
if (meth = get_method_object(meth_name, target, {})).nil?
|
32
|
+
output.puts "Invalid method name: #{meth_name}."
|
33
|
+
next
|
34
|
+
end
|
33
35
|
|
34
|
-
if meth
|
36
|
+
if is_a_c_method?(meth)
|
35
37
|
output.puts "Error: Can't reload a C method."
|
36
|
-
elsif meth
|
38
|
+
elsif is_a_dynamically_defined_method?(meth)
|
37
39
|
output.puts "Error: Can't reload an eval method."
|
38
40
|
else
|
39
|
-
file_name = meth.
|
41
|
+
file_name = meth.source_location.first
|
40
42
|
load file_name
|
41
43
|
output.puts "Reloaded #{file_name}."
|
42
44
|
end
|
@@ -37,6 +37,7 @@ class Pry
|
|
37
37
|
rescue RescuableException
|
38
38
|
output.puts "Bad object path: #{arg_string}. Failed trying to resolve: #{context}"
|
39
39
|
resolve_failure = true
|
40
|
+
break
|
40
41
|
end
|
41
42
|
end
|
42
43
|
|
@@ -136,11 +137,8 @@ class Pry
|
|
136
137
|
i_num = 5
|
137
138
|
end
|
138
139
|
|
139
|
-
|
140
|
-
|
141
|
-
else
|
142
|
-
meth_name = "N/A"
|
143
|
-
end
|
140
|
+
meth_name = meth_name_from_binding(target)
|
141
|
+
meth_name = "N/A" if !meth_name
|
144
142
|
|
145
143
|
if file =~ /(\(.*\))|<.*>/ || file == "" || file == "-e"
|
146
144
|
output.puts "Cannot find local context. Did you use `binding.pry` ?"
|
@@ -32,15 +32,20 @@ class Pry
|
|
32
32
|
|
33
33
|
args = [nil] if args.empty?
|
34
34
|
args.each do |method_name|
|
35
|
-
|
36
|
-
|
35
|
+
meth_name = method_name
|
36
|
+
if (meth = get_method_object(meth_name, target, opts.to_hash(true))).nil?
|
37
|
+
output.puts "Invalid method name: #{meth_name}. Type `show-doc --help` for help"
|
38
|
+
next
|
39
|
+
end
|
37
40
|
|
38
|
-
|
41
|
+
doc, code_type = doc_and_code_type_for(meth)
|
42
|
+
next if !doc
|
39
43
|
|
40
|
-
|
41
|
-
|
42
|
-
output.puts
|
43
|
-
output.puts "#{text.bold("
|
44
|
+
next output.puts("No documentation found.") if doc.empty?
|
45
|
+
doc = process_comment_markup(doc, code_type)
|
46
|
+
output.puts make_header(meth, code_type, doc)
|
47
|
+
output.puts "#{text.bold("visibility: ")} #{method_visibility(meth).to_s}"
|
48
|
+
output.puts "#{text.bold("signature: ")} #{signature_for(meth)}"
|
44
49
|
output.puts
|
45
50
|
render_output(opts.flood?, false, doc)
|
46
51
|
doc
|
@@ -71,20 +76,26 @@ class Pry
|
|
71
76
|
|
72
77
|
next if opts.help?
|
73
78
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
79
|
+
meth_name = args.shift
|
80
|
+
if (meth = get_method_object(meth_name, target, opts.to_hash(true))).nil?
|
81
|
+
output.puts "Invalid method name: #{meth_name}. Type `stat --help` for help"
|
82
|
+
next
|
83
|
+
end
|
84
|
+
|
85
|
+
if !is_a_c_method?(meth) && !is_a_dynamically_defined_method?(meth)
|
86
|
+
set_file_and_dir_locals(path_line_for(meth).first)
|
87
|
+
end
|
88
|
+
|
89
|
+
output.puts "Method Information:"
|
90
|
+
output.puts "--"
|
91
|
+
output.puts "Name: " + meth_name
|
92
|
+
output.puts "Owner: " + (meth.owner.to_s ? meth.owner.to_s : "Unknown")
|
93
|
+
output.puts "Visibility: " + method_visibility(meth).to_s
|
94
|
+
output.puts "Type: " + (meth.is_a?(Method) ? "Bound" : "Unbound")
|
95
|
+
output.puts "Arity: " + meth.arity.to_s
|
96
|
+
output.puts "Method Signature: " + signature_for(meth)
|
97
|
+
|
98
|
+
output.puts "Source location: " + (meth.source_location ? meth.source_location.join(":") : "Not found.")
|
88
99
|
end
|
89
100
|
|
90
101
|
command "gist-method", "Gist a method to github. Type `gist-method --help` for more info.", :requires_gem => "gist" do |*args|
|
@@ -111,17 +122,19 @@ class Pry
|
|
111
122
|
|
112
123
|
next if opts.help?
|
113
124
|
|
114
|
-
|
115
|
-
|
125
|
+
# This needs to be extracted into its own method as it's shared
|
126
|
+
# by show-method and show-doc and stat commands
|
127
|
+
meth_name = args.shift
|
128
|
+
if (meth = get_method_object(meth_name, target, opts.to_hash(true))).nil?
|
129
|
+
output.puts "Invalid method name: #{meth_name}. Type `gist-method --help` for help"
|
130
|
+
next
|
131
|
+
end
|
116
132
|
|
117
133
|
type_map = { :ruby => "rb", :c => "c", :plain => "plain" }
|
118
134
|
if !opts.doc?
|
119
|
-
content = meth
|
120
|
-
code_type = meth.source_type
|
135
|
+
content, code_type = code_and_code_type_for(meth)
|
121
136
|
else
|
122
|
-
content = meth
|
123
|
-
code_type = meth.source_type
|
124
|
-
|
137
|
+
content, code_type = doc_and_code_type_for(meth)
|
125
138
|
text.no_color do
|
126
139
|
content = process_comment_markup(content, code_type)
|
127
140
|
end
|
@@ -134,6 +147,44 @@ class Pry
|
|
134
147
|
|
135
148
|
output.puts "Gist created at #{link}"
|
136
149
|
end
|
150
|
+
|
151
|
+
helpers do
|
152
|
+
|
153
|
+
# paraphrased from awesome_print gem
|
154
|
+
def signature_for(method)
|
155
|
+
if method.respond_to?(:parameters)
|
156
|
+
|
157
|
+
args = method.parameters.inject([]) do |arr, (type, name)|
|
158
|
+
name ||= (type == :block ? 'block' : "arg#{arr.size + 1}")
|
159
|
+
arr << case type
|
160
|
+
when :req then name.to_s
|
161
|
+
when :opt, :rest then "*#{name}"
|
162
|
+
when :block then "&#{name}"
|
163
|
+
else '?'
|
164
|
+
end
|
165
|
+
end
|
166
|
+
else
|
167
|
+
args = (1..method.arity.abs).map { |i| "arg#{i}" }
|
168
|
+
args[-1] = "*#{args[-1]}" if method.arity < 0
|
169
|
+
end
|
170
|
+
|
171
|
+
"#{method.name}(#{args.join(', ')})"
|
172
|
+
end
|
173
|
+
|
174
|
+
def method_visibility(meth)
|
175
|
+
if meth.owner.public_instance_methods.include? meth.name
|
176
|
+
:public
|
177
|
+
elsif meth.owner.protected_instance_methods.include? meth.name
|
178
|
+
:protected
|
179
|
+
elsif meth.owner.private_instance_methods.include? meth.name
|
180
|
+
:private
|
181
|
+
else
|
182
|
+
:none
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
137
187
|
end
|
188
|
+
|
138
189
|
end
|
139
190
|
end
|
@@ -77,13 +77,17 @@ class Pry
|
|
77
77
|
|
78
78
|
if opts.m?
|
79
79
|
meth_name = opts[:m]
|
80
|
-
meth =
|
81
|
-
|
80
|
+
if (meth = get_method_object(meth_name, target, {})).nil?
|
81
|
+
output.puts "Invalid method name: #{meth_name}."
|
82
|
+
next
|
83
|
+
end
|
84
|
+
code, _ = code_and_code_type_for(meth)
|
85
|
+
next if !code
|
82
86
|
|
83
87
|
range = opts.l? ? one_index_range_or_number(opts[:l]) : (0..-1)
|
84
88
|
range = (0..-2) if opts.o?
|
85
89
|
|
86
|
-
eval_string << Array(
|
90
|
+
eval_string << Array(code.each_line.to_a[range]).join
|
87
91
|
elsif opts.f?
|
88
92
|
file_name = File.expand_path(opts[:f])
|
89
93
|
next output.puts "No such file: #{opts[:f]}" if !File.exists?(file_name)
|
@@ -28,28 +28,33 @@ class Pry
|
|
28
28
|
output.puts opt
|
29
29
|
end
|
30
30
|
end
|
31
|
+
|
31
32
|
next if opts.help?
|
32
|
-
opts[:instance] = opts['instance-methods'] if opts.m?
|
33
33
|
|
34
34
|
args = [nil] if args.empty?
|
35
35
|
args.each do |method_name|
|
36
|
-
|
37
|
-
|
36
|
+
meth_name = method_name
|
37
|
+
if (meth = get_method_object(meth_name, target, opts.to_hash(true))).nil?
|
38
|
+
output.puts "Invalid method name: #{meth_name}. Type `show-method --help` for help"
|
39
|
+
next
|
40
|
+
end
|
41
|
+
|
42
|
+
code, code_type = code_and_code_type_for(meth)
|
43
|
+
next if !code
|
38
44
|
|
39
|
-
output.puts make_header(meth)
|
45
|
+
output.puts make_header(meth, code_type, code)
|
40
46
|
if Pry.color
|
41
|
-
code = CodeRay.scan(
|
42
|
-
else
|
43
|
-
code = meth.source
|
47
|
+
code = CodeRay.scan(code, code_type).term
|
44
48
|
end
|
45
49
|
|
46
50
|
start_line = false
|
47
|
-
if opts.
|
48
|
-
start_line = 1
|
49
|
-
elsif opts.l?
|
50
|
-
start_line = meth.source_line || 1
|
51
|
+
if opts.l?
|
52
|
+
start_line = meth.source_location ? meth.source_location.last : 1
|
51
53
|
end
|
52
54
|
|
55
|
+
start_line = opts.b? ? 1 : start_line
|
56
|
+
|
57
|
+
|
53
58
|
render_output(opts.flood?, start_line, code)
|
54
59
|
code
|
55
60
|
end
|
@@ -84,25 +89,23 @@ class Pry
|
|
84
89
|
end
|
85
90
|
|
86
91
|
if find_command(command_name)
|
87
|
-
block =
|
92
|
+
block = find_command(command_name).block
|
88
93
|
|
89
|
-
|
90
|
-
|
94
|
+
code, _ = code_and_code_type_for(block)
|
95
|
+
next if !code
|
91
96
|
|
92
|
-
output.puts make_header(block)
|
97
|
+
output.puts make_header(block, :ruby, code)
|
93
98
|
|
94
99
|
if Pry.color
|
95
|
-
code = CodeRay.scan(
|
96
|
-
else
|
97
|
-
code = block.source
|
100
|
+
code = CodeRay.scan(code, :ruby).term
|
98
101
|
end
|
99
102
|
|
100
103
|
start_line = false
|
101
104
|
if opts.l?
|
102
|
-
start_line = block.
|
105
|
+
start_line = block.source_location ? block.source_location.last : 1
|
103
106
|
end
|
104
107
|
|
105
|
-
render_output(opts.flood?, opts.l? ? block.
|
108
|
+
render_output(opts.flood?, opts.l? ? block.source_location.last : false, code)
|
106
109
|
code
|
107
110
|
else
|
108
111
|
output.puts "No such command: #{command_name}."
|
@@ -119,7 +122,7 @@ class Pry
|
|
119
122
|
USAGE
|
120
123
|
|
121
124
|
opt.on :e, :ex, "Open the file that raised the most recent exception (_ex_.file)", :optional => true, :as => Integer
|
122
|
-
opt.on :i, :in, "Open a temporary file containing the
|
125
|
+
opt.on :i, :in, "Open a temporary file containing the Nth line of _in_. N may be a range.", :optional => true, :as => Range, :default => -1..-1
|
123
126
|
opt.on :t, :temp, "Open an empty temporary file"
|
124
127
|
opt.on :l, :line, "Jump to this line in the opened file", true, :as => Integer
|
125
128
|
opt.on :n, :"no-reload", "Don't automatically reload the edited code"
|
@@ -130,8 +133,8 @@ class Pry
|
|
130
133
|
end
|
131
134
|
next if opts.h?
|
132
135
|
|
133
|
-
if [opts.ex
|
134
|
-
next output.puts "Only one of --ex, --temp, and FILE may be specified"
|
136
|
+
if [opts.ex?, opts.t?, opts.in?, !args.empty?].count(true) > 1
|
137
|
+
next output.puts "Only one of --ex, --temp, --in and FILE may be specified"
|
135
138
|
end
|
136
139
|
|
137
140
|
# edit of local code, eval'd within pry.
|
@@ -140,7 +143,14 @@ class Pry
|
|
140
143
|
content = if opts.t?
|
141
144
|
""
|
142
145
|
elsif opts.i?
|
143
|
-
|
146
|
+
case opts[:i]
|
147
|
+
when Range
|
148
|
+
(_pry_.input_array[opts[:i]] || []).join
|
149
|
+
when Fixnum
|
150
|
+
_pry_.input_array[opts[:i]] || ""
|
151
|
+
else
|
152
|
+
next output.puts "Not a valid range: #{opts[:i]}"
|
153
|
+
end
|
144
154
|
elsif eval_string.strip != ""
|
145
155
|
eval_string
|
146
156
|
else
|
@@ -168,8 +178,8 @@ class Pry
|
|
168
178
|
bt_index = opts[:ex].to_i
|
169
179
|
|
170
180
|
ex_file, ex_line = ex.bt_source_location_for(bt_index)
|
171
|
-
if ex_file &&
|
172
|
-
file_name =
|
181
|
+
if ex_file && is_core_rbx_path?(ex_file)
|
182
|
+
file_name = rbx_convert_path_to_full(ex_file)
|
173
183
|
else
|
174
184
|
file_name = ex_file
|
175
185
|
end
|
@@ -221,6 +231,7 @@ class Pry
|
|
221
231
|
output.puts opt
|
222
232
|
end
|
223
233
|
end
|
234
|
+
|
224
235
|
next if opts.help?
|
225
236
|
|
226
237
|
if !Pry.config.editor
|
@@ -229,14 +240,21 @@ class Pry
|
|
229
240
|
next
|
230
241
|
end
|
231
242
|
|
232
|
-
|
233
|
-
|
243
|
+
meth_name = args.shift
|
244
|
+
meth_name, target, type = get_method_attributes(meth_name, target, opts.to_hash(true))
|
245
|
+
meth = get_method_object_from_target(meth_name, target, type)
|
246
|
+
|
247
|
+
if meth.nil?
|
248
|
+
output.puts "Invalid method name: #{meth_name}."
|
249
|
+
next
|
250
|
+
end
|
234
251
|
|
235
|
-
if opts.p? || meth
|
236
|
-
|
252
|
+
if opts.p? || is_a_dynamically_defined_method?(meth)
|
253
|
+
code, _ = code_and_code_type_for(meth)
|
237
254
|
|
255
|
+
lines = code.lines.to_a
|
238
256
|
if lines[0] =~ /^def [^( \n]+/
|
239
|
-
lines[0] = "def #{
|
257
|
+
lines[0] = "def #{meth_name}#{$'}"
|
240
258
|
else
|
241
259
|
next output.puts "Error: Pry can only patch methods created with the `def` keyword."
|
242
260
|
end
|
@@ -250,10 +268,11 @@ class Pry
|
|
250
268
|
next
|
251
269
|
end
|
252
270
|
|
253
|
-
if meth
|
271
|
+
if is_a_c_method?(meth)
|
254
272
|
output.puts "Error: Can't edit a C method."
|
255
273
|
else
|
256
|
-
file, line = meth
|
274
|
+
file, line = path_line_for(meth)
|
275
|
+
set_file_and_dir_locals(file)
|
257
276
|
|
258
277
|
invoke_editor(file, opts["no-jump"] ? 0 : line)
|
259
278
|
silence_warnings do
|