pry 0.10.3 → 0.12.2
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 +4 -4
- data/CHANGELOG.md +251 -16
- data/LICENSE +1 -1
- data/README.md +35 -51
- data/bin/pry +3 -11
- data/lib/pry/basic_object.rb +6 -0
- data/lib/pry/cli.rb +50 -52
- data/lib/pry/code/code_file.rb +13 -6
- data/lib/pry/code/code_range.rb +3 -3
- data/lib/pry/code/loc.rb +14 -8
- data/lib/pry/code.rb +12 -5
- data/lib/pry/code_object.rb +27 -4
- data/lib/pry/color_printer.rb +20 -10
- data/lib/pry/command.rb +76 -45
- data/lib/pry/command_set.rb +17 -45
- data/lib/pry/commands/amend_line.rb +3 -4
- data/lib/pry/commands/bang.rb +1 -1
- data/lib/pry/commands/cat/exception_formatter.rb +10 -8
- data/lib/pry/commands/cat/file_formatter.rb +7 -3
- data/lib/pry/commands/cat/input_expression_formatter.rb +1 -1
- data/lib/pry/commands/cat.rb +7 -6
- data/lib/pry/commands/change_prompt.rb +29 -9
- data/lib/pry/commands/clear_screen.rb +14 -0
- data/lib/pry/commands/code_collector.rb +25 -23
- data/lib/pry/commands/easter_eggs.rb +12 -12
- data/lib/pry/commands/edit/file_and_line_locator.rb +1 -1
- data/lib/pry/commands/edit.rb +15 -10
- data/lib/pry/commands/exit.rb +2 -1
- data/lib/pry/commands/find_method.rb +12 -14
- data/lib/pry/commands/gem_cd.rb +1 -1
- data/lib/pry/commands/gem_install.rb +2 -2
- data/lib/pry/commands/gem_list.rb +2 -2
- data/lib/pry/commands/gem_open.rb +2 -2
- data/lib/pry/commands/gem_readme.rb +25 -0
- data/lib/pry/commands/gem_search.rb +40 -0
- data/lib/pry/commands/gem_stats.rb +83 -0
- data/lib/pry/commands/gist.rb +7 -6
- data/lib/pry/commands/help.rb +3 -3
- data/lib/pry/commands/hist.rb +11 -10
- data/lib/pry/commands/import_set.rb +2 -1
- data/lib/pry/commands/install_command.rb +7 -6
- data/lib/pry/commands/jump_to.rb +7 -7
- data/lib/pry/commands/list_inspectors.rb +2 -2
- data/lib/pry/commands/ls/constants.rb +14 -3
- data/lib/pry/commands/ls/formatter.rb +4 -2
- data/lib/pry/commands/ls/globals.rb +0 -2
- data/lib/pry/commands/ls/grep.rb +0 -2
- data/lib/pry/commands/ls/instance_vars.rb +0 -1
- data/lib/pry/commands/ls/jruby_hacks.rb +2 -2
- data/lib/pry/commands/ls/local_names.rb +0 -2
- data/lib/pry/commands/ls/local_vars.rb +0 -2
- data/lib/pry/commands/ls/ls_entity.rb +0 -1
- data/lib/pry/commands/ls/methods.rb +0 -3
- data/lib/pry/commands/ls/methods_helper.rb +1 -1
- data/lib/pry/commands/ls/self_methods.rb +2 -1
- data/lib/pry/commands/ls.rb +30 -31
- data/lib/pry/commands/play.rb +3 -4
- data/lib/pry/commands/pry_backtrace.rb +1 -1
- data/lib/pry/commands/raise_up.rb +2 -1
- data/lib/pry/commands/reload_code.rb +2 -2
- data/lib/pry/commands/ri.rb +9 -4
- data/lib/pry/commands/shell_command.rb +36 -9
- data/lib/pry/commands/shell_mode.rb +6 -6
- data/lib/pry/commands/show_doc.rb +5 -7
- data/lib/pry/commands/show_info.rb +41 -20
- data/lib/pry/commands/show_source.rb +5 -2
- data/lib/pry/commands/stat.rb +1 -1
- data/lib/pry/commands/watch_expression/expression.rb +1 -1
- data/lib/pry/commands/watch_expression.rb +9 -7
- data/lib/pry/commands/whereami.rb +16 -9
- data/lib/pry/commands/wtf.rb +15 -2
- data/lib/pry/config/behavior.rb +230 -114
- data/lib/pry/config/convenience.rb +24 -21
- data/lib/pry/config/default.rb +151 -153
- data/lib/pry/config/memoization.rb +48 -0
- data/lib/pry/config.rb +30 -19
- data/lib/pry/core_extensions.rb +15 -4
- data/lib/pry/editor.rb +5 -12
- data/lib/pry/exceptions.rb +1 -3
- data/lib/pry/forwardable.rb +23 -0
- data/lib/pry/helpers/base_helpers.rb +197 -110
- data/lib/pry/helpers/command_helpers.rb +5 -4
- data/lib/pry/helpers/documentation_helpers.rb +3 -2
- data/lib/pry/helpers/options_helpers.rb +6 -6
- data/lib/pry/helpers/platform.rb +58 -0
- data/lib/pry/helpers/table.rb +20 -15
- data/lib/pry/helpers/text.rb +82 -74
- data/lib/pry/helpers.rb +1 -0
- data/lib/pry/history.rb +44 -10
- data/lib/pry/hooks.rb +50 -109
- data/lib/pry/indent.rb +21 -19
- data/lib/pry/input_completer.rb +146 -123
- data/lib/pry/input_lock.rb +0 -2
- data/lib/pry/last_exception.rb +2 -2
- data/lib/pry/method/disowned.rb +3 -1
- data/lib/pry/method/patcher.rb +2 -5
- data/lib/pry/method/weird_method_locator.rb +21 -11
- data/lib/pry/method.rb +44 -38
- data/lib/pry/object_path.rb +5 -4
- data/lib/pry/output.rb +37 -37
- data/lib/pry/pager.rb +195 -181
- data/lib/pry/platform.rb +91 -0
- data/lib/pry/plugins.rb +27 -8
- data/lib/pry/prompt.rb +144 -25
- data/lib/pry/pry_class.rb +83 -33
- data/lib/pry/pry_instance.rb +94 -59
- data/lib/pry/repl.rb +70 -11
- data/lib/pry/repl_file_loader.rb +2 -3
- data/lib/pry/ring.rb +84 -0
- data/lib/pry/rubygem.rb +9 -7
- data/lib/pry/slop/LICENSE +20 -0
- data/lib/pry/slop/commands.rb +195 -0
- data/lib/pry/slop/option.rb +206 -0
- data/lib/pry/slop.rb +661 -0
- data/lib/pry/terminal.rb +18 -6
- data/lib/pry/testable/evalable.rb +15 -0
- data/lib/pry/testable/mockable.rb +14 -0
- data/lib/pry/testable/pry_tester.rb +73 -0
- data/lib/pry/testable/utility.rb +26 -0
- data/lib/pry/testable/variables.rb +46 -0
- data/lib/pry/testable.rb +70 -0
- data/lib/pry/version.rb +1 -1
- data/lib/pry/{module_candidate.rb → wrapped_module/candidate.rb} +9 -14
- data/lib/pry/wrapped_module.rb +22 -21
- data/lib/pry.rb +21 -50
- metadata +35 -46
- data/lib/pry/commands/list_prompts.rb +0 -35
- data/lib/pry/commands/simple_prompt.rb +0 -22
- data/lib/pry/history_array.rb +0 -121
- data/lib/pry/rbx_path.rb +0 -22
- data/lib/pry/test/helper.rb +0 -170
metadata
CHANGED
@@ -1,78 +1,52 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Mair (banisterfiend)
|
8
8
|
- Conrad Irwin
|
9
9
|
- Ryan Fitzgerald
|
10
|
+
- Kyrylo Silin
|
10
11
|
autorequire:
|
11
12
|
bindir: bin
|
12
13
|
cert_chain: []
|
13
|
-
date:
|
14
|
+
date: 2018-11-12 00:00:00.000000000 Z
|
14
15
|
dependencies:
|
15
16
|
- !ruby/object:Gem::Dependency
|
16
17
|
name: coderay
|
17
18
|
requirement: !ruby/object:Gem::Requirement
|
18
19
|
requirements:
|
19
|
-
- - ~>
|
20
|
+
- - "~>"
|
20
21
|
- !ruby/object:Gem::Version
|
21
22
|
version: 1.1.0
|
22
23
|
type: :runtime
|
23
24
|
prerelease: false
|
24
25
|
version_requirements: !ruby/object:Gem::Requirement
|
25
26
|
requirements:
|
26
|
-
- - ~>
|
27
|
+
- - "~>"
|
27
28
|
- !ruby/object:Gem::Version
|
28
29
|
version: 1.1.0
|
29
|
-
- !ruby/object:Gem::Dependency
|
30
|
-
name: slop
|
31
|
-
requirement: !ruby/object:Gem::Requirement
|
32
|
-
requirements:
|
33
|
-
- - ~>
|
34
|
-
- !ruby/object:Gem::Version
|
35
|
-
version: '3.4'
|
36
|
-
type: :runtime
|
37
|
-
prerelease: false
|
38
|
-
version_requirements: !ruby/object:Gem::Requirement
|
39
|
-
requirements:
|
40
|
-
- - ~>
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
version: '3.4'
|
43
30
|
- !ruby/object:Gem::Dependency
|
44
31
|
name: method_source
|
45
32
|
requirement: !ruby/object:Gem::Requirement
|
46
33
|
requirements:
|
47
|
-
- - ~>
|
34
|
+
- - "~>"
|
48
35
|
- !ruby/object:Gem::Version
|
49
|
-
version: 0.
|
36
|
+
version: 0.9.0
|
50
37
|
type: :runtime
|
51
38
|
prerelease: false
|
52
39
|
version_requirements: !ruby/object:Gem::Requirement
|
53
40
|
requirements:
|
54
|
-
- - ~>
|
41
|
+
- - "~>"
|
55
42
|
- !ruby/object:Gem::Version
|
56
|
-
version: 0.
|
57
|
-
- !ruby/object:Gem::Dependency
|
58
|
-
name: bundler
|
59
|
-
requirement: !ruby/object:Gem::Requirement
|
60
|
-
requirements:
|
61
|
-
- - ~>
|
62
|
-
- !ruby/object:Gem::Version
|
63
|
-
version: '1.0'
|
64
|
-
type: :development
|
65
|
-
prerelease: false
|
66
|
-
version_requirements: !ruby/object:Gem::Requirement
|
67
|
-
requirements:
|
68
|
-
- - ~>
|
69
|
-
- !ruby/object:Gem::Version
|
70
|
-
version: '1.0'
|
43
|
+
version: 0.9.0
|
71
44
|
description: An IRB alternative and runtime developer console
|
72
45
|
email:
|
73
46
|
- jrmair@gmail.com
|
74
47
|
- conrad.irwin@gmail.com
|
75
48
|
- rwfitzge@gmail.com
|
49
|
+
- silin@kyrylo.org
|
76
50
|
executables:
|
77
51
|
- pry
|
78
52
|
extensions: []
|
@@ -83,6 +57,7 @@ files:
|
|
83
57
|
- README.md
|
84
58
|
- bin/pry
|
85
59
|
- lib/pry.rb
|
60
|
+
- lib/pry/basic_object.rb
|
86
61
|
- lib/pry/cli.rb
|
87
62
|
- lib/pry/code.rb
|
88
63
|
- lib/pry/code/code_file.rb
|
@@ -104,6 +79,7 @@ files:
|
|
104
79
|
- lib/pry/commands/cd.rb
|
105
80
|
- lib/pry/commands/change_inspector.rb
|
106
81
|
- lib/pry/commands/change_prompt.rb
|
82
|
+
- lib/pry/commands/clear_screen.rb
|
107
83
|
- lib/pry/commands/code_collector.rb
|
108
84
|
- lib/pry/commands/disable_pry.rb
|
109
85
|
- lib/pry/commands/disabled_commands.rb
|
@@ -120,6 +96,9 @@ files:
|
|
120
96
|
- lib/pry/commands/gem_install.rb
|
121
97
|
- lib/pry/commands/gem_list.rb
|
122
98
|
- lib/pry/commands/gem_open.rb
|
99
|
+
- lib/pry/commands/gem_readme.rb
|
100
|
+
- lib/pry/commands/gem_search.rb
|
101
|
+
- lib/pry/commands/gem_stats.rb
|
123
102
|
- lib/pry/commands/gist.rb
|
124
103
|
- lib/pry/commands/help.rb
|
125
104
|
- lib/pry/commands/hist.rb
|
@@ -127,7 +106,6 @@ files:
|
|
127
106
|
- lib/pry/commands/install_command.rb
|
128
107
|
- lib/pry/commands/jump_to.rb
|
129
108
|
- lib/pry/commands/list_inspectors.rb
|
130
|
-
- lib/pry/commands/list_prompts.rb
|
131
109
|
- lib/pry/commands/ls.rb
|
132
110
|
- lib/pry/commands/ls/constants.rb
|
133
111
|
- lib/pry/commands/ls/formatter.rb
|
@@ -157,7 +135,6 @@ files:
|
|
157
135
|
- lib/pry/commands/show_info.rb
|
158
136
|
- lib/pry/commands/show_input.rb
|
159
137
|
- lib/pry/commands/show_source.rb
|
160
|
-
- lib/pry/commands/simple_prompt.rb
|
161
138
|
- lib/pry/commands/stat.rb
|
162
139
|
- lib/pry/commands/switch_to.rb
|
163
140
|
- lib/pry/commands/toggle_color.rb
|
@@ -169,18 +146,20 @@ files:
|
|
169
146
|
- lib/pry/config/behavior.rb
|
170
147
|
- lib/pry/config/convenience.rb
|
171
148
|
- lib/pry/config/default.rb
|
149
|
+
- lib/pry/config/memoization.rb
|
172
150
|
- lib/pry/core_extensions.rb
|
173
151
|
- lib/pry/editor.rb
|
174
152
|
- lib/pry/exceptions.rb
|
153
|
+
- lib/pry/forwardable.rb
|
175
154
|
- lib/pry/helpers.rb
|
176
155
|
- lib/pry/helpers/base_helpers.rb
|
177
156
|
- lib/pry/helpers/command_helpers.rb
|
178
157
|
- lib/pry/helpers/documentation_helpers.rb
|
179
158
|
- lib/pry/helpers/options_helpers.rb
|
159
|
+
- lib/pry/helpers/platform.rb
|
180
160
|
- lib/pry/helpers/table.rb
|
181
161
|
- lib/pry/helpers/text.rb
|
182
162
|
- lib/pry/history.rb
|
183
|
-
- lib/pry/history_array.rb
|
184
163
|
- lib/pry/hooks.rb
|
185
164
|
- lib/pry/indent.rb
|
186
165
|
- lib/pry/input_completer.rb
|
@@ -191,22 +170,32 @@ files:
|
|
191
170
|
- lib/pry/method/disowned.rb
|
192
171
|
- lib/pry/method/patcher.rb
|
193
172
|
- lib/pry/method/weird_method_locator.rb
|
194
|
-
- lib/pry/module_candidate.rb
|
195
173
|
- lib/pry/object_path.rb
|
196
174
|
- lib/pry/output.rb
|
197
175
|
- lib/pry/pager.rb
|
176
|
+
- lib/pry/platform.rb
|
198
177
|
- lib/pry/plugins.rb
|
199
178
|
- lib/pry/prompt.rb
|
200
179
|
- lib/pry/pry_class.rb
|
201
180
|
- lib/pry/pry_instance.rb
|
202
|
-
- lib/pry/rbx_path.rb
|
203
181
|
- lib/pry/repl.rb
|
204
182
|
- lib/pry/repl_file_loader.rb
|
183
|
+
- lib/pry/ring.rb
|
205
184
|
- lib/pry/rubygem.rb
|
185
|
+
- lib/pry/slop.rb
|
186
|
+
- lib/pry/slop/LICENSE
|
187
|
+
- lib/pry/slop/commands.rb
|
188
|
+
- lib/pry/slop/option.rb
|
206
189
|
- lib/pry/terminal.rb
|
207
|
-
- lib/pry/
|
190
|
+
- lib/pry/testable.rb
|
191
|
+
- lib/pry/testable/evalable.rb
|
192
|
+
- lib/pry/testable/mockable.rb
|
193
|
+
- lib/pry/testable/pry_tester.rb
|
194
|
+
- lib/pry/testable/utility.rb
|
195
|
+
- lib/pry/testable/variables.rb
|
208
196
|
- lib/pry/version.rb
|
209
197
|
- lib/pry/wrapped_module.rb
|
198
|
+
- lib/pry/wrapped_module/candidate.rb
|
210
199
|
homepage: http://pryrepl.org
|
211
200
|
licenses:
|
212
201
|
- MIT
|
@@ -217,17 +206,17 @@ require_paths:
|
|
217
206
|
- lib
|
218
207
|
required_ruby_version: !ruby/object:Gem::Requirement
|
219
208
|
requirements:
|
220
|
-
- -
|
209
|
+
- - ">="
|
221
210
|
- !ruby/object:Gem::Version
|
222
|
-
version:
|
211
|
+
version: 1.9.3
|
223
212
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
224
213
|
requirements:
|
225
|
-
- -
|
214
|
+
- - ">="
|
226
215
|
- !ruby/object:Gem::Version
|
227
216
|
version: '0'
|
228
217
|
requirements: []
|
229
218
|
rubyforge_project:
|
230
|
-
rubygems_version: 2.
|
219
|
+
rubygems_version: 2.6.13
|
231
220
|
signing_key:
|
232
221
|
specification_version: 4
|
233
222
|
summary: An IRB alternative and runtime developer console
|
@@ -1,35 +0,0 @@
|
|
1
|
-
class Pry::Command::ListPrompts < Pry::ClassCommand
|
2
|
-
match 'list-prompts'
|
3
|
-
group 'Input and Output'
|
4
|
-
description 'List the prompts available for use.'
|
5
|
-
banner <<-BANNER
|
6
|
-
Usage: list-prompts
|
7
|
-
|
8
|
-
List the available prompts. You can use change-prompt to switch between
|
9
|
-
them.
|
10
|
-
BANNER
|
11
|
-
|
12
|
-
def process
|
13
|
-
output.puts heading("Available prompts") + "\n"
|
14
|
-
prompt_map.each do |name, prompt|
|
15
|
-
output.write "Name: #{text.bold(name)}"
|
16
|
-
output.puts selected_prompt?(prompt) ? selected_text : ""
|
17
|
-
output.puts prompt[:description]
|
18
|
-
output.puts
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
def prompt_map
|
24
|
-
Pry::Prompt::MAP
|
25
|
-
end
|
26
|
-
|
27
|
-
def selected_text
|
28
|
-
text.red " (selected) "
|
29
|
-
end
|
30
|
-
|
31
|
-
def selected_prompt?(prompt)
|
32
|
-
_pry_.prompt == prompt[:value]
|
33
|
-
end
|
34
|
-
Pry::Commands.add_command(self)
|
35
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
class Pry
|
2
|
-
class Command::SimplePrompt < Pry::ClassCommand
|
3
|
-
match 'simple-prompt'
|
4
|
-
group 'prompts'
|
5
|
-
description 'Toggle the simple prompt.'
|
6
|
-
|
7
|
-
banner <<-'BANNER'
|
8
|
-
Toggle the simple prompt.
|
9
|
-
BANNER
|
10
|
-
|
11
|
-
def process
|
12
|
-
case _pry_.prompt
|
13
|
-
when Pry::SIMPLE_PROMPT
|
14
|
-
_pry_.pop_prompt
|
15
|
-
else
|
16
|
-
_pry_.push_prompt Pry::SIMPLE_PROMPT
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
Pry::Commands.add_command(Pry::Command::SimplePrompt)
|
22
|
-
end
|
data/lib/pry/history_array.rb
DELETED
@@ -1,121 +0,0 @@
|
|
1
|
-
class Pry
|
2
|
-
# A history array is an array to which you can only add elements. Older
|
3
|
-
# entries are removed progressively, so that the array never contains more than
|
4
|
-
# N elements.
|
5
|
-
#
|
6
|
-
# History arrays are used by Pry to store the output of the last commands.
|
7
|
-
#
|
8
|
-
# @example
|
9
|
-
# ary = Pry::HistoryArray.new 10
|
10
|
-
# ary << 1 << 2 << 3
|
11
|
-
# ary[0] # => 1
|
12
|
-
# ary[1] # => 2
|
13
|
-
# 10.times { |n| ary << n }
|
14
|
-
# ary[0] # => nil
|
15
|
-
# ary[-1] # => 9
|
16
|
-
class HistoryArray
|
17
|
-
include Enumerable
|
18
|
-
|
19
|
-
# @param [Integer] size Maximum amount of objects in the array
|
20
|
-
def initialize(size)
|
21
|
-
@max_size = size
|
22
|
-
|
23
|
-
@hash = {}
|
24
|
-
@count = 0
|
25
|
-
end
|
26
|
-
|
27
|
-
# Pushes an object at the end of the array
|
28
|
-
# @param [Object] value Object to be added
|
29
|
-
def <<(value)
|
30
|
-
@hash[@count] = value
|
31
|
-
|
32
|
-
if @hash.size > max_size
|
33
|
-
@hash.delete(@count - max_size)
|
34
|
-
end
|
35
|
-
|
36
|
-
@count += 1
|
37
|
-
|
38
|
-
self
|
39
|
-
end
|
40
|
-
|
41
|
-
# @overload [](index)
|
42
|
-
# @param [Integer] index Index of the item to access.
|
43
|
-
# @return [Object, nil] Item at that index or nil if it has been removed.
|
44
|
-
# @overload [](index, size)
|
45
|
-
# @param [Integer] index Index of the first item to access.
|
46
|
-
# @param [Integer] size Amount of items to access
|
47
|
-
# @return [Array, nil] The selected items. Nil if index is greater than
|
48
|
-
# the size of the array.
|
49
|
-
# @overload [](range)
|
50
|
-
# @param [Range<Integer>] range Range of indices to access.
|
51
|
-
# @return [Array, nil] The selected items. Nil if index is greater than
|
52
|
-
# the size of the array.
|
53
|
-
def [](index_or_range, size = nil)
|
54
|
-
if index_or_range.is_a? Integer
|
55
|
-
index = convert_index(index_or_range)
|
56
|
-
|
57
|
-
if size
|
58
|
-
end_index = index + size
|
59
|
-
index > @count ? nil : (index...[end_index, @count].min).map do |n|
|
60
|
-
@hash[n]
|
61
|
-
end
|
62
|
-
else
|
63
|
-
@hash[index]
|
64
|
-
end
|
65
|
-
else
|
66
|
-
range = convert_range(index_or_range)
|
67
|
-
range.begin > @count ? nil : range.map { |n| @hash[n] }
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
# @return [Integer] Amount of objects in the array
|
72
|
-
def size
|
73
|
-
@count
|
74
|
-
end
|
75
|
-
alias count size
|
76
|
-
alias length size
|
77
|
-
|
78
|
-
def empty?
|
79
|
-
size == 0
|
80
|
-
end
|
81
|
-
|
82
|
-
def each
|
83
|
-
((@count - size)...@count).each do |n|
|
84
|
-
yield @hash[n]
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
def to_a
|
89
|
-
((@count - size)...@count).map { |n| @hash[n] }
|
90
|
-
end
|
91
|
-
|
92
|
-
# Returns [Hash] copy of the internal @hash history
|
93
|
-
def to_h
|
94
|
-
@hash.dup
|
95
|
-
end
|
96
|
-
|
97
|
-
def pop!
|
98
|
-
@hash.delete @count - 1
|
99
|
-
@count -= 1
|
100
|
-
end
|
101
|
-
|
102
|
-
def inspect
|
103
|
-
"#<#{self.class} size=#{size} first=#{@count - size} max_size=#{max_size}>"
|
104
|
-
end
|
105
|
-
|
106
|
-
# @return [Integer] Maximum amount of objects in the array
|
107
|
-
attr_reader :max_size
|
108
|
-
|
109
|
-
private
|
110
|
-
def convert_index(n)
|
111
|
-
n >= 0 ? n : @count + n
|
112
|
-
end
|
113
|
-
|
114
|
-
def convert_range(range)
|
115
|
-
end_index = convert_index(range.end)
|
116
|
-
end_index += 1 unless range.exclude_end?
|
117
|
-
|
118
|
-
Range.new(convert_index(range.begin), [end_index, @count].min, true)
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
data/lib/pry/rbx_path.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
class Pry
|
2
|
-
module RbxPath
|
3
|
-
module_function
|
4
|
-
def is_core_path?(path)
|
5
|
-
Pry::Helpers::BaseHelpers.rbx? && (path.start_with?("kernel") || path.start_with?("lib")) && File.exist?(convert_path_to_full(path))
|
6
|
-
end
|
7
|
-
|
8
|
-
def convert_path_to_full(path)
|
9
|
-
if path.start_with?("kernel")
|
10
|
-
File.join File.dirname(Rubinius::KERNEL_PATH), path
|
11
|
-
elsif path.start_with?("lib")
|
12
|
-
File.join File.dirname(Rubinius::LIB_PATH), path
|
13
|
-
else
|
14
|
-
path
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def rvm_ruby?(path)
|
19
|
-
!!(path =~ /\.rvm/)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
data/lib/pry/test/helper.rb
DELETED
@@ -1,170 +0,0 @@
|
|
1
|
-
require 'pry'
|
2
|
-
|
3
|
-
# in case the tests call reset_defaults, ensure we reset them to
|
4
|
-
# amended (test friendly) values
|
5
|
-
class << Pry
|
6
|
-
alias_method :orig_reset_defaults, :reset_defaults
|
7
|
-
def reset_defaults
|
8
|
-
orig_reset_defaults
|
9
|
-
|
10
|
-
Pry.config.color = false
|
11
|
-
Pry.config.pager = false
|
12
|
-
Pry.config.should_load_rc = false
|
13
|
-
Pry.config.should_load_local_rc= false
|
14
|
-
Pry.config.should_load_plugins = false
|
15
|
-
Pry.config.history.should_load = false
|
16
|
-
Pry.config.history.should_save = false
|
17
|
-
Pry.config.correct_indent = false
|
18
|
-
Pry.config.hooks = Pry::Hooks.new
|
19
|
-
Pry.config.collision_warning = false
|
20
|
-
end
|
21
|
-
end
|
22
|
-
Pry.reset_defaults
|
23
|
-
|
24
|
-
# A global space for storing temporary state during tests.
|
25
|
-
|
26
|
-
module PryTestHelpers
|
27
|
-
|
28
|
-
module_function
|
29
|
-
|
30
|
-
# inject a variable into a binding
|
31
|
-
def inject_var(name, value, b)
|
32
|
-
Pry.current[:pry_local] = value
|
33
|
-
b.eval("#{name} = ::Pry.current[:pry_local]")
|
34
|
-
ensure
|
35
|
-
Pry.current[:pry_local] = nil
|
36
|
-
end
|
37
|
-
|
38
|
-
def constant_scope(*names)
|
39
|
-
names.each do |name|
|
40
|
-
Object.remove_const name if Object.const_defined?(name)
|
41
|
-
end
|
42
|
-
|
43
|
-
yield
|
44
|
-
ensure
|
45
|
-
names.each do |name|
|
46
|
-
Object.remove_const name if Object.const_defined?(name)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
# Open a temp file and yield it to the block, closing it after
|
51
|
-
# @return [String] The path of the temp file
|
52
|
-
def temp_file(ext='.rb')
|
53
|
-
file = Tempfile.new(['pry', ext])
|
54
|
-
yield file
|
55
|
-
ensure
|
56
|
-
file.close(true) if file
|
57
|
-
File.unlink("#{file.path}c") if File.exists?("#{file.path}c") # rbx
|
58
|
-
end
|
59
|
-
|
60
|
-
def unindent(*args)
|
61
|
-
Pry::Helpers::CommandHelpers.unindent(*args)
|
62
|
-
end
|
63
|
-
|
64
|
-
def mock_command(cmd, args=[], opts={})
|
65
|
-
output = StringIO.new
|
66
|
-
pry = Pry.new(output: output)
|
67
|
-
ret = cmd.new(opts.merge(pry_instance: pry, :output => output)).call_safely(*args)
|
68
|
-
Struct.new(:output, :return).new(output.string, ret)
|
69
|
-
end
|
70
|
-
|
71
|
-
def mock_exception(*mock_backtrace)
|
72
|
-
StandardError.new.tap do |e|
|
73
|
-
e.define_singleton_method(:backtrace) { mock_backtrace }
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def pry_tester(*args, &block)
|
79
|
-
if args.length == 0 || args[0].is_a?(Hash)
|
80
|
-
args.unshift(Pry.toplevel_binding)
|
81
|
-
end
|
82
|
-
|
83
|
-
PryTester.new(*args).tap do |t|
|
84
|
-
(class << t; self; end).class_eval(&block) if block
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
def pry_eval(*eval_strs)
|
89
|
-
if eval_strs.first.is_a? String
|
90
|
-
binding = Pry.toplevel_binding
|
91
|
-
else
|
92
|
-
binding = Pry.binding_for(eval_strs.shift)
|
93
|
-
end
|
94
|
-
|
95
|
-
pry_tester(binding).eval(*eval_strs)
|
96
|
-
end
|
97
|
-
|
98
|
-
class PryTester
|
99
|
-
extend Forwardable
|
100
|
-
|
101
|
-
attr_reader :pry, :out
|
102
|
-
|
103
|
-
def_delegators :@pry, :eval_string, :eval_string=
|
104
|
-
|
105
|
-
def initialize(target = TOPLEVEL_BINDING, options = {})
|
106
|
-
@pry = Pry.new(options.merge(:target => target))
|
107
|
-
@history = options[:history]
|
108
|
-
|
109
|
-
@pry.inject_sticky_locals!
|
110
|
-
reset_output
|
111
|
-
end
|
112
|
-
|
113
|
-
def eval(*strs)
|
114
|
-
reset_output
|
115
|
-
result = nil
|
116
|
-
|
117
|
-
strs.flatten.each do |str|
|
118
|
-
str = "#{str.strip}\n"
|
119
|
-
@history.push str if @history
|
120
|
-
|
121
|
-
if @pry.process_command(str)
|
122
|
-
result = last_command_result_or_output
|
123
|
-
else
|
124
|
-
result = @pry.evaluate_ruby(str)
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
result
|
129
|
-
end
|
130
|
-
|
131
|
-
def push(*lines)
|
132
|
-
Array(lines).flatten.each do |line|
|
133
|
-
@pry.eval(line)
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
def push_binding(context)
|
138
|
-
@pry.push_binding context
|
139
|
-
end
|
140
|
-
|
141
|
-
def last_output
|
142
|
-
@out.string if @out
|
143
|
-
end
|
144
|
-
|
145
|
-
def process_command(command_str)
|
146
|
-
@pry.process_command(command_str) or raise "Not a valid command"
|
147
|
-
last_command_result_or_output
|
148
|
-
end
|
149
|
-
|
150
|
-
def last_command_result
|
151
|
-
result = Pry.current[:pry_cmd_result]
|
152
|
-
result.retval if result
|
153
|
-
end
|
154
|
-
|
155
|
-
protected
|
156
|
-
|
157
|
-
def last_command_result_or_output
|
158
|
-
result = last_command_result
|
159
|
-
if result != Pry::Command::VOID_VALUE
|
160
|
-
result
|
161
|
-
else
|
162
|
-
last_output
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
def reset_output
|
167
|
-
@out = StringIO.new
|
168
|
-
@pry.output = @out
|
169
|
-
end
|
170
|
-
end
|