pry 0.10.pre.1-java → 0.10.0.pre2-java
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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +702 -0
- data/LICENSE +2 -2
- data/{README.markdown → README.md} +41 -35
- data/lib/pry.rb +82 -139
- data/lib/pry/cli.rb +77 -30
- data/lib/pry/code.rb +126 -182
- data/lib/pry/code/code_file.rb +103 -0
- data/lib/pry/code/code_range.rb +71 -0
- data/lib/pry/code/loc.rb +92 -0
- data/lib/pry/code_object.rb +172 -0
- data/lib/pry/color_printer.rb +55 -0
- data/lib/pry/command.rb +184 -28
- data/lib/pry/command_set.rb +113 -59
- data/lib/pry/commands.rb +4 -27
- data/lib/pry/commands/amend_line.rb +99 -0
- data/lib/pry/commands/bang.rb +20 -0
- data/lib/pry/commands/bang_pry.rb +17 -0
- data/lib/pry/commands/cat.rb +62 -0
- data/lib/pry/commands/cat/abstract_formatter.rb +27 -0
- data/lib/pry/commands/cat/exception_formatter.rb +77 -0
- data/lib/pry/commands/cat/file_formatter.rb +67 -0
- data/lib/pry/commands/cat/input_expression_formatter.rb +43 -0
- data/lib/pry/commands/cd.rb +41 -0
- data/lib/pry/commands/change_inspector.rb +27 -0
- data/lib/pry/commands/change_prompt.rb +26 -0
- data/lib/pry/commands/code_collector.rb +165 -0
- data/lib/pry/commands/disable_pry.rb +27 -0
- data/lib/pry/commands/disabled_commands.rb +2 -0
- data/lib/pry/commands/easter_eggs.rb +112 -0
- data/lib/pry/commands/edit.rb +195 -0
- data/lib/pry/commands/edit/exception_patcher.rb +25 -0
- data/lib/pry/commands/edit/file_and_line_locator.rb +36 -0
- data/lib/pry/commands/exit.rb +42 -0
- data/lib/pry/commands/exit_all.rb +29 -0
- data/lib/pry/commands/exit_program.rb +23 -0
- data/lib/pry/commands/find_method.rb +193 -0
- data/lib/pry/commands/fix_indent.rb +19 -0
- data/lib/pry/commands/gem_cd.rb +26 -0
- data/lib/pry/commands/gem_install.rb +32 -0
- data/lib/pry/commands/gem_list.rb +33 -0
- data/lib/pry/commands/gem_open.rb +29 -0
- data/lib/pry/commands/gist.rb +101 -0
- data/lib/pry/commands/help.rb +164 -0
- data/lib/pry/commands/hist.rb +180 -0
- data/lib/pry/commands/import_set.rb +22 -0
- data/lib/pry/commands/install_command.rb +53 -0
- data/lib/pry/commands/jump_to.rb +29 -0
- data/lib/pry/commands/list_inspectors.rb +35 -0
- data/lib/pry/commands/list_prompts.rb +35 -0
- data/lib/pry/commands/ls.rb +114 -0
- data/lib/pry/commands/ls/constants.rb +47 -0
- data/lib/pry/commands/ls/formatter.rb +49 -0
- data/lib/pry/commands/ls/globals.rb +48 -0
- data/lib/pry/commands/ls/grep.rb +21 -0
- data/lib/pry/commands/ls/instance_vars.rb +39 -0
- data/lib/pry/commands/ls/interrogatable.rb +18 -0
- data/lib/pry/commands/ls/jruby_hacks.rb +49 -0
- data/lib/pry/commands/ls/local_names.rb +35 -0
- data/lib/pry/commands/ls/local_vars.rb +39 -0
- data/lib/pry/commands/ls/ls_entity.rb +70 -0
- data/lib/pry/commands/ls/methods.rb +57 -0
- data/lib/pry/commands/ls/methods_helper.rb +46 -0
- data/lib/pry/commands/ls/self_methods.rb +32 -0
- data/lib/pry/commands/nesting.rb +25 -0
- data/lib/pry/commands/play.rb +103 -0
- data/lib/pry/commands/pry_backtrace.rb +25 -0
- data/lib/pry/commands/pry_version.rb +17 -0
- data/lib/pry/commands/raise_up.rb +32 -0
- data/lib/pry/commands/reload_code.rb +62 -0
- data/lib/pry/commands/reset.rb +18 -0
- data/lib/pry/commands/ri.rb +60 -0
- data/lib/pry/commands/save_file.rb +61 -0
- data/lib/pry/commands/shell_command.rb +48 -0
- data/lib/pry/commands/shell_mode.rb +25 -0
- data/lib/pry/commands/show_doc.rb +83 -0
- data/lib/pry/commands/show_info.rb +195 -0
- data/lib/pry/commands/show_input.rb +17 -0
- data/lib/pry/commands/show_source.rb +50 -0
- data/lib/pry/commands/simple_prompt.rb +22 -0
- data/lib/pry/commands/stat.rb +40 -0
- data/lib/pry/commands/switch_to.rb +23 -0
- data/lib/pry/commands/toggle_color.rb +24 -0
- data/lib/pry/commands/watch_expression.rb +105 -0
- data/lib/pry/commands/watch_expression/expression.rb +38 -0
- data/lib/pry/commands/whereami.rb +190 -0
- data/lib/pry/commands/wtf.rb +57 -0
- data/lib/pry/config.rb +20 -229
- data/lib/pry/config/behavior.rb +139 -0
- data/lib/pry/config/convenience.rb +26 -0
- data/lib/pry/config/default.rb +165 -0
- data/lib/pry/core_extensions.rb +59 -38
- data/lib/pry/editor.rb +133 -0
- data/lib/pry/exceptions.rb +77 -0
- data/lib/pry/helpers.rb +1 -0
- data/lib/pry/helpers/base_helpers.rb +40 -154
- data/lib/pry/helpers/command_helpers.rb +19 -130
- data/lib/pry/helpers/documentation_helpers.rb +21 -11
- data/lib/pry/helpers/table.rb +109 -0
- data/lib/pry/helpers/text.rb +8 -9
- data/lib/pry/history.rb +61 -45
- data/lib/pry/history_array.rb +11 -1
- data/lib/pry/hooks.rb +10 -32
- data/lib/pry/indent.rb +110 -38
- data/lib/pry/input_completer.rb +242 -0
- data/lib/pry/input_lock.rb +132 -0
- data/lib/pry/inspector.rb +27 -0
- data/lib/pry/last_exception.rb +61 -0
- data/lib/pry/method.rb +199 -200
- data/lib/pry/method/disowned.rb +53 -0
- data/lib/pry/method/patcher.rb +125 -0
- data/lib/pry/method/weird_method_locator.rb +186 -0
- data/lib/pry/module_candidate.rb +39 -33
- data/lib/pry/object_path.rb +82 -0
- data/lib/pry/output.rb +50 -0
- data/lib/pry/pager.rb +234 -0
- data/lib/pry/plugins.rb +4 -3
- data/lib/pry/prompt.rb +26 -0
- data/lib/pry/pry_class.rb +199 -227
- data/lib/pry/pry_instance.rb +344 -403
- data/lib/pry/rbx_path.rb +1 -1
- data/lib/pry/repl.rb +202 -0
- data/lib/pry/repl_file_loader.rb +20 -26
- data/lib/pry/rubygem.rb +82 -0
- data/lib/pry/terminal.rb +79 -0
- data/lib/pry/test/helper.rb +170 -0
- data/lib/pry/version.rb +1 -1
- data/lib/pry/wrapped_module.rb +133 -48
- metadata +132 -197
- data/.document +0 -2
- data/.gemtest +0 -0
- data/.gitignore +0 -16
- data/.travis.yml +0 -17
- data/.yardopts +0 -1
- data/CHANGELOG +0 -387
- data/CONTRIBUTORS +0 -36
- data/Gemfile +0 -2
- data/Rakefile +0 -137
- data/TODO +0 -117
- data/examples/example_basic.rb +0 -15
- data/examples/example_command_override.rb +0 -32
- data/examples/example_commands.rb +0 -36
- data/examples/example_hooks.rb +0 -9
- data/examples/example_image_edit.rb +0 -67
- data/examples/example_input.rb +0 -7
- data/examples/example_input2.rb +0 -29
- data/examples/example_output.rb +0 -11
- data/examples/example_print.rb +0 -6
- data/examples/example_prompt.rb +0 -9
- data/examples/helper.rb +0 -6
- data/lib/pry/completion.rb +0 -221
- data/lib/pry/custom_completions.rb +0 -6
- data/lib/pry/default_commands/cd.rb +0 -81
- data/lib/pry/default_commands/commands.rb +0 -62
- data/lib/pry/default_commands/context.rb +0 -98
- data/lib/pry/default_commands/easter_eggs.rb +0 -95
- data/lib/pry/default_commands/editing.rb +0 -420
- data/lib/pry/default_commands/find_method.rb +0 -169
- data/lib/pry/default_commands/gems.rb +0 -84
- data/lib/pry/default_commands/gist.rb +0 -187
- data/lib/pry/default_commands/help.rb +0 -127
- data/lib/pry/default_commands/hist.rb +0 -120
- data/lib/pry/default_commands/input_and_output.rb +0 -306
- data/lib/pry/default_commands/introspection.rb +0 -410
- data/lib/pry/default_commands/ls.rb +0 -272
- data/lib/pry/default_commands/misc.rb +0 -38
- data/lib/pry/default_commands/navigating_pry.rb +0 -110
- data/lib/pry/default_commands/whereami.rb +0 -92
- data/lib/pry/extended_commands/experimental.rb +0 -7
- data/lib/pry/rbx_method.rb +0 -13
- data/man/pry.1 +0 -195
- data/man/pry.1.html +0 -204
- data/man/pry.1.ronn +0 -141
- data/pry.gemspec +0 -46
- data/test/candidate_helper1.rb +0 -11
- data/test/candidate_helper2.rb +0 -8
- data/test/helper.rb +0 -223
- data/test/test_cli.rb +0 -78
- data/test/test_code.rb +0 -201
- data/test/test_command.rb +0 -712
- data/test/test_command_helpers.rb +0 -9
- data/test/test_command_integration.rb +0 -668
- data/test/test_command_set.rb +0 -610
- data/test/test_completion.rb +0 -62
- data/test/test_control_d_handler.rb +0 -45
- data/test/test_default_commands/example.erb +0 -5
- data/test/test_default_commands/test_cd.rb +0 -318
- data/test/test_default_commands/test_context.rb +0 -280
- data/test/test_default_commands/test_documentation.rb +0 -314
- data/test/test_default_commands/test_find_method.rb +0 -50
- data/test/test_default_commands/test_gems.rb +0 -18
- data/test/test_default_commands/test_help.rb +0 -57
- data/test/test_default_commands/test_input.rb +0 -428
- data/test/test_default_commands/test_introspection.rb +0 -511
- data/test/test_default_commands/test_ls.rb +0 -151
- data/test/test_default_commands/test_shell.rb +0 -343
- data/test/test_default_commands/test_show_source.rb +0 -432
- data/test/test_exception_whitelist.rb +0 -21
- data/test/test_history_array.rb +0 -65
- data/test/test_hooks.rb +0 -521
- data/test/test_indent.rb +0 -277
- data/test/test_input_stack.rb +0 -86
- data/test/test_method.rb +0 -401
- data/test/test_pry.rb +0 -463
- data/test/test_pry_defaults.rb +0 -419
- data/test/test_pry_history.rb +0 -84
- data/test/test_pry_output.rb +0 -41
- data/test/test_sticky_locals.rb +0 -155
- data/test/test_syntax_checking.rb +0 -65
- data/test/test_wrapped_module.rb +0 -174
- data/test/testrc +0 -2
- data/test/testrcbad +0 -2
- data/wiki/Customizing-pry.md +0 -397
- data/wiki/Home.md +0 -4
data/pry.gemspec
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
Gem::Specification.new do |s|
|
4
|
-
s.name = "pry"
|
5
|
-
s.version = "0.10.pre.1"
|
6
|
-
|
7
|
-
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
8
|
-
s.authors = ["John Mair (banisterfiend)", "Conrad Irwin"]
|
9
|
-
s.date = "2012-07-05"
|
10
|
-
s.description = "An IRB alternative and runtime developer console"
|
11
|
-
s.email = ["jrmair@gmail.com", "conrad.irwin@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/cli.rb", "lib/pry/code.rb", "lib/pry/command.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/cd.rb", "lib/pry/default_commands/commands.rb", "lib/pry/default_commands/context.rb", "lib/pry/default_commands/easter_eggs.rb", "lib/pry/default_commands/editing.rb", "lib/pry/default_commands/find_method.rb", "lib/pry/default_commands/gems.rb", "lib/pry/default_commands/gist.rb", "lib/pry/default_commands/help.rb", "lib/pry/default_commands/hist.rb", "lib/pry/default_commands/input_and_output.rb", "lib/pry/default_commands/introspection.rb", "lib/pry/default_commands/ls.rb", "lib/pry/default_commands/misc.rb", "lib/pry/default_commands/navigating_pry.rb", "lib/pry/default_commands/whereami.rb", "lib/pry/extended_commands/experimental.rb", "lib/pry/helpers.rb", "lib/pry/helpers/base_helpers.rb", "lib/pry/helpers/command_helpers.rb", "lib/pry/helpers/documentation_helpers.rb", "lib/pry/helpers/options_helpers.rb", "lib/pry/helpers/text.rb", "lib/pry/history.rb", "lib/pry/history_array.rb", "lib/pry/hooks.rb", "lib/pry/indent.rb", "lib/pry/method.rb", "lib/pry/module_candidate.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/repl_file_loader.rb", "lib/pry/version.rb", "lib/pry/wrapped_module.rb", "man/pry.1", "man/pry.1.html", "man/pry.1.ronn", "pry.gemspec", "test/candidate_helper1.rb", "test/candidate_helper2.rb", "test/helper.rb", "test/test_cli.rb", "test/test_code.rb", "test/test_command.rb", "test/test_command_helpers.rb", "test/test_command_integration.rb", "test/test_command_set.rb", "test/test_completion.rb", "test/test_control_d_handler.rb", "test/test_default_commands/example.erb", "test/test_default_commands/test_cd.rb", "test/test_default_commands/test_context.rb", "test/test_default_commands/test_documentation.rb", "test/test_default_commands/test_find_method.rb", "test/test_default_commands/test_gems.rb", "test/test_default_commands/test_help.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_default_commands/test_show_source.rb", "test/test_exception_whitelist.rb", "test/test_history_array.rb", "test/test_hooks.rb", "test/test_indent.rb", "test/test_input_stack.rb", "test/test_method.rb", "test/test_pry.rb", "test/test_pry_defaults.rb", "test/test_pry_history.rb", "test/test_pry_output.rb", "test/test_sticky_locals.rb", "test/test_syntax_checking.rb", "test/test_wrapped_module.rb", "test/testrc", "test/testrcbad", "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.24"
|
17
|
-
s.summary = "An IRB alternative and runtime developer console"
|
18
|
-
s.test_files = ["test/candidate_helper1.rb", "test/candidate_helper2.rb", "test/helper.rb", "test/test_cli.rb", "test/test_code.rb", "test/test_command.rb", "test/test_command_helpers.rb", "test/test_command_integration.rb", "test/test_command_set.rb", "test/test_completion.rb", "test/test_control_d_handler.rb", "test/test_default_commands/example.erb", "test/test_default_commands/test_cd.rb", "test/test_default_commands/test_context.rb", "test/test_default_commands/test_documentation.rb", "test/test_default_commands/test_find_method.rb", "test/test_default_commands/test_gems.rb", "test/test_default_commands/test_help.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_default_commands/test_show_source.rb", "test/test_exception_whitelist.rb", "test/test_history_array.rb", "test/test_hooks.rb", "test/test_indent.rb", "test/test_input_stack.rb", "test/test_method.rb", "test/test_pry.rb", "test/test_pry_defaults.rb", "test/test_pry_history.rb", "test/test_pry_output.rb", "test/test_sticky_locals.rb", "test/test_syntax_checking.rb", "test/test_wrapped_module.rb", "test/testrc", "test/testrcbad"]
|
19
|
-
|
20
|
-
if s.respond_to? :specification_version then
|
21
|
-
s.specification_version = 3
|
22
|
-
|
23
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
24
|
-
s.add_runtime_dependency(%q<coderay>, ["~> 1.0.5"])
|
25
|
-
s.add_runtime_dependency(%q<slop>, ["~> 3.3.1"])
|
26
|
-
s.add_runtime_dependency(%q<method_source>, ["~> 0.8"])
|
27
|
-
s.add_development_dependency(%q<bacon>, ["~> 1.1"])
|
28
|
-
s.add_development_dependency(%q<open4>, ["~> 1.3"])
|
29
|
-
s.add_development_dependency(%q<rake>, ["~> 0.9"])
|
30
|
-
else
|
31
|
-
s.add_dependency(%q<coderay>, ["~> 1.0.5"])
|
32
|
-
s.add_dependency(%q<slop>, ["~> 3.3.1"])
|
33
|
-
s.add_dependency(%q<method_source>, ["~> 0.8"])
|
34
|
-
s.add_dependency(%q<bacon>, ["~> 1.1"])
|
35
|
-
s.add_dependency(%q<open4>, ["~> 1.3"])
|
36
|
-
s.add_dependency(%q<rake>, ["~> 0.9"])
|
37
|
-
end
|
38
|
-
else
|
39
|
-
s.add_dependency(%q<coderay>, ["~> 1.0.5"])
|
40
|
-
s.add_dependency(%q<slop>, ["~> 3.3.1"])
|
41
|
-
s.add_dependency(%q<method_source>, ["~> 0.8"])
|
42
|
-
s.add_dependency(%q<bacon>, ["~> 1.1"])
|
43
|
-
s.add_dependency(%q<open4>, ["~> 1.3"])
|
44
|
-
s.add_dependency(%q<rake>, ["~> 0.9"])
|
45
|
-
end
|
46
|
-
end
|
data/test/candidate_helper1.rb
DELETED
data/test/candidate_helper2.rb
DELETED
data/test/helper.rb
DELETED
@@ -1,223 +0,0 @@
|
|
1
|
-
unless Object.const_defined? 'Pry'
|
2
|
-
$:.unshift File.expand_path '../../lib', __FILE__
|
3
|
-
require 'pry'
|
4
|
-
end
|
5
|
-
|
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}, Slop v#{Slop::VERSION}"
|
7
|
-
|
8
|
-
require 'bacon'
|
9
|
-
require 'open4'
|
10
|
-
|
11
|
-
# A global space for storing temporary state during tests.
|
12
|
-
Pad = OpenStruct.new
|
13
|
-
def Pad.clear
|
14
|
-
@table = {}
|
15
|
-
end
|
16
|
-
|
17
|
-
# turn warnings off (esp for Pry::Hooks which will generate warnings
|
18
|
-
# in tests)
|
19
|
-
$VERBOSE = nil
|
20
|
-
|
21
|
-
# Ensure we do not execute any rc files
|
22
|
-
Pry::RC_FILES.clear
|
23
|
-
|
24
|
-
# inject a variable into a binding
|
25
|
-
def inject_var(name, value, b)
|
26
|
-
Thread.current[:__pry_local__] = value
|
27
|
-
b.eval("#{name} = Thread.current[:__pry_local__]")
|
28
|
-
ensure
|
29
|
-
Thread.current[:__pry_local__] = nil
|
30
|
-
end
|
31
|
-
|
32
|
-
def constant_scope(*names)
|
33
|
-
names.each do |name|
|
34
|
-
Object.remove_const name if Object.const_defined?(name)
|
35
|
-
end
|
36
|
-
|
37
|
-
yield
|
38
|
-
ensure
|
39
|
-
names.each do |name|
|
40
|
-
Object.remove_const name if Object.const_defined?(name)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def mri18_and_no_real_source_location?
|
45
|
-
Pry::Helpers::BaseHelpers.mri_18? && !(Method.instance_method(:source_location).owner == Method)
|
46
|
-
end
|
47
|
-
|
48
|
-
# used by test_show_source.rb and test_documentation.rb
|
49
|
-
class TestClassForShowSource
|
50
|
-
def alpha
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
class TestClassForShowSourceClassEval
|
55
|
-
def alpha
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
class TestClassForShowSourceInstanceEval
|
60
|
-
def alpha
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
# in case the tests call reset_defaults, ensure we reset them to
|
65
|
-
# amended (test friendly) values
|
66
|
-
class << Pry
|
67
|
-
alias_method :orig_reset_defaults, :reset_defaults
|
68
|
-
def reset_defaults
|
69
|
-
orig_reset_defaults
|
70
|
-
|
71
|
-
Pry.color = false
|
72
|
-
Pry.pager = false
|
73
|
-
Pry.config.should_load_rc = false
|
74
|
-
Pry.config.should_load_local_rc= false
|
75
|
-
Pry.config.should_load_plugins = false
|
76
|
-
Pry.config.history.should_load = false
|
77
|
-
Pry.config.history.should_save = false
|
78
|
-
Pry.config.auto_indent = false
|
79
|
-
Pry.config.hooks = Pry::Hooks.new
|
80
|
-
Pry.config.collision_warning = false
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def mock_exception(*mock_backtrace)
|
85
|
-
e = StandardError.new("mock exception")
|
86
|
-
(class << e; self; end).class_eval do
|
87
|
-
define_method(:backtrace) { mock_backtrace }
|
88
|
-
end
|
89
|
-
e
|
90
|
-
end
|
91
|
-
|
92
|
-
Pry.reset_defaults
|
93
|
-
|
94
|
-
# this is to test exception code (cat --ex)
|
95
|
-
def broken_method
|
96
|
-
this method is broken
|
97
|
-
end
|
98
|
-
|
99
|
-
# sample doc
|
100
|
-
def sample_method
|
101
|
-
:sample
|
102
|
-
end
|
103
|
-
|
104
|
-
# another sample doc
|
105
|
-
def another_sample_method
|
106
|
-
:another_sample
|
107
|
-
end
|
108
|
-
|
109
|
-
# Set I/O streams.
|
110
|
-
#
|
111
|
-
# Out defaults to an anonymous StringIO.
|
112
|
-
#
|
113
|
-
def redirect_pry_io(new_in, new_out = StringIO.new)
|
114
|
-
old_in = Pry.input
|
115
|
-
old_out = Pry.output
|
116
|
-
|
117
|
-
Pry.input = new_in
|
118
|
-
Pry.output = new_out
|
119
|
-
begin
|
120
|
-
yield
|
121
|
-
ensure
|
122
|
-
Pry.input = old_in
|
123
|
-
Pry.output = old_out
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
def mock_pry(*args)
|
128
|
-
|
129
|
-
binding = args.first.is_a?(Binding) ? args.shift : binding()
|
130
|
-
|
131
|
-
input = InputTester.new(*args)
|
132
|
-
output = StringIO.new
|
133
|
-
|
134
|
-
redirect_pry_io(input, output) do
|
135
|
-
binding.pry
|
136
|
-
end
|
137
|
-
|
138
|
-
output.string
|
139
|
-
end
|
140
|
-
|
141
|
-
def mock_command(cmd, args=[], opts={})
|
142
|
-
output = StringIO.new
|
143
|
-
ret = cmd.new(opts.merge(:output => output)).call_safely(*args)
|
144
|
-
Struct.new(:output, :return).new(output.string, ret)
|
145
|
-
end
|
146
|
-
|
147
|
-
def redirect_global_pry_input(new_io)
|
148
|
-
old_io = Pry.input
|
149
|
-
Pry.input = new_io
|
150
|
-
begin
|
151
|
-
yield
|
152
|
-
ensure
|
153
|
-
Pry.input = old_io
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
def redirect_global_pry_output(new_io)
|
158
|
-
old_io = Pry.output
|
159
|
-
Pry.output = new_io
|
160
|
-
begin
|
161
|
-
yield
|
162
|
-
ensure
|
163
|
-
Pry.output = old_io
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
class Module
|
168
|
-
public :remove_const
|
169
|
-
public :remove_method
|
170
|
-
end
|
171
|
-
|
172
|
-
|
173
|
-
class InputTester
|
174
|
-
def initialize(*actions)
|
175
|
-
@orig_actions = actions.dup
|
176
|
-
@actions = actions
|
177
|
-
end
|
178
|
-
|
179
|
-
def readline(*)
|
180
|
-
@actions.shift
|
181
|
-
end
|
182
|
-
|
183
|
-
def rewind
|
184
|
-
@actions = @orig_actions.dup
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
class Pry
|
189
|
-
|
190
|
-
# null output class - doesn't write anywwhere.
|
191
|
-
class NullOutput
|
192
|
-
def self.puts(*) end
|
193
|
-
def self.string(*) end
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
|
-
# Open a temp file and yield it to the block, closing it after
|
198
|
-
# @return [String] The path of the temp file
|
199
|
-
def temp_file(ext='.rb')
|
200
|
-
file = Tempfile.new(['pry', ext])
|
201
|
-
yield file
|
202
|
-
ensure
|
203
|
-
file.close(true) if file
|
204
|
-
end
|
205
|
-
|
206
|
-
|
207
|
-
CommandTester = Pry::CommandSet.new do
|
208
|
-
command "command1", "command 1 test" do
|
209
|
-
output.puts "command1"
|
210
|
-
end
|
211
|
-
|
212
|
-
command "command2", "command 2 test" do |arg|
|
213
|
-
output.puts arg
|
214
|
-
end
|
215
|
-
end
|
216
|
-
|
217
|
-
# to help with tracking down bugs that cause an infinite loop in the test suite
|
218
|
-
if ENV["SET_TRACE_FUNC"]
|
219
|
-
require 'set_trace' if Pry::Helpers::BaseHelpers.rbx?
|
220
|
-
set_trace_func proc { |event, file, line, id, binding, classname|
|
221
|
-
STDERR.printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname
|
222
|
-
}
|
223
|
-
end
|
data/test/test_cli.rb
DELETED
@@ -1,78 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe Pry::Hooks do
|
4
|
-
before do
|
5
|
-
Pry::CLI.reset
|
6
|
-
end
|
7
|
-
|
8
|
-
describe "parsing options" do
|
9
|
-
it 'should raise if no options defined' do
|
10
|
-
lambda { Pry::CLI.parse_options(["--nothing"]) }.should.raise Pry::CLI::NoOptionsError
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
describe "adding options" do
|
15
|
-
it "should be able to add an option" do
|
16
|
-
run = false
|
17
|
-
|
18
|
-
Pry::CLI.add_options do
|
19
|
-
on :optiontest, "A test option" do
|
20
|
-
run = true
|
21
|
-
end
|
22
|
-
end.parse_options(["--optiontest"])
|
23
|
-
|
24
|
-
run.should == true
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should be able to add multiple options" do
|
28
|
-
run = false
|
29
|
-
run2 = false
|
30
|
-
|
31
|
-
Pry::CLI.add_options do
|
32
|
-
on :optiontest, "A test option" do
|
33
|
-
run = true
|
34
|
-
end
|
35
|
-
end.add_options do
|
36
|
-
on :optiontest2, "Another test option" do
|
37
|
-
run2 = true
|
38
|
-
end
|
39
|
-
end.parse_options(["--optiontest", "--optiontest2"])
|
40
|
-
|
41
|
-
run.should == true
|
42
|
-
run2.should == true
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
46
|
-
|
47
|
-
describe "processing options" do
|
48
|
-
it "should be able to process an option" do
|
49
|
-
run = false
|
50
|
-
|
51
|
-
Pry::CLI.add_options do
|
52
|
-
on :optiontest, "A test option"
|
53
|
-
end.process_options do |opts|
|
54
|
-
run = true if opts.present?(:optiontest)
|
55
|
-
end.parse_options(["--optiontest"])
|
56
|
-
|
57
|
-
run.should == true
|
58
|
-
end
|
59
|
-
|
60
|
-
it "should be able to process multiple options" do
|
61
|
-
run = false
|
62
|
-
run2 = false
|
63
|
-
|
64
|
-
Pry::CLI.add_options do
|
65
|
-
on :optiontest, "A test option"
|
66
|
-
on :optiontest2, "Another test option"
|
67
|
-
end.process_options do |opts|
|
68
|
-
run = true if opts.present?(:optiontest)
|
69
|
-
end.process_options do |opts|
|
70
|
-
run2 = true if opts.present?(:optiontest2)
|
71
|
-
end.parse_options(["--optiontest", "--optiontest2"])
|
72
|
-
|
73
|
-
run.should == true
|
74
|
-
run2.should == true
|
75
|
-
end
|
76
|
-
|
77
|
-
end
|
78
|
-
end
|
data/test/test_code.rb
DELETED
@@ -1,201 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe Pry::Code do
|
4
|
-
describe '.from_file' do
|
5
|
-
should 'read lines from a file on disk' do
|
6
|
-
Pry::Code.from_file('lib/pry.rb').length.should > 0
|
7
|
-
end
|
8
|
-
|
9
|
-
should 'read lines from Pry\'s line buffer' do
|
10
|
-
mock_pry(':hay_guys')
|
11
|
-
Pry::Code.from_file('(pry)').grep(/:hay_guys/).length.should == 1
|
12
|
-
end
|
13
|
-
|
14
|
-
should 'default to Ruby' do
|
15
|
-
temp_file('') do |f|
|
16
|
-
Pry::Code.from_file(f.path).code_type.should == :ruby
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
should 'check the extension' do
|
21
|
-
temp_file('.c') do |f|
|
22
|
-
Pry::Code.from_file(f.path).code_type.should == :c
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
should 'raise an error if the file doesn\'t exist' do
|
27
|
-
proc do
|
28
|
-
Pry::Code.from_file('/knalkjsdnalsd/alkjdlkq')
|
29
|
-
end.should.raise(MethodSource::SourceNotFoundError)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe '.from_method' do
|
34
|
-
should 'read lines from a method\'s definition' do
|
35
|
-
m = Pry::Method.from_obj(Pry, :load_history)
|
36
|
-
Pry::Code.from_method(m).length.should > 0
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe '#initialize' do
|
41
|
-
before do
|
42
|
-
@str = Pry::Helpers::CommandHelpers.unindent <<-CODE
|
43
|
-
def hay
|
44
|
-
:guys
|
45
|
-
end
|
46
|
-
CODE
|
47
|
-
|
48
|
-
@array = ['def hay', ' :guys', 'end']
|
49
|
-
end
|
50
|
-
|
51
|
-
should 'break a string into lines' do
|
52
|
-
Pry::Code.new(@str).length.should == 3
|
53
|
-
end
|
54
|
-
|
55
|
-
should 'accept an array' do
|
56
|
-
Pry::Code.new(@array).length.should == 3
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'an array or string should produce an equivalent object' do
|
60
|
-
Pry::Code.new(@str).should == Pry::Code.new(@array)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
describe 'filters and formatters' do
|
65
|
-
before do
|
66
|
-
@code = Pry::Code(Pry::Helpers::CommandHelpers.unindent <<-STR)
|
67
|
-
class MyProgram
|
68
|
-
def self.main
|
69
|
-
puts 'Hello, world!'
|
70
|
-
end
|
71
|
-
end
|
72
|
-
STR
|
73
|
-
end
|
74
|
-
|
75
|
-
describe 'filters' do
|
76
|
-
describe '#between' do
|
77
|
-
should 'work with an inclusive range' do
|
78
|
-
@code = @code.between(1..3)
|
79
|
-
@code.length.should == 3
|
80
|
-
@code.should =~ /\Aclass MyProgram/
|
81
|
-
@code.should =~ /world!'\Z/
|
82
|
-
end
|
83
|
-
|
84
|
-
should 'default to an inclusive range' do
|
85
|
-
@code = @code.between(3, 5)
|
86
|
-
@code.length.should == 3
|
87
|
-
end
|
88
|
-
|
89
|
-
should 'work with an exclusive range' do
|
90
|
-
@code = @code.between(2...4)
|
91
|
-
@code.length.should == 2
|
92
|
-
@code.should =~ /\A def self/
|
93
|
-
@code.should =~ /world!'\Z/
|
94
|
-
end
|
95
|
-
|
96
|
-
should 'use real line numbers for positive indices' do
|
97
|
-
@code = @code.after(3, 3)
|
98
|
-
@code = @code.between(4, 4)
|
99
|
-
@code.length.should == 1
|
100
|
-
@code.should =~ /\A end\Z/
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
describe '#before' do
|
105
|
-
should 'work' do
|
106
|
-
@code = @code.before(3, 1)
|
107
|
-
@code.should =~ /\A def self\.main\Z/
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
describe '#around' do
|
112
|
-
should 'work' do
|
113
|
-
@code = @code.around(3, 1)
|
114
|
-
@code.length.should == 3
|
115
|
-
@code.should =~ /\A def self/
|
116
|
-
@code.should =~ / end\Z/
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
describe '#after' do
|
121
|
-
should 'work' do
|
122
|
-
@code = @code.after(3, 1)
|
123
|
-
@code.should =~ /\A end\Z/
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
describe '#grep' do
|
128
|
-
should 'work' do
|
129
|
-
@code = @code.grep(/end/)
|
130
|
-
@code.length.should == 2
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
describe 'formatters' do
|
136
|
-
describe '#with_line_numbers' do
|
137
|
-
should 'show line numbers' do
|
138
|
-
@code = @code.with_line_numbers
|
139
|
-
@code.should =~ /1:/
|
140
|
-
end
|
141
|
-
|
142
|
-
should 'disable line numbers when falsy' do
|
143
|
-
@code = @code.with_line_numbers
|
144
|
-
@code = @code.with_line_numbers(false)
|
145
|
-
@code.should.not =~ /1:/
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
describe '#with_marker' do
|
150
|
-
should 'show a marker in the right place' do
|
151
|
-
@code = @code.with_marker(2)
|
152
|
-
@code.should =~ /^ => def self/
|
153
|
-
end
|
154
|
-
|
155
|
-
should 'disable the marker when falsy' do
|
156
|
-
@code = @code.with_marker(2)
|
157
|
-
@code = @code.with_marker(false)
|
158
|
-
@code.should =~ /^ def self/
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
describe '#with_indentation' do
|
163
|
-
should 'indent the text' do
|
164
|
-
@code = @code.with_indentation(2)
|
165
|
-
@code.should =~ /^ def self/
|
166
|
-
end
|
167
|
-
|
168
|
-
should 'disable the indentation when falsy' do
|
169
|
-
@code = @code.with_indentation(2)
|
170
|
-
@code = @code.with_indentation(false)
|
171
|
-
@code.should =~ /^ def self/
|
172
|
-
end
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
describe 'composition' do
|
177
|
-
describe 'grep and with_line_numbers' do
|
178
|
-
should 'work' do
|
179
|
-
@code = @code.grep(/end/).with_line_numbers
|
180
|
-
@code.should =~ /\A4: end/
|
181
|
-
@code.should =~ /5: end\Z/
|
182
|
-
end
|
183
|
-
end
|
184
|
-
|
185
|
-
describe 'grep and before and with_line_numbers' do
|
186
|
-
should 'work' do
|
187
|
-
@code = @code.grep(/e/).before(5, 5).with_line_numbers
|
188
|
-
@code.should =~ /\A2: def self.main\n3:/
|
189
|
-
@code.should =~ /4: end\Z/
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
describe 'before and after' do
|
194
|
-
should 'work' do
|
195
|
-
@code = @code.before(4, 2).after(2)
|
196
|
-
@code.should == " puts 'Hello, world!'"
|
197
|
-
end
|
198
|
-
end
|
199
|
-
end
|
200
|
-
end
|
201
|
-
end
|