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
@@ -1,11 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
2
-
3
- # Create a StringIO to contain the output data
4
- str_output = StringIO.new
5
-
6
- # Start a Pry session on the Fixnum 5 using str_output to store the
7
- # output (not writing to $stdout)
8
- Pry.start(5, :output => str_output)
9
-
10
- # Display all the output accumulated during the session
11
- puts str_output.string
@@ -1,6 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
2
-
3
- my_print = proc { |out, value| out.puts "Output is: #{value.inspect}" }
4
-
5
- # Start a Pry session using the print object defined in my_print
6
- Pry.start(TOPLEVEL_BINDING, :print => my_print)
@@ -1,9 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
2
-
3
- # Remember, first prompt in array is the main prompt, second is the wait
4
- # prompt (used for multiline input when more input is required)
5
- my_prompt = [ proc { |obj, *| "inside #{obj}> " },
6
- proc { |obj, *| "inside #{obj}* "} ]
7
-
8
- # Start a Pry session using the prompt defined in my_prompt
9
- Pry.start(TOPLEVEL_BINDING, :prompt => my_prompt)
data/examples/helper.rb DELETED
@@ -1,6 +0,0 @@
1
- require 'rubygems'
2
- unless Object.const_defined? 'Pry'
3
- $:.unshift File.expand_path '../../lib', __FILE__
4
- require 'pry'
5
- end
6
-
@@ -1,221 +0,0 @@
1
- # taken from irb
2
-
3
- require "readline"
4
-
5
- class Pry
6
-
7
- # Implements tab completion for Readline in Pry
8
- module InputCompleter
9
-
10
- if Readline.respond_to?("basic_word_break_characters=")
11
- Readline.basic_word_break_characters = " \t\n\"\\'`><=;|&{("
12
- end
13
-
14
- Readline.completion_append_character = nil
15
-
16
- ReservedWords = [
17
- "BEGIN", "END",
18
- "alias", "and",
19
- "begin", "break",
20
- "case", "class",
21
- "def", "defined", "do",
22
- "else", "elsif", "end", "ensure",
23
- "false", "for",
24
- "if", "in",
25
- "module",
26
- "next", "nil", "not",
27
- "or",
28
- "redo", "rescue", "retry", "return",
29
- "self", "super",
30
- "then", "true",
31
- "undef", "unless", "until",
32
- "when", "while",
33
- "yield" ]
34
-
35
- Operators = [
36
- "%", "&", "*", "**", "+", "-", "/",
37
- "<", "<<", "<=", "<=>", "==", "===", "=~", ">", ">=", ">>",
38
- "[]", "[]=", "^", "!", "!=", "!~"
39
- ]
40
-
41
- # Return a new completion proc for use by Readline.
42
- # @param [Binding] target The current binding context.
43
- # @param [Array<String>] commands The array of Pry commands.
44
- def self.build_completion_proc(target, commands=[""])
45
- proc do |input|
46
- begin
47
- bind = target
48
-
49
- case input
50
- when /^(\/[^\/]*\/)\.([^.]*)$/
51
- # Regexp
52
- receiver = $1
53
- message = Regexp.quote($2)
54
-
55
- candidates = Regexp.instance_methods.collect{|m| m.to_s}
56
- select_message(receiver, message, candidates)
57
-
58
- when /^([^\]]*\])\.([^.]*)$/
59
- # Array
60
- receiver = $1
61
- message = Regexp.quote($2)
62
-
63
- candidates = Array.instance_methods.collect{|m| m.to_s}
64
- select_message(receiver, message, candidates)
65
-
66
- when /^([^\}]*\})\.([^.]*)$/
67
- # Proc or Hash
68
- receiver = $1
69
- message = Regexp.quote($2)
70
-
71
- candidates = Proc.instance_methods.collect{|m| m.to_s}
72
- candidates |= Hash.instance_methods.collect{|m| m.to_s}
73
- select_message(receiver, message, candidates)
74
-
75
- when /^(:[^:.]*)$/
76
- # Symbol
77
- if Symbol.respond_to?(:all_symbols)
78
- sym = Regexp.quote($1)
79
- candidates = Symbol.all_symbols.collect{|s| ":" + s.id2name}
80
-
81
- candidates.grep(/^#{sym}/)
82
- else
83
- []
84
- end
85
-
86
- when /^::([A-Z][^:\.\(]*)$/
87
- # Absolute Constant or class methods
88
- receiver = $1
89
- candidates = Object.constants.collect{|m| m.to_s}
90
- candidates.grep(/^#{receiver}/).collect{|e| "::" + e}
91
-
92
- when /^([A-Z].*)::([^:.]*)$/
93
- # Constant or class methods
94
- receiver = $1
95
- message = Regexp.quote($2)
96
- begin
97
- candidates = eval("#{receiver}.constants.collect{|m| m.to_s}", bind)
98
- candidates |= eval("#{receiver}.methods.collect{|m| m.to_s}", bind)
99
- rescue RescuableException
100
- candidates = []
101
- end
102
- candidates.grep(/^#{message}/).collect{|e| receiver + "::" + e}
103
-
104
- when /^(:[^:.]+)\.([^.]*)$/
105
- # Symbol
106
- receiver = $1
107
- message = Regexp.quote($2)
108
-
109
- candidates = Symbol.instance_methods.collect{|m| m.to_s}
110
- select_message(receiver, message, candidates)
111
-
112
- when /^(-?(0[dbo])?[0-9_]+(\.[0-9_]+)?([eE]-?[0-9]+)?)\.([^.]*)$/
113
- # Numeric
114
- receiver = $1
115
- message = Regexp.quote($5)
116
-
117
- begin
118
- candidates = eval(receiver, bind).methods.collect{|m| m.to_s}
119
- rescue RescuableException
120
- candidates = []
121
- end
122
- select_message(receiver, message, candidates)
123
-
124
- when /^(-?0x[0-9a-fA-F_]+)\.([^.]*)$/
125
- # Numeric(0xFFFF)
126
- receiver = $1
127
- message = Regexp.quote($2)
128
-
129
- begin
130
- candidates = eval(receiver, bind).methods.collect{|m| m.to_s}
131
- rescue RescuableException
132
- candidates = []
133
- end
134
- select_message(receiver, message, candidates)
135
-
136
- when /^(\$[^.]*)$/
137
- regmessage = Regexp.new(Regexp.quote($1))
138
- candidates = global_variables.collect{|m| m.to_s}.grep(regmessage)
139
-
140
- when /^([^."].*)\.([^.]*)$/
141
- # variable
142
- receiver = $1
143
- message = Regexp.quote($2)
144
-
145
- gv = eval("global_variables", bind).collect{|m| m.to_s}
146
- lv = eval("local_variables", bind).collect{|m| m.to_s}
147
- cv = eval("self.class.constants", bind).collect{|m| m.to_s}
148
-
149
- if (gv | lv | cv).include?(receiver) or /^[A-Z]/ =~ receiver && /\./ !~ receiver
150
- # foo.func and foo is local var. OR
151
- # Foo::Bar.func
152
- begin
153
- candidates = eval("#{receiver}.methods", bind).collect{|m| m.to_s}
154
- rescue RescuableException
155
- candidates = []
156
- end
157
- else
158
- # func1.func2
159
- candidates = []
160
- ObjectSpace.each_object(Module){|m|
161
- begin
162
- name = m.name.to_s
163
- rescue RescuableException
164
- name = ""
165
- end
166
- next if name != "IRB::Context" and
167
- /^(IRB|SLex|RubyLex|RubyToken)/ =~ name
168
-
169
- # jruby doesn't always provide #instance_methods() on each
170
- # object.
171
- if m.respond_to?(:instance_methods)
172
- candidates.concat m.instance_methods(false).collect{|x| x.to_s}
173
- end
174
- }
175
- candidates.sort!
176
- candidates.uniq!
177
- end
178
- select_message(receiver, message, candidates)
179
-
180
- when /^\.([^.]*)$/
181
- # unknown(maybe String)
182
-
183
- receiver = ""
184
- message = Regexp.quote($1)
185
-
186
- candidates = String.instance_methods(true).collect{|m| m.to_s}
187
- select_message(receiver, message, candidates)
188
-
189
- else
190
- candidates = eval(
191
- "methods | private_methods | local_variables | " \
192
- "self.class.constants | instance_variables",
193
- bind
194
- ).collect{|m| m.to_s}
195
-
196
- if eval("respond_to?(:class_variables)", bind)
197
- candidates += eval("class_variables", bind).collect { |m| m.to_s }
198
- end
199
-
200
- (candidates|ReservedWords|commands).grep(/^#{Regexp.quote(input)}/)
201
- end
202
- rescue RescuableException
203
- []
204
- end
205
- end
206
- end
207
-
208
- def self.select_message(receiver, message, candidates)
209
- candidates.grep(/^#{message}/).collect do |e|
210
- case e
211
- when /^[a-zA-Z_]/
212
- receiver + "." + e
213
- when /^[0-9]/
214
- when *Operators
215
- #receiver + " " + e
216
- end
217
- end
218
- end
219
- end
220
- end
221
-
@@ -1,6 +0,0 @@
1
- class Pry
2
-
3
- # This proc will be instance_eval's against the active Pry instance
4
- DEFAULT_CUSTOM_COMPLETIONS = proc { commands.commands.keys }
5
- FILE_COMPLETIONS = proc { commands.commands.keys + Dir.entries('.') }
6
- end
@@ -1,81 +0,0 @@
1
- class Pry
2
- module DefaultCommands
3
- Cd = Pry::CommandSet.new do
4
- create_command "cd" do
5
- group "Context"
6
- description "Move into a new context (object or scope)."
7
-
8
- banner <<-BANNER
9
- Usage: cd [OPTIONS] [--help]
10
-
11
- Move into new context (object or scope). As in unix shells use
12
- `cd ..` to go back, `cd /` to return to Pry top-level and `cd -`
13
- to toggle between last two scopes).
14
- Complex syntax (e.g `cd ../@x/y`) also supported.
15
-
16
- e.g: `cd @x`
17
- e.g: `cd ..`
18
- e.g: `cd /`
19
- e.g: `cd -`
20
-
21
- https://github.com/pry/pry/wiki/State-navigation#wiki-Changing_scope
22
- BANNER
23
-
24
- def process
25
- # Extract command arguments. Delete blank arguments like " ", but
26
- # don't delete empty strings like "".
27
- path = arg_string.split(/\//).delete_if { |a| a =~ /\A\s+\z/ }
28
- stack = _pry_.binding_stack.dup
29
- old_stack = state.old_stack || []
30
-
31
- # Special case when we only get a single "/", return to root.
32
- if path.empty?
33
- state.old_stack = stack.dup unless old_stack.empty?
34
- stack = [stack.first]
35
- end
36
-
37
- path.each_with_index do |context, i|
38
- begin
39
- case context.chomp
40
- when ""
41
- state.old_stack = stack.dup
42
- stack = [stack.first]
43
- when "::"
44
- state.old_stack = stack.dup
45
- stack.push(TOPLEVEL_BINDING)
46
- when "."
47
- next
48
- when ".."
49
- unless stack.size == 1
50
- # Don't rewrite old_stack if we're in complex expression
51
- # (e.g.: `cd 1/2/3/../4).
52
- state.old_stack = stack.dup if path.first == ".."
53
- stack.pop
54
- end
55
- when "-"
56
- unless old_stack.empty?
57
- # Interchange current stack and old stack with each other.
58
- stack, state.old_stack = state.old_stack, stack
59
- end
60
- else
61
- state.old_stack = stack.dup if i == 0
62
- stack.push(Pry.binding_for(stack.last.eval(context)))
63
- end
64
-
65
- rescue RescuableException => e
66
- # Restore old stack to its initial values.
67
- state.old_stack = old_stack
68
-
69
- output.puts "Bad object path: #{arg_string.chomp}. Failed trying to resolve: #{context}"
70
- output.puts e.inspect
71
- return
72
- end
73
- end
74
-
75
- _pry_.binding_stack = stack
76
- end
77
-
78
- end
79
- end
80
- end
81
- end
@@ -1,62 +0,0 @@
1
- class Pry
2
- module DefaultCommands
3
- Commands = Pry::CommandSet.new do
4
- create_command "import-set", "Import a command set" do
5
- group "Commands"
6
- def process(command_set_name)
7
- raise CommandError, "Provide a command set name" if command_set.nil?
8
-
9
- set = target.eval(arg_string)
10
- _pry_.commands.import set
11
- end
12
- end
13
-
14
- create_command "install-command", "Install a disabled command." do |name|
15
- group 'Commands'
16
-
17
- banner <<-BANNER
18
- Usage: install-command COMMAND
19
-
20
- Installs the gems necessary to run the given COMMAND. You will generally not
21
- need to run this unless told to by an error message.
22
- BANNER
23
-
24
- def process(name)
25
- require 'rubygems/dependency_installer' unless defined? Gem::DependencyInstaller
26
- command = find_command(name)
27
-
28
- if command_dependencies_met?(command.options)
29
- output.puts "Dependencies for #{command.name} are met. Nothing to do."
30
- return
31
- end
32
-
33
- output.puts "Attempting to install `#{name}` command..."
34
- gems_to_install = Array(command.options[:requires_gem])
35
-
36
- gems_to_install.each do |g|
37
- next if gem_installed?(g)
38
- output.puts "Installing `#{g}` gem..."
39
-
40
- begin
41
- Gem::DependencyInstaller.new.install(g)
42
- rescue Gem::GemNotFoundException
43
- raise CommandError, "Required Gem: `#{g}` not found. Aborting command installation."
44
- end
45
- end
46
-
47
- Gem.refresh
48
- gems_to_install.each do |g|
49
- begin
50
- require g
51
- rescue LoadError
52
- raise CommandError, "Required Gem: `#{g}` installed but not found?!. Aborting command installation."
53
- end
54
- end
55
-
56
- output.puts "Installation of `#{name}` successful! Type `help #{name}` for information"
57
- end
58
- end
59
- end
60
- end
61
- end
62
-
@@ -1,98 +0,0 @@
1
- require "pry/default_commands/ls"
2
- require "pry/default_commands/cd"
3
- require "pry/default_commands/find_method"
4
- require "pry/default_commands/whereami"
5
-
6
- class Pry
7
- module DefaultCommands
8
-
9
- Context = Pry::CommandSet.new do
10
- import Ls
11
- import Cd
12
- import FindMethod
13
- import Whereami
14
-
15
- create_command "pry-backtrace", "Show the backtrace for the Pry session." do
16
- banner <<-BANNER
17
- Usage: pry-backtrace [OPTIONS] [--help]
18
-
19
- Show the backtrace for the position in the code where Pry was started. This can be used to
20
- infer the behavior of the program immediately before it entered Pry, just like the backtrace
21
- property of an exception.
22
-
23
- (NOTE: if you are looking for the backtrace of the most recent exception raised,
24
- just type: `_ex_.backtrace` instead, see https://github.com/pry/pry/wiki/Special-Locals)
25
-
26
- e.g: pry-backtrace
27
- BANNER
28
-
29
- def process
30
- output.puts "\n#{text.bold('Backtrace:')}\n--\n"
31
- stagger_output _pry_.backtrace.join("\n")
32
- end
33
- end
34
-
35
- command "reset", "Reset the REPL to a clean state." do
36
- output.puts "Pry reset."
37
- exec "pry"
38
- end
39
-
40
- create_command(/wtf([?!]*)/, "Show the backtrace of the most recent exception") do
41
- options :listing => 'wtf?'
42
-
43
- banner <<-BANNER
44
- Show's a few lines of the backtrace of the most recent exception (also available
45
- as _ex_.backtrace).
46
-
47
- If you want to see more lines, add more question marks or exclamation marks:
48
-
49
- e.g.
50
- pry(main)> wtf?
51
- pry(main)> wtf?!???!?!?
52
-
53
- To see the entire backtrace, pass the -v/--verbose flag:
54
-
55
- e.g.
56
- pry(main)> wtf -v
57
- BANNER
58
-
59
- def options(opt)
60
- opt.on(:v, :verbose, "Show the full backtrace.")
61
- end
62
-
63
- def process
64
- raise Pry::CommandError, "No most-recent exception" unless _pry_.last_exception
65
-
66
- output.puts "#{text.bold('Exception:')} #{_pry_.last_exception.class}: #{_pry_.last_exception}\n--"
67
- if opts.verbose?
68
- output.puts Code.new(_pry_.last_exception.backtrace, 0, :text).with_line_numbers.to_s
69
- else
70
- output.puts Code.new(_pry_.last_exception.backtrace.first([captures[0].size, 0.5].max * 10), 0, :text).with_line_numbers.to_s
71
- end
72
- end
73
- end
74
-
75
- # N.B. using a regular expresion here so that "raise-up 'foo'" does the right thing.
76
- create_command(/raise-up(!?\b.*)/, :listing => 'raise-up') do
77
- description "Raise an exception out of the current pry instance."
78
- banner <<-BANNER
79
- Raise up, like exit, allows you to quit pry. Instead of returning a value however, it raises an exception.
80
- If you don't provide the exception to be raised, it will use the most recent exception (in pry _ex_).
81
-
82
- e.g. `raise-up "get-me-out-of-here"` is equivalent to:
83
- `raise "get-me-out-of-here"
84
- raise-up`
85
-
86
- When called as raise-up! (with an exclamation mark), this command raises the exception through
87
- any nested prys you have created by "cd"ing into objects.
88
- BANNER
89
-
90
- def process
91
- return stagger_output help if captures[0] =~ /(-h|--help)\b/
92
- # Handle 'raise-up', 'raise-up "foo"', 'raise-up RuntimeError, 'farble' in a rubyesque manner
93
- target.eval("_pry_.raise_up#{captures[0]}")
94
- end
95
- end
96
- end
97
- end
98
- end