pry 0.10.pre.1-i386-mingw32 → 0.10.0.pre3-i386-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (214) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +702 -0
  3. data/LICENSE +2 -2
  4. data/{README.markdown → README.md} +41 -35
  5. data/lib/pry.rb +82 -139
  6. data/lib/pry/cli.rb +77 -30
  7. data/lib/pry/code.rb +122 -183
  8. data/lib/pry/code/code_file.rb +103 -0
  9. data/lib/pry/code/code_range.rb +71 -0
  10. data/lib/pry/code/loc.rb +92 -0
  11. data/lib/pry/code_object.rb +172 -0
  12. data/lib/pry/color_printer.rb +55 -0
  13. data/lib/pry/command.rb +184 -28
  14. data/lib/pry/command_set.rb +113 -59
  15. data/lib/pry/commands.rb +4 -27
  16. data/lib/pry/commands/amend_line.rb +99 -0
  17. data/lib/pry/commands/bang.rb +20 -0
  18. data/lib/pry/commands/bang_pry.rb +17 -0
  19. data/lib/pry/commands/cat.rb +62 -0
  20. data/lib/pry/commands/cat/abstract_formatter.rb +27 -0
  21. data/lib/pry/commands/cat/exception_formatter.rb +77 -0
  22. data/lib/pry/commands/cat/file_formatter.rb +67 -0
  23. data/lib/pry/commands/cat/input_expression_formatter.rb +43 -0
  24. data/lib/pry/commands/cd.rb +41 -0
  25. data/lib/pry/commands/change_inspector.rb +27 -0
  26. data/lib/pry/commands/change_prompt.rb +26 -0
  27. data/lib/pry/commands/code_collector.rb +165 -0
  28. data/lib/pry/commands/disable_pry.rb +27 -0
  29. data/lib/pry/commands/disabled_commands.rb +2 -0
  30. data/lib/pry/commands/easter_eggs.rb +112 -0
  31. data/lib/pry/commands/edit.rb +195 -0
  32. data/lib/pry/commands/edit/exception_patcher.rb +25 -0
  33. data/lib/pry/commands/edit/file_and_line_locator.rb +36 -0
  34. data/lib/pry/commands/exit.rb +42 -0
  35. data/lib/pry/commands/exit_all.rb +29 -0
  36. data/lib/pry/commands/exit_program.rb +23 -0
  37. data/lib/pry/commands/find_method.rb +193 -0
  38. data/lib/pry/commands/fix_indent.rb +19 -0
  39. data/lib/pry/commands/gem_cd.rb +26 -0
  40. data/lib/pry/commands/gem_install.rb +32 -0
  41. data/lib/pry/commands/gem_list.rb +33 -0
  42. data/lib/pry/commands/gem_open.rb +29 -0
  43. data/lib/pry/commands/gist.rb +101 -0
  44. data/lib/pry/commands/help.rb +164 -0
  45. data/lib/pry/commands/hist.rb +180 -0
  46. data/lib/pry/commands/import_set.rb +22 -0
  47. data/lib/pry/commands/install_command.rb +53 -0
  48. data/lib/pry/commands/jump_to.rb +29 -0
  49. data/lib/pry/commands/list_inspectors.rb +35 -0
  50. data/lib/pry/commands/list_prompts.rb +35 -0
  51. data/lib/pry/commands/ls.rb +114 -0
  52. data/lib/pry/commands/ls/constants.rb +47 -0
  53. data/lib/pry/commands/ls/formatter.rb +49 -0
  54. data/lib/pry/commands/ls/globals.rb +48 -0
  55. data/lib/pry/commands/ls/grep.rb +21 -0
  56. data/lib/pry/commands/ls/instance_vars.rb +39 -0
  57. data/lib/pry/commands/ls/interrogatable.rb +18 -0
  58. data/lib/pry/commands/ls/jruby_hacks.rb +49 -0
  59. data/lib/pry/commands/ls/local_names.rb +35 -0
  60. data/lib/pry/commands/ls/local_vars.rb +39 -0
  61. data/lib/pry/commands/ls/ls_entity.rb +70 -0
  62. data/lib/pry/commands/ls/methods.rb +57 -0
  63. data/lib/pry/commands/ls/methods_helper.rb +46 -0
  64. data/lib/pry/commands/ls/self_methods.rb +32 -0
  65. data/lib/pry/commands/nesting.rb +25 -0
  66. data/lib/pry/commands/play.rb +103 -0
  67. data/lib/pry/commands/pry_backtrace.rb +25 -0
  68. data/lib/pry/commands/pry_version.rb +17 -0
  69. data/lib/pry/commands/raise_up.rb +32 -0
  70. data/lib/pry/commands/reload_code.rb +62 -0
  71. data/lib/pry/commands/reset.rb +18 -0
  72. data/lib/pry/commands/ri.rb +60 -0
  73. data/lib/pry/commands/save_file.rb +61 -0
  74. data/lib/pry/commands/shell_command.rb +48 -0
  75. data/lib/pry/commands/shell_mode.rb +25 -0
  76. data/lib/pry/commands/show_doc.rb +83 -0
  77. data/lib/pry/commands/show_info.rb +195 -0
  78. data/lib/pry/commands/show_input.rb +17 -0
  79. data/lib/pry/commands/show_source.rb +50 -0
  80. data/lib/pry/commands/simple_prompt.rb +22 -0
  81. data/lib/pry/commands/stat.rb +40 -0
  82. data/lib/pry/commands/switch_to.rb +23 -0
  83. data/lib/pry/commands/toggle_color.rb +24 -0
  84. data/lib/pry/commands/watch_expression.rb +105 -0
  85. data/lib/pry/commands/watch_expression/expression.rb +38 -0
  86. data/lib/pry/commands/whereami.rb +190 -0
  87. data/lib/pry/commands/wtf.rb +57 -0
  88. data/lib/pry/config.rb +20 -229
  89. data/lib/pry/config/behavior.rb +139 -0
  90. data/lib/pry/config/convenience.rb +26 -0
  91. data/lib/pry/config/default.rb +165 -0
  92. data/lib/pry/core_extensions.rb +59 -38
  93. data/lib/pry/editor.rb +133 -0
  94. data/lib/pry/exceptions.rb +77 -0
  95. data/lib/pry/helpers.rb +1 -0
  96. data/lib/pry/helpers/base_helpers.rb +40 -154
  97. data/lib/pry/helpers/command_helpers.rb +19 -130
  98. data/lib/pry/helpers/documentation_helpers.rb +21 -11
  99. data/lib/pry/helpers/table.rb +109 -0
  100. data/lib/pry/helpers/text.rb +8 -9
  101. data/lib/pry/history.rb +61 -45
  102. data/lib/pry/history_array.rb +11 -1
  103. data/lib/pry/hooks.rb +10 -32
  104. data/lib/pry/indent.rb +110 -38
  105. data/lib/pry/input_completer.rb +242 -0
  106. data/lib/pry/input_lock.rb +132 -0
  107. data/lib/pry/inspector.rb +27 -0
  108. data/lib/pry/last_exception.rb +61 -0
  109. data/lib/pry/method.rb +199 -200
  110. data/lib/pry/method/disowned.rb +53 -0
  111. data/lib/pry/method/patcher.rb +125 -0
  112. data/lib/pry/method/weird_method_locator.rb +186 -0
  113. data/lib/pry/module_candidate.rb +39 -33
  114. data/lib/pry/object_path.rb +82 -0
  115. data/lib/pry/output.rb +50 -0
  116. data/lib/pry/pager.rb +234 -0
  117. data/lib/pry/plugins.rb +4 -3
  118. data/lib/pry/prompt.rb +26 -0
  119. data/lib/pry/pry_class.rb +199 -227
  120. data/lib/pry/pry_instance.rb +344 -403
  121. data/lib/pry/rbx_path.rb +1 -1
  122. data/lib/pry/repl.rb +202 -0
  123. data/lib/pry/repl_file_loader.rb +20 -26
  124. data/lib/pry/rubygem.rb +82 -0
  125. data/lib/pry/terminal.rb +79 -0
  126. data/lib/pry/test/helper.rb +170 -0
  127. data/lib/pry/version.rb +1 -1
  128. data/lib/pry/wrapped_module.rb +133 -48
  129. metadata +132 -197
  130. data/.document +0 -2
  131. data/.gemtest +0 -0
  132. data/.gitignore +0 -16
  133. data/.travis.yml +0 -17
  134. data/.yardopts +0 -1
  135. data/CHANGELOG +0 -387
  136. data/CONTRIBUTORS +0 -36
  137. data/Gemfile +0 -2
  138. data/Rakefile +0 -137
  139. data/TODO +0 -117
  140. data/examples/example_basic.rb +0 -15
  141. data/examples/example_command_override.rb +0 -32
  142. data/examples/example_commands.rb +0 -36
  143. data/examples/example_hooks.rb +0 -9
  144. data/examples/example_image_edit.rb +0 -67
  145. data/examples/example_input.rb +0 -7
  146. data/examples/example_input2.rb +0 -29
  147. data/examples/example_output.rb +0 -11
  148. data/examples/example_print.rb +0 -6
  149. data/examples/example_prompt.rb +0 -9
  150. data/examples/helper.rb +0 -6
  151. data/lib/pry/completion.rb +0 -221
  152. data/lib/pry/custom_completions.rb +0 -6
  153. data/lib/pry/default_commands/cd.rb +0 -81
  154. data/lib/pry/default_commands/commands.rb +0 -62
  155. data/lib/pry/default_commands/context.rb +0 -98
  156. data/lib/pry/default_commands/easter_eggs.rb +0 -95
  157. data/lib/pry/default_commands/editing.rb +0 -420
  158. data/lib/pry/default_commands/find_method.rb +0 -169
  159. data/lib/pry/default_commands/gems.rb +0 -84
  160. data/lib/pry/default_commands/gist.rb +0 -187
  161. data/lib/pry/default_commands/help.rb +0 -127
  162. data/lib/pry/default_commands/hist.rb +0 -120
  163. data/lib/pry/default_commands/input_and_output.rb +0 -306
  164. data/lib/pry/default_commands/introspection.rb +0 -410
  165. data/lib/pry/default_commands/ls.rb +0 -272
  166. data/lib/pry/default_commands/misc.rb +0 -38
  167. data/lib/pry/default_commands/navigating_pry.rb +0 -110
  168. data/lib/pry/default_commands/whereami.rb +0 -92
  169. data/lib/pry/extended_commands/experimental.rb +0 -7
  170. data/lib/pry/rbx_method.rb +0 -13
  171. data/man/pry.1 +0 -195
  172. data/man/pry.1.html +0 -204
  173. data/man/pry.1.ronn +0 -141
  174. data/pry.gemspec +0 -46
  175. data/test/candidate_helper1.rb +0 -11
  176. data/test/candidate_helper2.rb +0 -8
  177. data/test/helper.rb +0 -223
  178. data/test/test_cli.rb +0 -78
  179. data/test/test_code.rb +0 -201
  180. data/test/test_command.rb +0 -712
  181. data/test/test_command_helpers.rb +0 -9
  182. data/test/test_command_integration.rb +0 -668
  183. data/test/test_command_set.rb +0 -610
  184. data/test/test_completion.rb +0 -62
  185. data/test/test_control_d_handler.rb +0 -45
  186. data/test/test_default_commands/example.erb +0 -5
  187. data/test/test_default_commands/test_cd.rb +0 -318
  188. data/test/test_default_commands/test_context.rb +0 -280
  189. data/test/test_default_commands/test_documentation.rb +0 -314
  190. data/test/test_default_commands/test_find_method.rb +0 -50
  191. data/test/test_default_commands/test_gems.rb +0 -18
  192. data/test/test_default_commands/test_help.rb +0 -57
  193. data/test/test_default_commands/test_input.rb +0 -428
  194. data/test/test_default_commands/test_introspection.rb +0 -511
  195. data/test/test_default_commands/test_ls.rb +0 -151
  196. data/test/test_default_commands/test_shell.rb +0 -343
  197. data/test/test_default_commands/test_show_source.rb +0 -432
  198. data/test/test_exception_whitelist.rb +0 -21
  199. data/test/test_history_array.rb +0 -65
  200. data/test/test_hooks.rb +0 -521
  201. data/test/test_indent.rb +0 -277
  202. data/test/test_input_stack.rb +0 -86
  203. data/test/test_method.rb +0 -401
  204. data/test/test_pry.rb +0 -463
  205. data/test/test_pry_defaults.rb +0 -419
  206. data/test/test_pry_history.rb +0 -84
  207. data/test/test_pry_output.rb +0 -41
  208. data/test/test_sticky_locals.rb +0 -155
  209. data/test/test_syntax_checking.rb +0 -65
  210. data/test/test_wrapped_module.rb +0 -174
  211. data/test/testrc +0 -2
  212. data/test/testrcbad +0 -2
  213. data/wiki/Customizing-pry.md +0 -397
  214. 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
@@ -1,11 +0,0 @@
1
- # rank 0
2
- class CandidateTest
3
- def test1
4
- end
5
-
6
- def test2
7
- end
8
-
9
- def test3
10
- end
11
- end
@@ -1,8 +0,0 @@
1
- # rank 1
2
- class CandidateTest
3
- def test4
4
- end
5
-
6
- def test5
7
- end
8
- end
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