pry 0.9.6.2-i386-mingw32 → 0.9.7-i386-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/CHANGELOG +19 -1
- data/CONTRIBUTORS +22 -16
- data/Rakefile +12 -6
- data/bin/pry +15 -12
- data/lib/pry.rb +39 -28
- data/lib/pry/command_context.rb +1 -0
- data/lib/pry/command_processor.rb +9 -2
- data/lib/pry/command_set.rb +7 -0
- data/lib/pry/config.rb +8 -0
- data/lib/pry/default_commands/basic.rb +7 -10
- data/lib/pry/default_commands/context.rb +36 -26
- data/lib/pry/default_commands/documentation.rb +31 -123
- data/lib/pry/default_commands/gems.rb +9 -4
- data/lib/pry/default_commands/input.rb +21 -11
- data/lib/pry/default_commands/introspection.rb +79 -88
- data/lib/pry/default_commands/ls.rb +165 -176
- data/lib/pry/default_commands/shell.rb +8 -8
- data/lib/pry/extended_commands/experimental.rb +1 -5
- data/lib/pry/extended_commands/user_command_api.rb +17 -5
- data/lib/pry/helpers.rb +1 -0
- data/lib/pry/helpers/base_helpers.rb +5 -1
- data/lib/pry/helpers/command_helpers.rb +22 -241
- data/lib/pry/helpers/options_helpers.rb +58 -0
- data/lib/pry/helpers/text.rb +10 -4
- data/lib/pry/history.rb +1 -1
- data/lib/pry/indent.rb +205 -0
- data/lib/pry/method.rb +412 -0
- data/lib/pry/pry_class.rb +56 -15
- data/lib/pry/pry_instance.rb +63 -16
- data/lib/pry/rbx_method.rb +20 -0
- data/lib/pry/rbx_path.rb +34 -0
- data/lib/pry/version.rb +1 -1
- data/pry.gemspec +16 -16
- data/test/helper.rb +8 -4
- data/test/test_command_helpers.rb +1 -69
- data/test/test_command_set.rb +29 -28
- data/test/test_default_commands/test_documentation.rb +23 -10
- data/test/test_default_commands/test_introspection.rb +58 -13
- data/test/test_default_commands/test_ls.rb +148 -0
- data/test/test_indent.rb +234 -0
- data/test/test_input_stack.rb +13 -0
- data/test/test_method.rb +291 -0
- data/test/test_pry.rb +10 -1
- metadata +88 -71
data/lib/pry/pry_class.rb
CHANGED
@@ -2,7 +2,6 @@ require 'ostruct'
|
|
2
2
|
require 'forwardable'
|
3
3
|
require 'pry/config'
|
4
4
|
|
5
|
-
# @author John Mair (banisterfiend)
|
6
5
|
class Pry
|
7
6
|
|
8
7
|
# The RC Files to load.
|
@@ -55,11 +54,10 @@ class Pry
|
|
55
54
|
end
|
56
55
|
|
57
56
|
# Load the rc files given in the `Pry::RC_FILES` array.
|
58
|
-
#
|
59
|
-
# be used to reload the files if they have changed.
|
57
|
+
# This method can also be used to reload the files if they have changed.
|
60
58
|
def self.load_rc
|
61
|
-
RC_FILES.
|
62
|
-
|
59
|
+
files = RC_FILES.collect { |file_name| File.expand_path(file_name) }.uniq
|
60
|
+
files.each do |file_name|
|
63
61
|
load(file_name) if File.exists?(file_name)
|
64
62
|
end
|
65
63
|
end
|
@@ -185,13 +183,14 @@ class Pry
|
|
185
183
|
config.exception_whitelist = DEFAULT_EXCEPTION_WHITELIST
|
186
184
|
config.hooks = DEFAULT_HOOKS
|
187
185
|
config.input_stack = []
|
188
|
-
config.color =
|
186
|
+
config.color = Pry::Helpers::BaseHelpers.use_ansi_codes?
|
189
187
|
config.pager = true
|
190
188
|
config.system = DEFAULT_SYSTEM
|
191
189
|
config.editor = default_editor_for_platform
|
192
190
|
config.should_load_rc = true
|
193
191
|
config.disable_auto_reload = false
|
194
192
|
config.command_prefix = ""
|
193
|
+
config.auto_indent = true
|
195
194
|
|
196
195
|
config.plugins ||= OpenStruct.new
|
197
196
|
config.plugins.enabled = true
|
@@ -208,16 +207,38 @@ class Pry
|
|
208
207
|
|
209
208
|
config.memory_size = 100
|
210
209
|
|
211
|
-
|
212
|
-
|
213
|
-
Pry.config.ls.instance_var_color = :bright_blue
|
214
|
-
Pry.config.ls.class_var_color = :blue
|
215
|
-
Pry.config.ls.global_var_color = :bright_magenta
|
216
|
-
Pry.config.ls.method_color = :green
|
217
|
-
Pry.config.ls.instance_method_color = :bright_green
|
218
|
-
Pry.config.ls.constant_color = :yellow
|
210
|
+
config.ls ||= OpenStruct.new({
|
211
|
+
:heading_color => :default,
|
219
212
|
|
220
|
-
|
213
|
+
:public_method_color => :default,
|
214
|
+
:private_method_color => :green,
|
215
|
+
:protected_method_color => :yellow,
|
216
|
+
:method_missing_color => :bright_red,
|
217
|
+
|
218
|
+
:local_var_color => :default,
|
219
|
+
:pry_var_color => :red, # e.g. _, _pry_, _file_
|
220
|
+
|
221
|
+
:instance_var_color => :blue, # e.g. @foo
|
222
|
+
:class_var_color => :bright_blue, # e.g. @@foo
|
223
|
+
|
224
|
+
:global_var_color => :default, # e.g. $CODERAY_DEBUG, $eventmachine_library
|
225
|
+
:builtin_global_color => :cyan, # e.g. $stdin, $-w, $PID
|
226
|
+
:pseudo_global_color => :cyan, # e.g. $~, $1..$9, $LAST_MATCH_INFO
|
227
|
+
|
228
|
+
:constant_color => :default, # e.g. VERSION, ARGF
|
229
|
+
:class_constant_color => :blue, # e.g. Object, Kernel
|
230
|
+
:exception_constant_color => :magenta, # e.g. Exception, RuntimeError
|
231
|
+
|
232
|
+
# What should separate items listed by ls? (TODO: we should allow a columnar layout)
|
233
|
+
:separator => " ",
|
234
|
+
|
235
|
+
# Any methods defined on these classes, or modules included into these classes, will not
|
236
|
+
# be shown by ls unless the -v flag is used.
|
237
|
+
# A user of Rails may wih to add ActiveRecord::Base to the list.
|
238
|
+
# add the following to your .pryrc:
|
239
|
+
# Pry.config.ls.ceiling << ActiveRecord::Base if defined? ActiveRecordBase
|
240
|
+
:ceiling => [Object, Module, Class]
|
241
|
+
})
|
221
242
|
end
|
222
243
|
|
223
244
|
# Set all the configurable options back to their default values
|
@@ -232,6 +253,26 @@ class Pry
|
|
232
253
|
self.line_buffer = [""]
|
233
254
|
self.eval_path = "(pry)"
|
234
255
|
self.active_sessions = 0
|
256
|
+
|
257
|
+
fix_coderay_colors
|
258
|
+
end
|
259
|
+
|
260
|
+
# To avoid mass-confusion, we change the default colour of "white" to
|
261
|
+
# "blue" enabling global legibility
|
262
|
+
def self.fix_coderay_colors
|
263
|
+
to_fix = if (CodeRay::Encoders::Terminal::TOKEN_COLORS rescue nil)
|
264
|
+
# CodeRay 1.0.0
|
265
|
+
CodeRay::Encoders::Terminal::TOKEN_COLORS
|
266
|
+
else
|
267
|
+
# CodeRay 0.9
|
268
|
+
begin
|
269
|
+
require 'coderay/encoders/term'
|
270
|
+
CodeRay::Encoders::Term::TOKEN_COLORS
|
271
|
+
rescue => e
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
to_fix[:comment] = "0;34" if to_fix
|
235
276
|
end
|
236
277
|
|
237
278
|
# Basic initialization.
|
data/lib/pry/pry_instance.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "pry/command_processor.rb"
|
2
|
+
require "pry/indent"
|
2
3
|
|
3
4
|
class Pry
|
4
5
|
|
@@ -22,7 +23,6 @@ class Pry
|
|
22
23
|
attr_reader :input_array
|
23
24
|
attr_reader :output_array
|
24
25
|
|
25
|
-
|
26
26
|
# Create a new `Pry` object.
|
27
27
|
# @param [Hash] options The optional configuration parameters.
|
28
28
|
# @option options [#readline] :input The object to use for input.
|
@@ -37,6 +37,7 @@ class Pry
|
|
37
37
|
|
38
38
|
@command_processor = CommandProcessor.new(self)
|
39
39
|
@binding_stack = []
|
40
|
+
@indent = Pry::Indent.new
|
40
41
|
end
|
41
42
|
|
42
43
|
# Refresh the Pry instance settings from the Pry class.
|
@@ -128,13 +129,21 @@ class Pry
|
|
128
129
|
private :initialize_special_locals
|
129
130
|
|
130
131
|
def inject_special_locals(target)
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
132
|
+
special_locals.each_pair do |name, value|
|
133
|
+
inject_local(name, value, target)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
def special_locals
|
138
|
+
{
|
139
|
+
:_in_ => @input_array,
|
140
|
+
:_out_ => @output_array,
|
141
|
+
:_pry_ => self,
|
142
|
+
:_ex_ => last_exception,
|
143
|
+
:_file_ => last_file,
|
144
|
+
:_dir_ => last_dir,
|
145
|
+
:_ => last_result
|
146
|
+
}
|
138
147
|
end
|
139
148
|
|
140
149
|
# Initialize the repl session.
|
@@ -206,9 +215,9 @@ class Pry
|
|
206
215
|
def re(target=TOPLEVEL_BINDING)
|
207
216
|
target = Pry.binding_for(target)
|
208
217
|
|
209
|
-
if input
|
218
|
+
if input.respond_to?(:completion_proc=)
|
210
219
|
# Readline tab completion
|
211
|
-
|
220
|
+
input.completion_proc = Pry::InputCompleter.build_completion_proc target, instance_eval(&custom_completions)
|
212
221
|
end
|
213
222
|
|
214
223
|
# It's not actually redundant to inject them continually as we may have
|
@@ -219,6 +228,9 @@ class Pry
|
|
219
228
|
|
220
229
|
result = set_last_result(target.eval(code, Pry.eval_path, Pry.current_line), target)
|
221
230
|
result
|
231
|
+
rescue CommandError, Slop::InvalidOptionError => e
|
232
|
+
output.puts "Error: #{e.message}"
|
233
|
+
@suppress_output = true
|
222
234
|
rescue RescuableException => e
|
223
235
|
set_last_exception(e, target)
|
224
236
|
ensure
|
@@ -275,20 +287,46 @@ class Pry
|
|
275
287
|
end
|
276
288
|
|
277
289
|
# Read a line of input and check for ^d, also determine prompt to use.
|
278
|
-
# This method should not need to be invoked directly.
|
290
|
+
# This method should not need to be invoked directly. This method also
|
291
|
+
# automatically indents the input value using Pry::Indent if auto
|
292
|
+
# indenting is enabled.
|
293
|
+
#
|
279
294
|
# @param [String] eval_string The cumulative lines of input.
|
280
295
|
# @param [Binding] target The target of the session.
|
281
296
|
# @return [String] The line received.
|
282
297
|
def retrieve_line(eval_string, target)
|
298
|
+
@indent.reset if eval_string.empty?
|
299
|
+
|
283
300
|
current_prompt = select_prompt(eval_string.empty?, target.eval('self'))
|
284
|
-
|
301
|
+
indentation = Pry.config.auto_indent ? @indent.indent_level : ''
|
302
|
+
|
303
|
+
val = readline(current_prompt + indentation)
|
285
304
|
|
286
305
|
# exit session if we receive EOF character (^D)
|
287
306
|
if !val
|
288
307
|
output.puts ""
|
289
308
|
Pry.config.control_d_handler.call(eval_string, self)
|
309
|
+
|
310
|
+
@indent.reset if Pry.config.auto_indent
|
290
311
|
""
|
291
312
|
else
|
313
|
+
# Change the eval_string into the input encoding (Issue 284)
|
314
|
+
# TODO: This wouldn't be necessary if the eval_string was constructed from
|
315
|
+
# input strings only.
|
316
|
+
if eval_string.empty? && val.respond_to?(:encoding) && val.encoding != eval_string.encoding
|
317
|
+
eval_string.force_encoding(val.encoding)
|
318
|
+
end
|
319
|
+
|
320
|
+
if !@command_processor.valid_command?(val, target) && Pry.config.auto_indent && !input.is_a?(StringIO)
|
321
|
+
orig_val = "#{indentation}#{val}"
|
322
|
+
val = @indent.indent(val)
|
323
|
+
|
324
|
+
if orig_val != val && output.tty? && Pry::Helpers::BaseHelpers.use_ansi_codes?
|
325
|
+
output.print @indent.correct_indentation(current_prompt + val, orig_val.length - val.length)
|
326
|
+
end
|
327
|
+
end
|
328
|
+
|
329
|
+
Pry.history << val.dup unless input.is_a?(StringIO)
|
292
330
|
val
|
293
331
|
end
|
294
332
|
end
|
@@ -411,9 +449,7 @@ class Pry
|
|
411
449
|
def readline(current_prompt="> ")
|
412
450
|
handle_read_errors do
|
413
451
|
if input == Readline
|
414
|
-
|
415
|
-
Pry.history << line.dup if line
|
416
|
-
line
|
452
|
+
input.readline(current_prompt, false) # false since we'll add it manually
|
417
453
|
else
|
418
454
|
if input.method(:readline).arity == 1
|
419
455
|
input.readline(current_prompt)
|
@@ -494,6 +530,16 @@ class Pry
|
|
494
530
|
!!Ripper::SexpBuilder.new(code).parse
|
495
531
|
end
|
496
532
|
|
533
|
+
elsif RUBY_VERSION =~ /1.9/ && RUBY_ENGINE == 'jruby'
|
534
|
+
|
535
|
+
# JRuby doesn't have Ripper, so use its native parser for 1.9 mode.
|
536
|
+
def valid_expression?(code)
|
537
|
+
JRuby.parse(code)
|
538
|
+
true
|
539
|
+
rescue SyntaxError
|
540
|
+
false
|
541
|
+
end
|
542
|
+
|
497
543
|
else
|
498
544
|
require 'ruby_parser'
|
499
545
|
|
@@ -505,7 +551,8 @@ class Pry
|
|
505
551
|
# valid_expression?("class Hello") #=> false
|
506
552
|
# valid_expression?("class Hello; end") #=> true
|
507
553
|
def valid_expression?(code)
|
508
|
-
RubyParser
|
554
|
+
# NOTE: we're using .dup because RubyParser mutates the input
|
555
|
+
RubyParser.new.parse(code.dup)
|
509
556
|
true
|
510
557
|
rescue Racc::ParseError, SyntaxError
|
511
558
|
false
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class Pry
|
2
|
+
module RbxMethod
|
3
|
+
private
|
4
|
+
def core?
|
5
|
+
source_file and RbxPath.is_core_path?(source_file)
|
6
|
+
end
|
7
|
+
|
8
|
+
def core_code
|
9
|
+
MethodSource.source_helper(core_path_line)
|
10
|
+
end
|
11
|
+
|
12
|
+
def core_doc
|
13
|
+
MethodSource.comment_helper(core_path_line)
|
14
|
+
end
|
15
|
+
|
16
|
+
def core_path_line
|
17
|
+
[RbxPath.convert_path_to_full(source_file), source_line]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/pry/rbx_path.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
class Pry
|
2
|
+
module RbxPath
|
3
|
+
module_function
|
4
|
+
def is_core_path?(path)
|
5
|
+
path.start_with?("kernel")
|
6
|
+
end
|
7
|
+
|
8
|
+
def convert_path_to_full(path)
|
9
|
+
if rvm_ruby?(Rubinius::BIN_PATH)
|
10
|
+
rvm_convert_path_to_full(path)
|
11
|
+
else
|
12
|
+
std_convert_path_to_full(path)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def rvm_ruby?(path)
|
17
|
+
!!(path =~ /\.rvm/)
|
18
|
+
end
|
19
|
+
|
20
|
+
def rvm_convert_path_to_full(path)
|
21
|
+
ruby_name = File.dirname(Rubinius::BIN_PATH).split("/").last
|
22
|
+
source_path = File.join(File.dirname(File.dirname(File.dirname(Rubinius::BIN_PATH))), "src", ruby_name)
|
23
|
+
file_name = File.join(source_path, path)
|
24
|
+
raise "Cannot find rbx core source" if !File.exists?(file_name)
|
25
|
+
file_name
|
26
|
+
end
|
27
|
+
|
28
|
+
def std_convert_path_to_full(path)
|
29
|
+
file_name = File.join(Rubinius::BIN_PATH, "..", path)
|
30
|
+
raise "Cannot find rbx core source" if !File.exists?(file_name)
|
31
|
+
file_name
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/pry/version.rb
CHANGED
data/pry.gemspec
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
|
-
s.name =
|
5
|
-
s.version = "0.9.
|
4
|
+
s.name = "pry"
|
5
|
+
s.version = "0.9.7"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
-
s.authors = [
|
9
|
-
s.date =
|
10
|
-
s.description =
|
11
|
-
s.email =
|
12
|
-
s.executables = [
|
13
|
-
s.files = [
|
14
|
-
s.homepage =
|
15
|
-
s.require_paths = [
|
16
|
-
s.rubygems_version =
|
17
|
-
s.summary =
|
18
|
-
s.test_files = [
|
8
|
+
s.authors = ["John Mair (banisterfiend)"]
|
9
|
+
s.date = "2011-10-26"
|
10
|
+
s.description = "An IRB alternative and runtime developer console"
|
11
|
+
s.email = "jrmair@gmail.com"
|
12
|
+
s.executables = ["pry"]
|
13
|
+
s.files = [".document", ".gemtest", ".gitignore", ".travis.yml", ".yardopts", "CHANGELOG", "CONTRIBUTORS", "Gemfile", "LICENSE", "README.markdown", "Rakefile", "TODO", "bin/pry", "examples/example_basic.rb", "examples/example_command_override.rb", "examples/example_commands.rb", "examples/example_hooks.rb", "examples/example_image_edit.rb", "examples/example_input.rb", "examples/example_input2.rb", "examples/example_output.rb", "examples/example_print.rb", "examples/example_prompt.rb", "examples/helper.rb", "lib/pry.rb", "lib/pry/command_context.rb", "lib/pry/command_processor.rb", "lib/pry/command_set.rb", "lib/pry/commands.rb", "lib/pry/completion.rb", "lib/pry/config.rb", "lib/pry/core_extensions.rb", "lib/pry/custom_completions.rb", "lib/pry/default_commands/basic.rb", "lib/pry/default_commands/context.rb", "lib/pry/default_commands/documentation.rb", "lib/pry/default_commands/easter_eggs.rb", "lib/pry/default_commands/gems.rb", "lib/pry/default_commands/input.rb", "lib/pry/default_commands/introspection.rb", "lib/pry/default_commands/ls.rb", "lib/pry/default_commands/shell.rb", "lib/pry/extended_commands/experimental.rb", "lib/pry/extended_commands/user_command_api.rb", "lib/pry/helpers.rb", "lib/pry/helpers/base_helpers.rb", "lib/pry/helpers/command_helpers.rb", "lib/pry/helpers/options_helpers.rb", "lib/pry/helpers/text.rb", "lib/pry/history.rb", "lib/pry/history_array.rb", "lib/pry/indent.rb", "lib/pry/method.rb", "lib/pry/plugins.rb", "lib/pry/pry_class.rb", "lib/pry/pry_instance.rb", "lib/pry/rbx_method.rb", "lib/pry/rbx_path.rb", "lib/pry/version.rb", "pry.gemspec", "test/helper.rb", "test/test_command_helpers.rb", "test/test_command_processor.rb", "test/test_command_set.rb", "test/test_completion.rb", "test/test_default_commands.rb", "test/test_default_commands/test_context.rb", "test/test_default_commands/test_documentation.rb", "test/test_default_commands/test_gems.rb", "test/test_default_commands/test_input.rb", "test/test_default_commands/test_introspection.rb", "test/test_default_commands/test_ls.rb", "test/test_default_commands/test_shell.rb", "test/test_exception_whitelist.rb", "test/test_history_array.rb", "test/test_indent.rb", "test/test_input_stack.rb", "test/test_method.rb", "test/test_pry.rb", "test/test_pry_history.rb", "test/test_pry_output.rb", "test/test_special_locals.rb", "test/testrc", "wiki/Customizing-pry.md", "wiki/Home.md"]
|
14
|
+
s.homepage = "http://pry.github.com"
|
15
|
+
s.require_paths = ["lib"]
|
16
|
+
s.rubygems_version = "1.8.11"
|
17
|
+
s.summary = "An IRB alternative and runtime developer console"
|
18
|
+
s.test_files = ["test/helper.rb", "test/test_command_helpers.rb", "test/test_command_processor.rb", "test/test_command_set.rb", "test/test_completion.rb", "test/test_default_commands.rb", "test/test_default_commands/test_context.rb", "test/test_default_commands/test_documentation.rb", "test/test_default_commands/test_gems.rb", "test/test_default_commands/test_input.rb", "test/test_default_commands/test_introspection.rb", "test/test_default_commands/test_ls.rb", "test/test_default_commands/test_shell.rb", "test/test_exception_whitelist.rb", "test/test_history_array.rb", "test/test_indent.rb", "test/test_input_stack.rb", "test/test_method.rb", "test/test_pry.rb", "test/test_pry_history.rb", "test/test_pry_output.rb", "test/test_special_locals.rb", "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>, ["~> 2.
|
24
|
+
s.add_runtime_dependency(%q<ruby_parser>, ["~> 2.3.1"])
|
25
25
|
s.add_runtime_dependency(%q<coderay>, ["~> 0.9.8"])
|
26
26
|
s.add_runtime_dependency(%q<slop>, ["~> 2.1.0"])
|
27
27
|
s.add_runtime_dependency(%q<method_source>, ["~> 0.6.5"])
|
@@ -29,7 +29,7 @@ Gem::Specification.new do |s|
|
|
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>, ["~> 2.
|
32
|
+
s.add_dependency(%q<ruby_parser>, ["~> 2.3.1"])
|
33
33
|
s.add_dependency(%q<coderay>, ["~> 0.9.8"])
|
34
34
|
s.add_dependency(%q<slop>, ["~> 2.1.0"])
|
35
35
|
s.add_dependency(%q<method_source>, ["~> 0.6.5"])
|
@@ -38,7 +38,7 @@ Gem::Specification.new do |s|
|
|
38
38
|
s.add_dependency(%q<rake>, ["~> 0.9"])
|
39
39
|
end
|
40
40
|
else
|
41
|
-
s.add_dependency(%q<ruby_parser>, ["~> 2.
|
41
|
+
s.add_dependency(%q<ruby_parser>, ["~> 2.3.1"])
|
42
42
|
s.add_dependency(%q<coderay>, ["~> 0.9.8"])
|
43
43
|
s.add_dependency(%q<slop>, ["~> 2.1.0"])
|
44
44
|
s.add_dependency(%q<method_source>, ["~> 0.6.5"])
|
data/test/helper.rb
CHANGED
@@ -3,7 +3,7 @@ unless Object.const_defined? 'Pry'
|
|
3
3
|
require 'pry'
|
4
4
|
end
|
5
5
|
|
6
|
-
puts "Ruby v#{RUBY_VERSION} (#{defined?(RUBY_ENGINE) ? RUBY_ENGINE : "ruby"}), Pry v#{Pry::VERSION}, method_source v#{MethodSource::VERSION}"
|
6
|
+
puts "Ruby v#{RUBY_VERSION} (#{defined?(RUBY_ENGINE) ? RUBY_ENGINE : "ruby"}), Pry v#{Pry::VERSION}, method_source v#{MethodSource::VERSION}, CodeRay v#{CodeRay::VERSION}"
|
7
7
|
|
8
8
|
require 'bacon'
|
9
9
|
require 'open4'
|
@@ -20,10 +20,11 @@ class << Pry
|
|
20
20
|
|
21
21
|
Pry.color = false
|
22
22
|
Pry.pager = false
|
23
|
-
Pry.config.should_load_rc
|
24
|
-
Pry.config.plugins.enabled
|
23
|
+
Pry.config.should_load_rc = false
|
24
|
+
Pry.config.plugins.enabled = false
|
25
25
|
Pry.config.history.should_load = false
|
26
26
|
Pry.config.history.should_save = false
|
27
|
+
Pry.config.auto_indent = false
|
27
28
|
Pry.config.hooks = { }
|
28
29
|
end
|
29
30
|
end
|
@@ -93,11 +94,14 @@ def redirect_pry_io(new_in, new_out = StringIO.new)
|
|
93
94
|
end
|
94
95
|
|
95
96
|
def mock_pry(*args)
|
97
|
+
|
98
|
+
binding = args.first.is_a?(Binding) ? args.shift : binding()
|
99
|
+
|
96
100
|
input = InputTester.new(*args)
|
97
101
|
output = StringIO.new
|
98
102
|
|
99
103
|
redirect_pry_io(input, output) do
|
100
|
-
|
104
|
+
binding.pry
|
101
105
|
end
|
102
106
|
|
103
107
|
output.string
|
@@ -5,73 +5,5 @@ describe Pry::Helpers::CommandHelpers do
|
|
5
5
|
@helper = Pry::Helpers::CommandHelpers
|
6
6
|
end
|
7
7
|
|
8
|
-
|
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
|
8
|
+
# FIXME: currently no tests
|
75
9
|
end
|
76
|
-
|
77
|
-
|