pry 0.10.3 → 0.14.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +439 -16
- data/LICENSE +1 -1
- data/README.md +362 -302
- data/bin/pry +4 -7
- data/lib/pry/basic_object.rb +10 -0
- data/lib/pry/block_command.rb +22 -0
- data/lib/pry/class_command.rb +194 -0
- data/lib/pry/cli.rb +84 -97
- data/lib/pry/code/code_file.rb +37 -26
- data/lib/pry/code/code_range.rb +7 -5
- data/lib/pry/code/loc.rb +26 -13
- data/lib/pry/code.rb +42 -31
- data/lib/pry/code_object.rb +53 -28
- data/lib/pry/color_printer.rb +46 -35
- data/lib/pry/command.rb +197 -369
- data/lib/pry/command_set.rb +89 -114
- data/lib/pry/command_state.rb +31 -0
- data/lib/pry/commands/amend_line.rb +86 -82
- data/lib/pry/commands/bang.rb +18 -14
- data/lib/pry/commands/bang_pry.rb +15 -11
- data/lib/pry/commands/cat/abstract_formatter.rb +23 -18
- data/lib/pry/commands/cat/exception_formatter.rb +85 -72
- data/lib/pry/commands/cat/file_formatter.rb +56 -46
- data/lib/pry/commands/cat/input_expression_formatter.rb +35 -30
- data/lib/pry/commands/cat.rb +62 -54
- data/lib/pry/commands/cd.rb +40 -35
- data/lib/pry/commands/change_inspector.rb +29 -22
- data/lib/pry/commands/change_prompt.rb +48 -23
- data/lib/pry/commands/clear_screen.rb +20 -0
- data/lib/pry/commands/code_collector.rb +148 -131
- data/lib/pry/commands/disable_pry.rb +23 -19
- data/lib/pry/commands/easter_eggs.rb +23 -34
- data/lib/pry/commands/edit/exception_patcher.rb +21 -17
- data/lib/pry/commands/edit/file_and_line_locator.rb +34 -23
- data/lib/pry/commands/edit.rb +185 -157
- data/lib/pry/commands/exit.rb +40 -35
- data/lib/pry/commands/exit_all.rb +24 -20
- data/lib/pry/commands/exit_program.rb +20 -16
- data/lib/pry/commands/find_method.rb +168 -162
- data/lib/pry/commands/fix_indent.rb +16 -12
- data/lib/pry/commands/help.rb +140 -133
- data/lib/pry/commands/hist.rb +151 -149
- data/lib/pry/commands/import_set.rb +20 -15
- data/lib/pry/commands/jump_to.rb +25 -21
- data/lib/pry/commands/list_inspectors.rb +35 -28
- data/lib/pry/commands/ls/constants.rb +59 -31
- data/lib/pry/commands/ls/formatter.rb +42 -36
- data/lib/pry/commands/ls/globals.rb +38 -36
- data/lib/pry/commands/ls/grep.rb +17 -15
- data/lib/pry/commands/ls/instance_vars.rb +29 -28
- data/lib/pry/commands/ls/interrogatable.rb +18 -12
- data/lib/pry/commands/ls/jruby_hacks.rb +47 -41
- data/lib/pry/commands/ls/local_names.rb +26 -24
- data/lib/pry/commands/ls/local_vars.rb +38 -30
- data/lib/pry/commands/ls/ls_entity.rb +47 -52
- data/lib/pry/commands/ls/methods.rb +49 -51
- data/lib/pry/commands/ls/methods_helper.rb +46 -42
- data/lib/pry/commands/ls/self_methods.rb +23 -21
- data/lib/pry/commands/ls.rb +124 -103
- data/lib/pry/commands/nesting.rb +21 -17
- data/lib/pry/commands/play.rb +92 -82
- data/lib/pry/commands/pry_backtrace.rb +22 -17
- data/lib/pry/commands/pry_version.rb +15 -11
- data/lib/pry/commands/raise_up.rb +33 -27
- data/lib/pry/commands/reload_code.rb +60 -48
- data/lib/pry/commands/reset.rb +16 -12
- data/lib/pry/commands/ri.rb +57 -42
- data/lib/pry/commands/save_file.rb +45 -43
- data/lib/pry/commands/shell_command.rb +56 -29
- data/lib/pry/commands/shell_mode.rb +22 -18
- data/lib/pry/commands/show_doc.rb +80 -70
- data/lib/pry/commands/show_info.rb +194 -155
- data/lib/pry/commands/show_input.rb +16 -11
- data/lib/pry/commands/show_source.rb +110 -42
- data/lib/pry/commands/stat.rb +35 -31
- data/lib/pry/commands/switch_to.rb +21 -15
- data/lib/pry/commands/toggle_color.rb +20 -16
- data/lib/pry/commands/watch_expression/expression.rb +32 -27
- data/lib/pry/commands/watch_expression.rb +89 -84
- data/lib/pry/commands/whereami.rb +156 -141
- data/lib/pry/commands/wtf.rb +78 -40
- data/lib/pry/config/attributable.rb +22 -0
- data/lib/pry/config/lazy_value.rb +29 -0
- data/lib/pry/config/memoized_value.rb +34 -0
- data/lib/pry/config/value.rb +24 -0
- data/lib/pry/config.rb +310 -20
- data/lib/pry/control_d_handler.rb +28 -0
- data/lib/pry/core_extensions.rb +22 -9
- data/lib/pry/editor.rb +56 -34
- data/lib/pry/env.rb +18 -0
- data/lib/pry/exception_handler.rb +43 -0
- data/lib/pry/exceptions.rb +13 -18
- data/lib/pry/forwardable.rb +27 -0
- data/lib/pry/helpers/base_helpers.rb +20 -62
- data/lib/pry/helpers/command_helpers.rb +52 -62
- data/lib/pry/helpers/documentation_helpers.rb +21 -12
- data/lib/pry/helpers/options_helpers.rb +15 -8
- data/lib/pry/helpers/platform.rb +55 -0
- data/lib/pry/helpers/table.rb +44 -32
- data/lib/pry/helpers/text.rb +96 -85
- data/lib/pry/helpers.rb +3 -0
- data/lib/pry/history.rb +81 -55
- data/lib/pry/hooks.rb +60 -110
- data/lib/pry/indent.rb +74 -68
- data/lib/pry/input_completer.rb +199 -158
- data/lib/pry/input_lock.rb +7 -10
- data/lib/pry/inspector.rb +36 -24
- data/lib/pry/last_exception.rb +45 -45
- data/lib/pry/method/disowned.rb +19 -5
- data/lib/pry/method/patcher.rb +14 -8
- data/lib/pry/method/weird_method_locator.rb +79 -45
- data/lib/pry/method.rb +178 -124
- data/lib/pry/object_path.rb +37 -28
- data/lib/pry/output.rb +102 -16
- data/lib/pry/pager.rb +187 -174
- data/lib/pry/prompt.rb +213 -25
- data/lib/pry/pry_class.rb +119 -98
- data/lib/pry/pry_instance.rb +261 -224
- data/lib/pry/repl.rb +83 -29
- data/lib/pry/repl_file_loader.rb +27 -22
- data/lib/pry/ring.rb +89 -0
- data/lib/pry/slop/LICENSE +20 -0
- data/lib/pry/slop/commands.rb +190 -0
- data/lib/pry/slop/option.rb +210 -0
- data/lib/pry/slop.rb +672 -0
- data/lib/pry/syntax_highlighter.rb +26 -0
- data/lib/pry/system_command_handler.rb +17 -0
- data/lib/pry/testable/evalable.rb +24 -0
- data/lib/pry/testable/mockable.rb +22 -0
- data/lib/pry/testable/pry_tester.rb +88 -0
- data/lib/pry/testable/utility.rb +34 -0
- data/lib/pry/testable/variables.rb +52 -0
- data/lib/pry/testable.rb +68 -0
- data/lib/pry/version.rb +3 -1
- data/lib/pry/warning.rb +20 -0
- data/lib/pry/{module_candidate.rb → wrapped_module/candidate.rb} +35 -32
- data/lib/pry/wrapped_module.rb +68 -63
- data/lib/pry.rb +133 -149
- metadata +58 -69
- data/lib/pry/commands/disabled_commands.rb +0 -2
- data/lib/pry/commands/gem_cd.rb +0 -26
- data/lib/pry/commands/gem_install.rb +0 -32
- data/lib/pry/commands/gem_list.rb +0 -33
- data/lib/pry/commands/gem_open.rb +0 -29
- data/lib/pry/commands/gist.rb +0 -101
- data/lib/pry/commands/install_command.rb +0 -53
- data/lib/pry/commands/list_prompts.rb +0 -35
- data/lib/pry/commands/simple_prompt.rb +0 -22
- data/lib/pry/commands.rb +0 -6
- data/lib/pry/config/behavior.rb +0 -139
- data/lib/pry/config/convenience.rb +0 -25
- data/lib/pry/config/default.rb +0 -161
- data/lib/pry/history_array.rb +0 -121
- data/lib/pry/plugins.rb +0 -103
- data/lib/pry/rbx_path.rb +0 -22
- data/lib/pry/rubygem.rb +0 -82
- data/lib/pry/terminal.rb +0 -79
- data/lib/pry/test/helper.rb +0 -170
@@ -1,26 +1,51 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Pry
|
4
|
+
class Command
|
5
|
+
class ChangePrompt < Pry::ClassCommand
|
6
|
+
match 'change-prompt'
|
7
|
+
group 'Input and Output'
|
8
|
+
description 'Change the current prompt.'
|
9
|
+
command_options argument_required: true
|
10
|
+
banner <<-BANNER
|
11
|
+
Usage: change-prompt [OPTIONS] [NAME]
|
12
|
+
|
13
|
+
Change the current prompt.
|
14
|
+
BANNER
|
15
|
+
|
16
|
+
def options(opt)
|
17
|
+
opt.on(:l, :list, 'List the available prompts')
|
18
|
+
end
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
def process(prompt)
|
21
|
+
if opts.present?(:l)
|
22
|
+
list_prompts
|
23
|
+
else
|
24
|
+
change_prompt(prompt)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def list_prompts
|
31
|
+
prompts = Pry::Prompt.all.map do |name, prompt|
|
32
|
+
"#{bold(name)}#{red(' (selected)') if pry_instance.prompt == prompt}\n" +
|
33
|
+
prompt.description
|
34
|
+
end
|
35
|
+
output.puts(prompts.join("\n" * 2))
|
36
|
+
end
|
37
|
+
|
38
|
+
def change_prompt(prompt)
|
39
|
+
if Pry::Prompt[prompt]
|
40
|
+
pry_instance.prompt = Pry::Prompt[prompt]
|
41
|
+
else
|
42
|
+
raise Pry::CommandError,
|
43
|
+
"'#{prompt}' isn't a known prompt. Run `change-prompt --list` " \
|
44
|
+
"to see the list of known prompts."
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
Pry::Commands.add_command(self)
|
49
|
+
end
|
24
50
|
end
|
25
|
-
Pry::Commands.add_command(self)
|
26
51
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Pry
|
4
|
+
class Command
|
5
|
+
class ClearScreen < Pry::ClassCommand
|
6
|
+
match 'clear-screen'
|
7
|
+
group 'Input and Output'
|
8
|
+
description 'Clear the contents of the screen/window Pry is running in.'
|
9
|
+
|
10
|
+
def process
|
11
|
+
if Pry::Helpers::Platform.windows?
|
12
|
+
pry_instance.config.system.call(pry_instance.output, 'cls', pry_instance)
|
13
|
+
else
|
14
|
+
pry_instance.config.system.call(pry_instance.output, 'clear', pry_instance)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
Pry::Commands.add_command(self)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -1,164 +1,181 @@
|
|
1
|
-
|
2
|
-
class Command::CodeCollector
|
3
|
-
include Helpers::CommandHelpers
|
4
|
-
|
5
|
-
attr_reader :args
|
6
|
-
attr_reader :opts
|
7
|
-
attr_reader :_pry_
|
1
|
+
# frozen_string_literal: true
|
8
2
|
|
9
|
-
|
10
|
-
|
3
|
+
class Pry
|
4
|
+
class Command
|
5
|
+
class CodeCollector
|
6
|
+
include Helpers::CommandHelpers
|
11
7
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
end
|
8
|
+
attr_reader :args
|
9
|
+
attr_reader :opts
|
10
|
+
attr_reader :pry_instance
|
16
11
|
|
17
|
-
|
18
|
-
|
12
|
+
# The name of the explicitly given file (if any).
|
13
|
+
attr_accessor :file
|
19
14
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
15
|
+
class << self
|
16
|
+
attr_accessor :input_expression_ranges
|
17
|
+
attr_accessor :output_result_ranges
|
18
|
+
end
|
25
19
|
|
26
|
-
# Add the `--lines`, `-o`, `-i`, `-s`, `-d` options.
|
27
|
-
def self.inject_options(opt)
|
28
20
|
@input_expression_ranges = []
|
29
21
|
@output_result_ranges = []
|
30
22
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
output_result_ranges << (r || (-5..-1))
|
23
|
+
def initialize(args, opts, pry_instance)
|
24
|
+
@args = args
|
25
|
+
@opts = opts
|
26
|
+
@pry_instance = pry_instance
|
36
27
|
end
|
37
|
-
|
38
|
-
|
39
|
-
|
28
|
+
|
29
|
+
# Add the `--lines`, `-o`, `-i`, `-s`, `-d` options.
|
30
|
+
def self.inject_options(opt)
|
31
|
+
@input_expression_ranges = []
|
32
|
+
@output_result_ranges = []
|
33
|
+
|
34
|
+
opt.on :l, :lines, "Restrict to a subset of lines. Takes a line number " \
|
35
|
+
"or range",
|
36
|
+
optional_argument: true, as: Range, default: 1..-1
|
37
|
+
opt.on :o, :out, "Select lines from Pry's output result history. " \
|
38
|
+
"Takes an index or range",
|
39
|
+
optional_argument: true, as: Range, default: -5..-1 do |r|
|
40
|
+
output_result_ranges << (r || (-5..-1))
|
41
|
+
end
|
42
|
+
opt.on :i, :in, "Select lines from Pry's input expression history. " \
|
43
|
+
"Takes an index or range",
|
44
|
+
optional_argument: true, as: Range, default: -5..-1 do |r|
|
45
|
+
input_expression_ranges << (r || (-5..-1))
|
46
|
+
end
|
47
|
+
opt.on :s, :super, "Select the 'super' method. Can be repeated to " \
|
48
|
+
"traverse the ancestors",
|
49
|
+
as: :count
|
50
|
+
opt.on :d, :doc, "Select lines from the code object's documentation"
|
40
51
|
end
|
41
|
-
opt.on :s, :super, "Select the 'super' method. Can be repeated to traverse the ancestors",
|
42
|
-
:as => :count
|
43
|
-
opt.on :d, :doc, "Select lines from the code object's documentation"
|
44
|
-
end
|
45
52
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
53
|
+
# The content (i.e code/docs) for the selected object.
|
54
|
+
# If the user provided a bare code object, it returns the source.
|
55
|
+
# If the user provided the `-i` or `-o` switches, it returns the
|
56
|
+
# selected input/output lines joined as a string. If the user used
|
57
|
+
# `-d CODE_OBJECT` it returns the docs for that code object.
|
58
|
+
#
|
59
|
+
# @return [String]
|
60
|
+
def content
|
61
|
+
@content ||=
|
62
|
+
begin
|
63
|
+
if bad_option_combination?
|
64
|
+
raise CommandError,
|
65
|
+
"Only one of --out, --in, --doc and CODE_OBJECT may " \
|
66
|
+
"be specified."
|
67
|
+
end
|
68
|
+
|
69
|
+
content = if opts.present?(:o)
|
70
|
+
pry_output_content
|
71
|
+
elsif opts.present?(:i)
|
72
|
+
pry_input_content
|
73
|
+
elsif opts.present?(:d)
|
74
|
+
code_object_doc
|
75
|
+
else
|
76
|
+
code_object_source_or_file
|
77
|
+
end
|
78
|
+
|
79
|
+
restrict_to_lines(content, line_range)
|
80
|
+
end
|
81
|
+
end
|
70
82
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
83
|
+
# The code object
|
84
|
+
#
|
85
|
+
# @return [Pry::WrappedModule, Pry::Method, Pry::Command]
|
86
|
+
def code_object
|
87
|
+
Pry::CodeObject.lookup(obj_name, pry_instance, super: opts[:super])
|
88
|
+
end
|
77
89
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
90
|
+
# Given a string and a range, return the `range` lines of that
|
91
|
+
# string.
|
92
|
+
#
|
93
|
+
# @param [String] content
|
94
|
+
# @param [Range, Fixnum] range
|
95
|
+
# @return [String] The string restricted to the given range
|
96
|
+
def restrict_to_lines(content, range)
|
97
|
+
Array(content.lines.to_a[range]).join
|
98
|
+
end
|
87
99
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
100
|
+
# The selected `pry_instance.output_ring` as a string, as specified by
|
101
|
+
# the `-o` switch.
|
102
|
+
#
|
103
|
+
# @return [String]
|
104
|
+
def pry_output_content
|
105
|
+
pry_array_content_as_string(
|
106
|
+
pry_instance.output_ring,
|
107
|
+
self.class.output_result_ranges,
|
108
|
+
&:pretty_inspect
|
109
|
+
)
|
95
110
|
end
|
96
|
-
end
|
97
111
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
112
|
+
# The selected `pry_instance.input_ring` as a string, as specified by
|
113
|
+
# the `-i` switch.
|
114
|
+
#
|
115
|
+
# @return [String]
|
116
|
+
def pry_input_content
|
117
|
+
pry_array_content_as_string(
|
118
|
+
pry_instance.input_ring, self.class.input_expression_ranges
|
119
|
+
) { |v| v }
|
120
|
+
end
|
105
121
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
122
|
+
# The line range passed to `--lines`, converted to a 0-indexed range.
|
123
|
+
def line_range
|
124
|
+
opts.present?(:lines) ? one_index_range_or_number(opts[:lines]) : 0..-1
|
125
|
+
end
|
110
126
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
127
|
+
# Name of the object argument
|
128
|
+
def obj_name
|
129
|
+
@obj_name ||= args.empty? ? "" : args.join(" ")
|
130
|
+
end
|
115
131
|
|
116
|
-
|
132
|
+
private
|
117
133
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
134
|
+
def bad_option_combination?
|
135
|
+
[opts.present?(:in), opts.present?(:out),
|
136
|
+
!args.empty?].count(true) > 1
|
137
|
+
end
|
138
|
+
|
139
|
+
def pry_array_content_as_string(array, ranges)
|
140
|
+
all = ''
|
141
|
+
ranges.each do |range|
|
142
|
+
if convert_to_range(range).first == 0
|
143
|
+
raise CommandError, "Minimum value for range is 1, not 0."
|
144
|
+
end
|
122
145
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
raise CommandError, "Minimum value for range is 1, not 0." if convert_to_range(range).first == 0
|
146
|
+
ranged_array = Array(array[range]) || []
|
147
|
+
ranged_array.compact.each { |v| all += yield(v) }
|
148
|
+
end
|
127
149
|
|
128
|
-
|
129
|
-
ranged_array.compact.each { |v| all << block.call(v) }
|
150
|
+
all
|
130
151
|
end
|
131
152
|
|
132
|
-
|
133
|
-
|
153
|
+
def code_object_doc
|
154
|
+
(code_object && code_object.doc) || could_not_locate(obj_name)
|
155
|
+
end
|
134
156
|
|
135
|
-
|
136
|
-
|
137
|
-
|
157
|
+
def code_object_source_or_file
|
158
|
+
(code_object && code_object.source) || file_content
|
159
|
+
end
|
138
160
|
|
139
|
-
|
140
|
-
|
141
|
-
|
161
|
+
def file_content
|
162
|
+
if File.exist?(obj_name)
|
163
|
+
# Set the file accessor.
|
164
|
+
self.file = obj_name
|
165
|
+
File.read(obj_name)
|
166
|
+
else
|
167
|
+
could_not_locate(obj_name)
|
168
|
+
end
|
169
|
+
end
|
142
170
|
|
143
|
-
|
144
|
-
|
145
|
-
# Set the file accessor.
|
146
|
-
self.file = obj_name
|
147
|
-
File.read(obj_name)
|
148
|
-
else
|
149
|
-
could_not_locate(obj_name)
|
171
|
+
def could_not_locate(name)
|
172
|
+
raise CommandError, "Cannot locate: #{name}!"
|
150
173
|
end
|
151
|
-
end
|
152
174
|
|
153
|
-
|
154
|
-
|
155
|
-
end
|
175
|
+
def convert_to_range(range)
|
176
|
+
return range if range.is_a?(Range)
|
156
177
|
|
157
|
-
|
158
|
-
if !n.is_a?(Range)
|
159
|
-
(n..n)
|
160
|
-
else
|
161
|
-
n
|
178
|
+
(range..range)
|
162
179
|
end
|
163
180
|
end
|
164
181
|
end
|
@@ -1,27 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Pry
|
2
|
-
class Command
|
3
|
-
|
4
|
-
|
5
|
-
|
4
|
+
class Command
|
5
|
+
class DisablePry < Pry::ClassCommand
|
6
|
+
match 'disable-pry'
|
7
|
+
group 'Navigating Pry'
|
8
|
+
description 'Stops all future calls to pry and exits the current session.'
|
6
9
|
|
7
|
-
|
8
|
-
|
10
|
+
banner <<-'BANNER'
|
11
|
+
Usage: disable-pry
|
9
12
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
13
|
+
After this command is run any further calls to pry will immediately return `nil`
|
14
|
+
without interrupting the flow of your program. This is particularly useful when
|
15
|
+
you've debugged the problem you were having, and now wish the program to run to
|
16
|
+
the end.
|
14
17
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
18
|
+
As alternatives, consider using `exit!` to force the current Ruby process
|
19
|
+
to quit immediately; or using `edit -p` to remove the `binding.pry`
|
20
|
+
from the code.
|
21
|
+
BANNER
|
19
22
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
+
def process
|
24
|
+
ENV['DISABLE_PRY'] = 'true'
|
25
|
+
pry_instance.run_command "exit"
|
26
|
+
end
|
23
27
|
end
|
24
|
-
end
|
25
28
|
|
26
|
-
|
29
|
+
Pry::Commands.add_command(Pry::Command::DisablePry)
|
30
|
+
end
|
27
31
|
end
|
@@ -1,26 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Pry
|
2
4
|
Pry::Commands.instance_eval do
|
3
|
-
command
|
4
|
-
run ".nyancat"
|
5
|
-
end
|
6
|
-
|
7
|
-
command(/!s\/(.*?)\/(.*?)/, "") do |source, dest|
|
5
|
+
command(%r{!s/(.*?)/(.*?)}, "") do |source, dest|
|
8
6
|
eval_string.gsub!(/#{source}/) { dest }
|
9
7
|
run "show-input"
|
10
8
|
end
|
11
9
|
|
12
|
-
command "get-naked", "" do
|
13
|
-
text = %{
|
14
|
-
--
|
15
|
-
We dont have to take our clothes off to have a good time.
|
16
|
-
We could dance & party all night And drink some cherry wine.
|
17
|
-
-- Jermaine Stewart }
|
18
|
-
output.puts text
|
19
|
-
text
|
20
|
-
end
|
21
|
-
|
22
10
|
command "east-coker", "" do
|
23
|
-
|
11
|
+
txt = %(
|
24
12
|
--
|
25
13
|
Now the light falls
|
26
14
|
Across the open field, leaving the deep lane
|
@@ -33,13 +21,13 @@ class Pry
|
|
33
21
|
The dahlias sleep in the empty silence.
|
34
22
|
Wait for the early owl.
|
35
23
|
-- T.S Eliot
|
36
|
-
|
37
|
-
output.puts
|
38
|
-
|
24
|
+
)
|
25
|
+
output.puts txt
|
26
|
+
txt
|
39
27
|
end
|
40
28
|
|
41
29
|
command "cohen-poem", "" do
|
42
|
-
|
30
|
+
txt = %(
|
43
31
|
--
|
44
32
|
When this American woman,
|
45
33
|
whose thighs are bound in casual red cloth,
|
@@ -56,9 +44,9 @@ class Pry
|
|
56
44
|
that if you turn your head
|
57
45
|
they are lost for hours.
|
58
46
|
-- Leonard Cohen
|
59
|
-
|
60
|
-
output.puts
|
61
|
-
|
47
|
+
)
|
48
|
+
output.puts txt
|
49
|
+
txt
|
62
50
|
end
|
63
51
|
|
64
52
|
command "pessoa-poem", "" do
|
@@ -79,34 +67,35 @@ class Pry
|
|
79
67
|
O abstract hunger for things, impotent libido for moments,
|
80
68
|
Intellectual orgy of feeling life!
|
81
69
|
-- Fernando Pessoa
|
82
|
-
TEXT
|
70
|
+
TEXT
|
83
71
|
end
|
84
72
|
|
85
73
|
command "test-ansi", "" do
|
86
|
-
prev_color =
|
87
|
-
|
74
|
+
prev_color = pry_instance.config.color
|
75
|
+
pry_instance.config.color = true
|
88
76
|
|
89
|
-
picture = unindent <<-'
|
77
|
+
picture = unindent <<-'OUTPUT'.gsub(/[[:alpha:]!]/) { |s| red(s) }
|
90
78
|
____ _______________________
|
91
79
|
/ \ | A W G |
|
92
80
|
/ O O \ | N I O N ! |
|
93
81
|
| | | S S R I ! |
|
94
82
|
\ \__/ / __| I K ! |
|
95
83
|
\____/ \________________________|
|
96
|
-
|
84
|
+
OUTPUT
|
97
85
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
86
|
+
move_up =
|
87
|
+
if Helpers::Platform.windows_ansi?
|
88
|
+
proc { |n| "\e[#{n}F" }
|
89
|
+
else
|
90
|
+
proc { |n| "\e[#{n}A\e[0G" }
|
91
|
+
end
|
103
92
|
|
104
93
|
output.puts "\n" * 6
|
105
94
|
output.puts picture.lines.map(&:chomp).reverse.join(move_up[1])
|
106
95
|
output.puts "\n" * 6
|
107
96
|
output.puts "** ENV['TERM'] is #{ENV['TERM']} **\n\n"
|
108
97
|
|
109
|
-
|
98
|
+
pry_instance.config.color = prev_color
|
110
99
|
end
|
111
100
|
end
|
112
101
|
end
|
@@ -1,24 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Pry
|
2
|
-
class Command
|
3
|
-
class
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
class Command
|
5
|
+
class Edit
|
6
|
+
class ExceptionPatcher
|
7
|
+
attr_accessor :pry_instance
|
8
|
+
attr_accessor :state
|
9
|
+
attr_accessor :file_and_line
|
7
10
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
def initialize(pry_instance, state, exception_file_and_line)
|
12
|
+
@pry_instance = pry_instance
|
13
|
+
@state = state
|
14
|
+
@file_and_line = exception_file_and_line
|
15
|
+
end
|
13
16
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
17
|
+
# perform the patch
|
18
|
+
def perform_patch
|
19
|
+
file_name, = file_and_line
|
20
|
+
lines = state.dynamical_ex_file || File.read(file_name)
|
18
21
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
+
source = Pry::Editor.new(pry_instance).edit_tempfile_with_content(lines)
|
23
|
+
pry_instance.evaluate_ruby source
|
24
|
+
state.dynamical_ex_file = source.split("\n")
|
25
|
+
end
|
22
26
|
end
|
23
27
|
end
|
24
28
|
end
|