pry 0.10.pre.1-i386-mswin32 → 0.10.0.pre3-i386-mswin32
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 +122 -183
- 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/examples/example_output.rb
DELETED
@@ -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
|
data/examples/example_print.rb
DELETED
data/examples/example_prompt.rb
DELETED
@@ -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
data/lib/pry/completion.rb
DELETED
@@ -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,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
|