pry 0.9.6.1-i386-mswin32 → 0.9.6.2-i386-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -61,8 +61,8 @@ class Pry
|
|
61
61
|
start_line = (ex_line - 1) - window_size
|
62
62
|
start_line = start_line < 0 ? 0 : start_line
|
63
63
|
end_line = (ex_line - 1) + window_size
|
64
|
-
if ex_file &&
|
65
|
-
file_name =
|
64
|
+
if ex_file && is_core_rbx_path?(ex_file)
|
65
|
+
file_name = rbx_convert_path_to_full(ex_file)
|
66
66
|
else
|
67
67
|
file_name = ex_file
|
68
68
|
end
|
@@ -4,8 +4,12 @@ class Pry
|
|
4
4
|
Experimental = Pry::CommandSet.new do
|
5
5
|
|
6
6
|
command "reload-method", "Reload the source specifically for a method", :requires_gem => "method_reload" do |meth_name|
|
7
|
-
meth =
|
8
|
-
|
7
|
+
if (meth = get_method_object(meth_name, target, {})).nil?
|
8
|
+
output.puts "Invalid method name: #{meth_name}."
|
9
|
+
next
|
10
|
+
end
|
11
|
+
|
12
|
+
meth.reload
|
9
13
|
end
|
10
14
|
end
|
11
15
|
end
|
@@ -5,6 +5,15 @@ class Pry
|
|
5
5
|
|
6
6
|
module_function
|
7
7
|
|
8
|
+
def meth_name_from_binding(b)
|
9
|
+
meth_name = b.eval('__method__')
|
10
|
+
if [:__script__, nil, :__binding__, :__binding_impl__].include?(meth_name)
|
11
|
+
nil
|
12
|
+
else
|
13
|
+
meth_name
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
8
17
|
# if start_line is not false then add line numbers starting with start_line
|
9
18
|
def render_output(should_flood, start_line, text, color=:blue)
|
10
19
|
if start_line
|
@@ -18,6 +27,18 @@ class Pry
|
|
18
27
|
end
|
19
28
|
end
|
20
29
|
|
30
|
+
def is_a_dynamically_defined_method?(meth)
|
31
|
+
file, _ = meth.source_location
|
32
|
+
!!(file =~ /(\(.*\))|<.*>/)
|
33
|
+
end
|
34
|
+
|
35
|
+
def check_for_dynamically_defined_method(meth)
|
36
|
+
file, _ = meth.source_location
|
37
|
+
if file =~ /(\(.*\))|<.*>/ && file != Pry.eval_path
|
38
|
+
raise "Cannot retrieve source for dynamically defined method."
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
21
42
|
# Open a temp file and yield it to the block, closing it after
|
22
43
|
# @return [String] The path of the temp file
|
23
44
|
def temp_file
|
@@ -27,28 +48,225 @@ class Pry
|
|
27
48
|
file.close
|
28
49
|
end
|
29
50
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
51
|
+
########### RBX HELPERS #############
|
52
|
+
def is_core_rbx_path?(path)
|
53
|
+
rbx? &&
|
54
|
+
path.start_with?("kernel")
|
55
|
+
end
|
56
|
+
|
57
|
+
def rbx_core?(meth)
|
58
|
+
meth.source_location &&
|
59
|
+
is_core_rbx_path?(meth.source_location.first)
|
60
|
+
end
|
61
|
+
|
62
|
+
def rvm_ruby?(path)
|
63
|
+
!!(path =~ /\.rvm/)
|
64
|
+
end
|
65
|
+
|
66
|
+
def rbx_core_code_for(meth)
|
67
|
+
rbx_core_code_or_doc_for(meth, :code)
|
68
|
+
end
|
69
|
+
|
70
|
+
def rbx_core_doc_for(meth)
|
71
|
+
rbx_core_code_or_doc_for(meth, :doc)
|
72
|
+
end
|
73
|
+
|
74
|
+
def rbx_core_code_or_doc_for(meth, code_or_doc)
|
75
|
+
path_line = rbx_core_path_line_for(meth)
|
76
|
+
|
77
|
+
case code_or_doc
|
78
|
+
when :code
|
79
|
+
MethodSource.source_helper(path_line)
|
80
|
+
when :doc
|
81
|
+
MethodSource.comment_helper(path_line)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def rbx_convert_path_to_full(path)
|
86
|
+
if rvm_ruby?(Rubinius::BIN_PATH)
|
87
|
+
rbx_rvm_convert_path_to_full(path)
|
88
|
+
else
|
89
|
+
rbx_std_convert_path_to_full(path)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def rbx_rvm_convert_path_to_full(path)
|
94
|
+
ruby_name = File.dirname(Rubinius::BIN_PATH).split("/").last
|
95
|
+
source_path = File.join(File.dirname(File.dirname(File.dirname(Rubinius::BIN_PATH))), "src", ruby_name)
|
96
|
+
file_name = File.join(source_path, path)
|
97
|
+
raise "Cannot find rbx core source" if !File.exists?(file_name)
|
98
|
+
file_name
|
99
|
+
end
|
100
|
+
|
101
|
+
def rbx_std_convert_path_to_full(path)
|
102
|
+
file_name = File.join(Rubinius::BIN_PATH, "..", path)
|
103
|
+
raise "Cannot find rbx core source" if !File.exists?(file_name)
|
104
|
+
file_name
|
105
|
+
end
|
106
|
+
|
107
|
+
def rbx_core_path_line_for(meth)
|
108
|
+
if rvm_ruby?(Rubinius::BIN_PATH)
|
109
|
+
rvm_rbx_core_path_line_for(meth)
|
110
|
+
else
|
111
|
+
std_rbx_core_path_line_for(meth)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def std_rbx_core_path_line_for(meth)
|
116
|
+
file_name = rbx_std_convert_path_to_full(meth.source_location.first)
|
117
|
+
start_line = meth.source_location.last
|
118
|
+
|
119
|
+
[file_name, start_line]
|
120
|
+
end
|
121
|
+
|
122
|
+
def rvm_rbx_core_path_line_for(meth)
|
123
|
+
file_name = rbx_rvm_convert_path_to_full(meth.source_location.first)
|
124
|
+
start_line = meth.source_location.last
|
125
|
+
|
126
|
+
[file_name, start_line]
|
127
|
+
end
|
128
|
+
|
129
|
+
######### END RBX HELPERS ###############
|
130
|
+
|
131
|
+
def code_and_code_type_for(meth)
|
132
|
+
case code_type = code_type_for(meth)
|
133
|
+
when nil
|
134
|
+
return nil
|
135
|
+
when :c
|
136
|
+
code = Pry::MethodInfo.info_for(meth).source
|
137
|
+
code = strip_comments_from_c_code(code)
|
138
|
+
when :ruby
|
139
|
+
if meth.source_location.first == Pry.eval_path
|
140
|
+
start_line = meth.source_location.last
|
141
|
+
|
142
|
+
# FIXME this line below needs to be refactored, WAY too
|
143
|
+
# much of a hack. We pass nothing to prompt because if
|
144
|
+
# prompt uses #inspect (or #pretty_inspect) on the context
|
145
|
+
# it can hang the session if the object being inspected on
|
146
|
+
# is enormous see: https://github.com/pry/pry/issues/245
|
147
|
+
p = Pry.new(:input => StringIO.new(Pry.line_buffer[start_line..-1].join), :prompt => proc {""}, :hooks => {}).r(target)
|
148
|
+
code = strip_leading_whitespace(p)
|
149
|
+
else
|
150
|
+
if rbx_core?(meth)
|
151
|
+
code = strip_leading_whitespace(rbx_core_code_for(meth))
|
152
|
+
else
|
153
|
+
code = strip_leading_whitespace(meth.source)
|
154
|
+
end
|
155
|
+
end
|
156
|
+
set_file_and_dir_locals(path_line_for(meth).first)
|
157
|
+
end
|
158
|
+
|
159
|
+
[code, code_type]
|
160
|
+
end
|
161
|
+
|
162
|
+
def doc_and_code_type_for(meth)
|
163
|
+
case code_type = code_type_for(meth)
|
164
|
+
when nil
|
165
|
+
return nil
|
166
|
+
when :c
|
167
|
+
doc = Pry::MethodInfo.info_for(meth).docstring
|
168
|
+
when :ruby
|
169
|
+
if rbx_core?(meth)
|
170
|
+
doc = strip_leading_hash_and_whitespace_from_ruby_comments(rbx_core_doc_for(meth))
|
171
|
+
else
|
172
|
+
doc = strip_leading_hash_and_whitespace_from_ruby_comments(meth.comment)
|
173
|
+
end
|
174
|
+
set_file_and_dir_locals(path_line_for(meth).first)
|
175
|
+
end
|
176
|
+
|
177
|
+
[doc, code_type]
|
178
|
+
end
|
179
|
+
|
180
|
+
def get_method_object(meth_name, target=nil, options={})
|
181
|
+
get_method_object_from_target(*get_method_attributes(meth_name, target, options)) rescue nil
|
182
|
+
end
|
183
|
+
|
184
|
+
def get_method_attributes(meth_name, target=nil, options={})
|
185
|
+
if meth_name
|
186
|
+
if meth_name =~ /(\S+)\#(\S+)\Z/
|
187
|
+
context, meth_name = $1, $2
|
188
|
+
target = Pry.binding_for(target.eval(context))
|
189
|
+
type = :instance
|
190
|
+
elsif meth_name =~ /(\S+)\.(\S+)\Z/
|
191
|
+
context, meth_name = $1, $2
|
192
|
+
target = Pry.binding_for(target.eval(context))
|
193
|
+
type = :singleton
|
194
|
+
elsif options["instance_methods"]
|
195
|
+
type = :instance
|
196
|
+
elsif options[:methods]
|
197
|
+
type = :singleton
|
198
|
+
else
|
199
|
+
type = nil
|
200
|
+
end
|
34
201
|
else
|
35
|
-
|
36
|
-
|
37
|
-
output.print " Type `#{command_name} --help` for help." unless omit_cmd
|
38
|
-
output.puts
|
202
|
+
meth_name = meth_name_from_binding(target)
|
203
|
+
type = nil
|
39
204
|
end
|
205
|
+
[meth_name, target, type]
|
40
206
|
end
|
41
207
|
|
42
|
-
def
|
43
|
-
|
208
|
+
def get_method_object_from_target(meth_name, target, type=nil)
|
209
|
+
case type
|
210
|
+
when :instance
|
211
|
+
target.eval("instance_method(:#{meth_name})") rescue nil
|
212
|
+
when :singleton
|
213
|
+
target.eval("method(:#{meth_name})") rescue nil
|
214
|
+
else
|
215
|
+
get_method_object_from_target(meth_name, target, :instance) ||
|
216
|
+
get_method_object_from_target(meth_name, target, :singleton)
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
def path_line_for(meth)
|
221
|
+
if rbx_core?(meth)
|
222
|
+
rbx_core_path_line_for(meth)
|
223
|
+
else
|
224
|
+
meth.source_location
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
def make_header(meth, code_type, content)
|
44
229
|
num_lines = "Number of lines: #{Pry::Helpers::Text.bold(content.each_line.count.to_s)}"
|
45
230
|
case code_type
|
46
|
-
when :
|
231
|
+
when :ruby
|
232
|
+
file, line = path_line_for(meth)
|
233
|
+
"\n#{Pry::Helpers::Text.bold('From:')} #{file} @ line #{line}:\n#{num_lines}\n\n"
|
234
|
+
else
|
47
235
|
file = Pry::MethodInfo.info_for(meth).file
|
48
236
|
"\n#{Pry::Helpers::Text.bold('From:')} #{file} in Ruby Core (C Method):\n#{num_lines}\n\n"
|
49
237
|
end
|
50
238
|
end
|
51
239
|
|
240
|
+
def is_a_c_method?(meth)
|
241
|
+
meth.source_location.nil?
|
242
|
+
end
|
243
|
+
|
244
|
+
def should_use_pry_doc?(meth)
|
245
|
+
Pry.config.has_pry_doc && is_a_c_method?(meth)
|
246
|
+
end
|
247
|
+
|
248
|
+
def code_type_for(meth)
|
249
|
+
# only C methods
|
250
|
+
if should_use_pry_doc?(meth)
|
251
|
+
info = Pry::MethodInfo.info_for(meth)
|
252
|
+
if info && info.source
|
253
|
+
code_type = :c
|
254
|
+
else
|
255
|
+
output.puts "Cannot find C method: #{meth.name}"
|
256
|
+
code_type = nil
|
257
|
+
end
|
258
|
+
else
|
259
|
+
if is_a_c_method?(meth)
|
260
|
+
output.puts "Cannot locate this method: #{meth.name}. Try `gem install pry-doc` to get access to Ruby Core documentation."
|
261
|
+
code_type = nil
|
262
|
+
else
|
263
|
+
check_for_dynamically_defined_method(meth)
|
264
|
+
code_type = :ruby
|
265
|
+
end
|
266
|
+
end
|
267
|
+
code_type
|
268
|
+
end
|
269
|
+
|
52
270
|
def file_map
|
53
271
|
{
|
54
272
|
[".c", ".h"] => :c,
|
@@ -139,6 +357,24 @@ class Pry
|
|
139
357
|
process_yardoc process_rdoc(comment, code_type)
|
140
358
|
end
|
141
359
|
|
360
|
+
# strip leading whitespace but preserve indentation
|
361
|
+
def strip_leading_whitespace(text)
|
362
|
+
return text if text.empty?
|
363
|
+
leading_spaces = text.lines.first[/^(\s+)/, 1]
|
364
|
+
text.gsub(/^#{leading_spaces}/, '')
|
365
|
+
end
|
366
|
+
|
367
|
+
def strip_leading_hash_and_whitespace_from_ruby_comments(comment)
|
368
|
+
comment = comment.dup
|
369
|
+
comment.gsub!(/\A\#+?$/, '')
|
370
|
+
comment.gsub!(/^\s*#/, '')
|
371
|
+
strip_leading_whitespace(comment)
|
372
|
+
end
|
373
|
+
|
374
|
+
def strip_comments_from_c_code(code)
|
375
|
+
code.sub(/\A\s*\/\*.*?\*\/\s*/m, '')
|
376
|
+
end
|
377
|
+
|
142
378
|
def invoke_editor(file, line)
|
143
379
|
if Pry.config.editor.respond_to?(:call)
|
144
380
|
editor_invocation = Pry.config.editor.call(file, line)
|
data/lib/pry/version.rb
CHANGED
data/pry.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{pry}
|
5
|
-
s.version = "0.9.6.
|
5
|
+
s.version = "0.9.6.2"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = [%q{John Mair (banisterfiend)}]
|
@@ -10,39 +10,39 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.description = %q{An IRB alternative and runtime developer console}
|
11
11
|
s.email = %q{jrmair@gmail.com}
|
12
12
|
s.executables = [%q{pry}]
|
13
|
-
s.files = [%q{.document}, %q{.gemtest}, %q{.gitignore}, %q{.travis.yml}, %q{.yardopts}, %q{CHANGELOG}, %q{CONTRIBUTORS}, %q{Gemfile}, %q{LICENSE}, %q{README.markdown}, %q{Rakefile}, %q{TODO}, %q{bin/pry}, %q{examples/example_basic.rb}, %q{examples/example_command_override.rb}, %q{examples/example_commands.rb}, %q{examples/example_hooks.rb}, %q{examples/example_image_edit.rb}, %q{examples/example_input.rb}, %q{examples/example_input2.rb}, %q{examples/example_output.rb}, %q{examples/example_print.rb}, %q{examples/example_prompt.rb}, %q{examples/helper.rb}, %q{lib/pry.rb}, %q{lib/pry/command_context.rb}, %q{lib/pry/command_processor.rb}, %q{lib/pry/command_set.rb}, %q{lib/pry/commands.rb}, %q{lib/pry/completion.rb}, %q{lib/pry/config.rb}, %q{lib/pry/core_extensions.rb}, %q{lib/pry/custom_completions.rb}, %q{lib/pry/default_commands/basic.rb}, %q{lib/pry/default_commands/context.rb}, %q{lib/pry/default_commands/documentation.rb}, %q{lib/pry/default_commands/easter_eggs.rb}, %q{lib/pry/default_commands/gems.rb}, %q{lib/pry/default_commands/input.rb}, %q{lib/pry/default_commands/introspection.rb}, %q{lib/pry/default_commands/ls.rb}, %q{lib/pry/default_commands/shell.rb}, %q{lib/pry/extended_commands/experimental.rb}, %q{lib/pry/extended_commands/user_command_api.rb}, %q{lib/pry/helpers.rb}, %q{lib/pry/helpers/base_helpers.rb}, %q{lib/pry/helpers/command_helpers.rb}, %q{lib/pry/helpers/text.rb}, %q{lib/pry/history.rb}, %q{lib/pry/history_array.rb}, %q{lib/pry/
|
13
|
+
s.files = [%q{.document}, %q{.gemtest}, %q{.gitignore}, %q{.travis.yml}, %q{.yardopts}, %q{CHANGELOG}, %q{CONTRIBUTORS}, %q{Gemfile}, %q{LICENSE}, %q{README.markdown}, %q{Rakefile}, %q{TODO}, %q{bin/pry}, %q{examples/example_basic.rb}, %q{examples/example_command_override.rb}, %q{examples/example_commands.rb}, %q{examples/example_hooks.rb}, %q{examples/example_image_edit.rb}, %q{examples/example_input.rb}, %q{examples/example_input2.rb}, %q{examples/example_output.rb}, %q{examples/example_print.rb}, %q{examples/example_prompt.rb}, %q{examples/helper.rb}, %q{lib/pry.rb}, %q{lib/pry/command_context.rb}, %q{lib/pry/command_processor.rb}, %q{lib/pry/command_set.rb}, %q{lib/pry/commands.rb}, %q{lib/pry/completion.rb}, %q{lib/pry/config.rb}, %q{lib/pry/core_extensions.rb}, %q{lib/pry/custom_completions.rb}, %q{lib/pry/default_commands/basic.rb}, %q{lib/pry/default_commands/context.rb}, %q{lib/pry/default_commands/documentation.rb}, %q{lib/pry/default_commands/easter_eggs.rb}, %q{lib/pry/default_commands/gems.rb}, %q{lib/pry/default_commands/input.rb}, %q{lib/pry/default_commands/introspection.rb}, %q{lib/pry/default_commands/ls.rb}, %q{lib/pry/default_commands/shell.rb}, %q{lib/pry/extended_commands/experimental.rb}, %q{lib/pry/extended_commands/user_command_api.rb}, %q{lib/pry/helpers.rb}, %q{lib/pry/helpers/base_helpers.rb}, %q{lib/pry/helpers/command_helpers.rb}, %q{lib/pry/helpers/text.rb}, %q{lib/pry/history.rb}, %q{lib/pry/history_array.rb}, %q{lib/pry/plugins.rb}, %q{lib/pry/pry_class.rb}, %q{lib/pry/pry_instance.rb}, %q{lib/pry/version.rb}, %q{pry.gemspec}, %q{test/helper.rb}, %q{test/test_command_helpers.rb}, %q{test/test_command_processor.rb}, %q{test/test_command_set.rb}, %q{test/test_completion.rb}, %q{test/test_default_commands.rb}, %q{test/test_default_commands/test_context.rb}, %q{test/test_default_commands/test_documentation.rb}, %q{test/test_default_commands/test_gems.rb}, %q{test/test_default_commands/test_input.rb}, %q{test/test_default_commands/test_introspection.rb}, %q{test/test_default_commands/test_shell.rb}, %q{test/test_exception_whitelist.rb}, %q{test/test_history_array.rb}, %q{test/test_input_stack.rb}, %q{test/test_pry.rb}, %q{test/test_pry_history.rb}, %q{test/test_pry_output.rb}, %q{test/test_special_locals.rb}, %q{test/testrc}, %q{wiki/Customizing-pry.md}, %q{wiki/Home.md}]
|
14
14
|
s.homepage = %q{http://pry.github.com}
|
15
15
|
s.require_paths = [%q{lib}]
|
16
16
|
s.rubygems_version = %q{1.8.6}
|
17
17
|
s.summary = %q{An IRB alternative and runtime developer console}
|
18
|
-
s.test_files = [%q{test/helper.rb}, %q{test/test_command_helpers.rb}, %q{test/test_command_processor.rb}, %q{test/test_command_set.rb}, %q{test/test_completion.rb}, %q{test/test_default_commands.rb}, %q{test/test_default_commands/test_context.rb}, %q{test/test_default_commands/test_documentation.rb}, %q{test/test_default_commands/test_gems.rb}, %q{test/test_default_commands/test_input.rb}, %q{test/test_default_commands/test_introspection.rb}, %q{test/test_default_commands/test_shell.rb}, %q{test/test_exception_whitelist.rb}, %q{test/test_history_array.rb}, %q{test/test_input_stack.rb}, %q{test/
|
18
|
+
s.test_files = [%q{test/helper.rb}, %q{test/test_command_helpers.rb}, %q{test/test_command_processor.rb}, %q{test/test_command_set.rb}, %q{test/test_completion.rb}, %q{test/test_default_commands.rb}, %q{test/test_default_commands/test_context.rb}, %q{test/test_default_commands/test_documentation.rb}, %q{test/test_default_commands/test_gems.rb}, %q{test/test_default_commands/test_input.rb}, %q{test/test_default_commands/test_introspection.rb}, %q{test/test_default_commands/test_shell.rb}, %q{test/test_exception_whitelist.rb}, %q{test/test_history_array.rb}, %q{test/test_input_stack.rb}, %q{test/test_pry.rb}, %q{test/test_pry_history.rb}, %q{test/test_pry_output.rb}, %q{test/test_special_locals.rb}, %q{test/testrc}]
|
19
19
|
|
20
20
|
if s.respond_to? :specification_version then
|
21
21
|
s.specification_version = 3
|
22
22
|
|
23
23
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
24
|
-
s.add_runtime_dependency(%q<ruby_parser>, ["
|
25
|
-
s.add_runtime_dependency(%q<coderay>, ["
|
24
|
+
s.add_runtime_dependency(%q<ruby_parser>, ["~> 2.0.5"])
|
25
|
+
s.add_runtime_dependency(%q<coderay>, ["~> 0.9.8"])
|
26
26
|
s.add_runtime_dependency(%q<slop>, ["~> 2.1.0"])
|
27
|
-
s.add_runtime_dependency(%q<method_source>, ["
|
28
|
-
s.add_development_dependency(%q<bacon>, ["
|
27
|
+
s.add_runtime_dependency(%q<method_source>, ["~> 0.6.5"])
|
28
|
+
s.add_development_dependency(%q<bacon>, ["~> 1.1.0"])
|
29
29
|
s.add_development_dependency(%q<open4>, ["~> 1.0.1"])
|
30
30
|
s.add_development_dependency(%q<rake>, ["~> 0.9"])
|
31
31
|
else
|
32
|
-
s.add_dependency(%q<ruby_parser>, ["
|
33
|
-
s.add_dependency(%q<coderay>, ["
|
32
|
+
s.add_dependency(%q<ruby_parser>, ["~> 2.0.5"])
|
33
|
+
s.add_dependency(%q<coderay>, ["~> 0.9.8"])
|
34
34
|
s.add_dependency(%q<slop>, ["~> 2.1.0"])
|
35
|
-
s.add_dependency(%q<method_source>, ["
|
36
|
-
s.add_dependency(%q<bacon>, ["
|
35
|
+
s.add_dependency(%q<method_source>, ["~> 0.6.5"])
|
36
|
+
s.add_dependency(%q<bacon>, ["~> 1.1.0"])
|
37
37
|
s.add_dependency(%q<open4>, ["~> 1.0.1"])
|
38
38
|
s.add_dependency(%q<rake>, ["~> 0.9"])
|
39
39
|
end
|
40
40
|
else
|
41
|
-
s.add_dependency(%q<ruby_parser>, ["
|
42
|
-
s.add_dependency(%q<coderay>, ["
|
41
|
+
s.add_dependency(%q<ruby_parser>, ["~> 2.0.5"])
|
42
|
+
s.add_dependency(%q<coderay>, ["~> 0.9.8"])
|
43
43
|
s.add_dependency(%q<slop>, ["~> 2.1.0"])
|
44
|
-
s.add_dependency(%q<method_source>, ["
|
45
|
-
s.add_dependency(%q<bacon>, ["
|
44
|
+
s.add_dependency(%q<method_source>, ["~> 0.6.5"])
|
45
|
+
s.add_dependency(%q<bacon>, ["~> 1.1.0"])
|
46
46
|
s.add_dependency(%q<open4>, ["~> 1.0.1"])
|
47
47
|
s.add_dependency(%q<rake>, ["~> 0.9"])
|
48
48
|
end
|
@@ -5,5 +5,73 @@ describe Pry::Helpers::CommandHelpers do
|
|
5
5
|
@helper = Pry::Helpers::CommandHelpers
|
6
6
|
end
|
7
7
|
|
8
|
-
|
8
|
+
describe "get_method_object" do
|
9
|
+
it 'should look up instance methods if no methods available and no options provided' do
|
10
|
+
klass = Class.new { def hello; end }
|
11
|
+
meth = @helper.get_method_object(:hello, Pry.binding_for(klass), {})
|
12
|
+
meth.should == klass.instance_method(:hello)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should look up methods if no instance methods available and no options provided' do
|
16
|
+
klass = Class.new { def self.hello; end }
|
17
|
+
meth = @helper.get_method_object(:hello, Pry.binding_for(klass), {})
|
18
|
+
meth.should == klass.method(:hello)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should look up instance methods first even if methods available and no options provided' do
|
22
|
+
klass = Class.new { def hello; end; def self.hello; end }
|
23
|
+
meth = @helper.get_method_object(:hello, Pry.binding_for(klass), {})
|
24
|
+
meth.should == klass.instance_method(:hello)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should look up instance methods if "instance-methods" option provided' do
|
28
|
+
klass = Class.new { def hello; end; def self.hello; end }
|
29
|
+
meth = @helper.get_method_object(:hello, Pry.binding_for(klass), {"instance-methods" => true})
|
30
|
+
meth.should == klass.instance_method(:hello)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should look up methods if :methods option provided' do
|
34
|
+
klass = Class.new { def hello; end; def self.hello; end }
|
35
|
+
meth = @helper.get_method_object(:hello, Pry.binding_for(klass), {:methods => true})
|
36
|
+
meth.should == klass.method(:hello)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should look up instance methods using the Class#method syntax' do
|
40
|
+
klass = Class.new { def hello; end; def self.hello; end }
|
41
|
+
meth = @helper.get_method_object("klass#hello", Pry.binding_for(binding), {})
|
42
|
+
meth.should == klass.instance_method(:hello)
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should look up methods using the object.method syntax' do
|
46
|
+
klass = Class.new { def hello; end; def self.hello; end }
|
47
|
+
meth = @helper.get_method_object("klass.hello", Pry.binding_for(binding), {})
|
48
|
+
meth.should == klass.method(:hello)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should NOT look up instance methods using the Class#method syntax if no instance methods defined' do
|
52
|
+
klass = Class.new { def self.hello; end }
|
53
|
+
meth = @helper.get_method_object("klass#hello", Pry.binding_for(binding), {})
|
54
|
+
meth.should == nil
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should NOT look up methods using the object.method syntax if no methods defined' do
|
58
|
+
klass = Class.new { def hello; end }
|
59
|
+
meth = @helper.get_method_object("klass.hello", Pry.binding_for(binding), {})
|
60
|
+
meth.should == nil
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should look up methods using klass.new.method syntax' do
|
64
|
+
klass = Class.new { def hello; :hello; end }
|
65
|
+
meth = @helper.get_method_object("klass.new.hello", Pry.binding_for(binding), {})
|
66
|
+
meth.name.to_sym.should == :hello
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should look up instance methods using klass.meth#method syntax' do
|
70
|
+
klass = Class.new { def self.meth; Class.new; end }
|
71
|
+
meth = @helper.get_method_object("klass.meth#initialize", Pry.binding_for(binding), {})
|
72
|
+
meth.name.to_sym.should == :initialize
|
73
|
+
end
|
74
|
+
end
|
9
75
|
end
|
76
|
+
|
77
|
+
|