pry 0.10.2-i386-mingw32 → 1.0.0.pre1-i386-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (189) hide show
  1. data/.document +2 -0
  2. data/.gitignore +16 -0
  3. data/.travis.yml +21 -0
  4. data/.yardopts +3 -0
  5. data/CHANGELOG +503 -0
  6. data/CONTRIBUTORS +55 -0
  7. data/Gemfile +9 -0
  8. data/Guardfile +62 -0
  9. data/LICENSE +2 -2
  10. data/{README.md → README.markdown} +31 -37
  11. data/Rakefile +144 -0
  12. data/TODO +117 -0
  13. data/lib/pry.rb +146 -33
  14. data/lib/pry/cli.rb +13 -35
  15. data/lib/pry/code.rb +63 -24
  16. data/lib/pry/code/loc.rb +2 -2
  17. data/lib/pry/code_object.rb +21 -40
  18. data/lib/pry/command.rb +6 -9
  19. data/lib/pry/command_set.rb +37 -80
  20. data/lib/pry/commands.rb +1 -1
  21. data/lib/pry/commands/amend_line.rb +1 -1
  22. data/lib/pry/commands/bang.rb +1 -1
  23. data/lib/pry/commands/cat.rb +2 -11
  24. data/lib/pry/commands/cat/abstract_formatter.rb +1 -1
  25. data/lib/pry/commands/cat/exception_formatter.rb +7 -6
  26. data/lib/pry/commands/cat/file_formatter.rb +32 -15
  27. data/lib/pry/commands/cat/input_expression_formatter.rb +1 -1
  28. data/lib/pry/commands/cd.rb +3 -14
  29. data/lib/pry/commands/code_collector.rb +4 -4
  30. data/lib/pry/commands/easter_eggs.rb +3 -3
  31. data/lib/pry/commands/edit.rb +22 -10
  32. data/lib/pry/commands/edit/exception_patcher.rb +1 -1
  33. data/lib/pry/commands/edit/file_and_line_locator.rb +2 -0
  34. data/lib/pry/{method/patcher.rb → commands/edit/method_patcher.rb} +37 -40
  35. data/lib/pry/commands/find_method.rb +22 -16
  36. data/lib/pry/commands/gem_install.rb +2 -5
  37. data/lib/pry/commands/gem_open.rb +1 -1
  38. data/lib/pry/commands/gist.rb +11 -10
  39. data/lib/pry/commands/help.rb +14 -14
  40. data/lib/pry/commands/hist.rb +5 -24
  41. data/lib/pry/commands/ls.rb +287 -56
  42. data/lib/pry/commands/play.rb +10 -44
  43. data/lib/pry/commands/pry_backtrace.rb +2 -1
  44. data/lib/pry/commands/raise_up.rb +1 -1
  45. data/lib/pry/commands/reload_code.rb +15 -31
  46. data/lib/pry/commands/ri.rb +3 -7
  47. data/lib/pry/commands/shell_command.rb +12 -17
  48. data/lib/pry/commands/shell_mode.rb +2 -2
  49. data/lib/pry/commands/show_doc.rb +0 -5
  50. data/lib/pry/commands/show_info.rb +10 -11
  51. data/lib/pry/commands/show_source.rb +3 -15
  52. data/lib/pry/commands/simple_prompt.rb +1 -1
  53. data/lib/pry/commands/toggle_color.rb +4 -8
  54. data/lib/pry/commands/whereami.rb +10 -18
  55. data/lib/pry/completion.rb +293 -0
  56. data/lib/pry/config.rb +233 -20
  57. data/lib/pry/core_extensions.rb +19 -29
  58. data/lib/pry/custom_completions.rb +6 -0
  59. data/lib/pry/editor.rb +103 -109
  60. data/lib/pry/helpers/base_helpers.rb +109 -22
  61. data/lib/pry/helpers/command_helpers.rb +8 -10
  62. data/lib/pry/helpers/documentation_helpers.rb +2 -1
  63. data/lib/pry/helpers/text.rb +5 -4
  64. data/lib/pry/history.rb +10 -21
  65. data/lib/pry/history_array.rb +0 -5
  66. data/lib/pry/hooks.rb +29 -9
  67. data/lib/pry/indent.rb +10 -5
  68. data/lib/pry/method.rb +86 -81
  69. data/lib/pry/method/weird_method_locator.rb +2 -4
  70. data/lib/pry/module_candidate.rb +14 -5
  71. data/lib/pry/pager.rb +48 -193
  72. data/lib/pry/plugins.rb +2 -2
  73. data/lib/pry/pry_class.rb +193 -104
  74. data/lib/pry/pry_instance.rb +154 -152
  75. data/lib/pry/rbx_method.rb +13 -0
  76. data/lib/pry/rbx_path.rb +1 -1
  77. data/lib/pry/repl.rb +14 -17
  78. data/lib/pry/repl_file_loader.rb +3 -8
  79. data/lib/pry/rubygem.rb +3 -3
  80. data/lib/pry/terminal.rb +3 -4
  81. data/lib/pry/test/helper.rb +11 -6
  82. data/lib/pry/version.rb +1 -1
  83. data/lib/pry/wrapped_module.rb +56 -49
  84. data/man/pry.1 +195 -0
  85. data/man/pry.1.html +204 -0
  86. data/man/pry.1.ronn +141 -0
  87. data/pry.gemspec +31 -0
  88. data/spec/Procfile +3 -0
  89. data/spec/cli_spec.rb +78 -0
  90. data/spec/code_object_spec.rb +277 -0
  91. data/spec/code_spec.rb +219 -0
  92. data/spec/command_helpers_spec.rb +29 -0
  93. data/spec/command_integration_spec.rb +562 -0
  94. data/spec/command_set_spec.rb +627 -0
  95. data/spec/command_spec.rb +821 -0
  96. data/spec/commands/amend_line_spec.rb +247 -0
  97. data/spec/commands/bang_spec.rb +18 -0
  98. data/spec/commands/cat_spec.rb +164 -0
  99. data/spec/commands/cd_spec.rb +250 -0
  100. data/spec/commands/disable_pry_spec.rb +25 -0
  101. data/spec/commands/edit_spec.rb +725 -0
  102. data/spec/commands/exit_all_spec.rb +27 -0
  103. data/spec/commands/exit_program_spec.rb +19 -0
  104. data/spec/commands/exit_spec.rb +28 -0
  105. data/spec/commands/find_method_spec.rb +70 -0
  106. data/spec/commands/gem_list_spec.rb +26 -0
  107. data/spec/commands/gist_spec.rb +79 -0
  108. data/spec/commands/help_spec.rb +56 -0
  109. data/spec/commands/hist_spec.rb +172 -0
  110. data/spec/commands/jump_to_spec.rb +15 -0
  111. data/spec/commands/ls_spec.rb +189 -0
  112. data/spec/commands/play_spec.rb +136 -0
  113. data/spec/commands/raise_up_spec.rb +56 -0
  114. data/spec/commands/save_file_spec.rb +177 -0
  115. data/spec/commands/show_doc_spec.rb +488 -0
  116. data/spec/commands/show_input_spec.rb +17 -0
  117. data/spec/commands/show_source_spec.rb +760 -0
  118. data/spec/commands/whereami_spec.rb +203 -0
  119. data/spec/completion_spec.rb +221 -0
  120. data/spec/control_d_handler_spec.rb +62 -0
  121. data/spec/documentation_helper_spec.rb +73 -0
  122. data/spec/editor_spec.rb +79 -0
  123. data/spec/exception_whitelist_spec.rb +21 -0
  124. data/spec/fixtures/candidate_helper1.rb +11 -0
  125. data/spec/fixtures/candidate_helper2.rb +8 -0
  126. data/spec/fixtures/example.erb +5 -0
  127. data/spec/fixtures/example_nesting.rb +33 -0
  128. data/spec/fixtures/show_source_doc_examples.rb +15 -0
  129. data/spec/fixtures/testlinkrc +2 -0
  130. data/spec/fixtures/testrc +2 -0
  131. data/spec/fixtures/testrcbad +2 -0
  132. data/spec/fixtures/whereami_helper.rb +6 -0
  133. data/spec/helper.rb +35 -0
  134. data/spec/helpers/bacon.rb +86 -0
  135. data/spec/helpers/mock_pry.rb +44 -0
  136. data/spec/helpers/repl_tester.rb +112 -0
  137. data/spec/helpers/table_spec.rb +105 -0
  138. data/spec/history_array_spec.rb +67 -0
  139. data/spec/hooks_spec.rb +522 -0
  140. data/spec/indent_spec.rb +301 -0
  141. data/spec/method_spec.rb +482 -0
  142. data/spec/prompt_spec.rb +61 -0
  143. data/spec/pry_defaults_spec.rb +420 -0
  144. data/spec/pry_history_spec.rb +69 -0
  145. data/spec/pry_output_spec.rb +95 -0
  146. data/spec/pry_repl_spec.rb +86 -0
  147. data/spec/pry_spec.rb +394 -0
  148. data/spec/pryrc_spec.rb +97 -0
  149. data/spec/run_command_spec.rb +25 -0
  150. data/spec/sticky_locals_spec.rb +147 -0
  151. data/spec/syntax_checking_spec.rb +81 -0
  152. data/spec/wrapped_module_spec.rb +261 -0
  153. data/wiki/Customizing-pry.md +397 -0
  154. data/wiki/Home.md +4 -0
  155. metadata +272 -61
  156. checksums.yaml +0 -7
  157. data/CHANGELOG.md +0 -714
  158. data/lib/pry/code/code_file.rb +0 -103
  159. data/lib/pry/color_printer.rb +0 -55
  160. data/lib/pry/commands/change_inspector.rb +0 -27
  161. data/lib/pry/commands/change_prompt.rb +0 -26
  162. data/lib/pry/commands/list_inspectors.rb +0 -35
  163. data/lib/pry/commands/list_prompts.rb +0 -35
  164. data/lib/pry/commands/ls/constants.rb +0 -47
  165. data/lib/pry/commands/ls/formatter.rb +0 -49
  166. data/lib/pry/commands/ls/globals.rb +0 -48
  167. data/lib/pry/commands/ls/grep.rb +0 -21
  168. data/lib/pry/commands/ls/instance_vars.rb +0 -39
  169. data/lib/pry/commands/ls/interrogatable.rb +0 -18
  170. data/lib/pry/commands/ls/jruby_hacks.rb +0 -49
  171. data/lib/pry/commands/ls/local_names.rb +0 -35
  172. data/lib/pry/commands/ls/local_vars.rb +0 -39
  173. data/lib/pry/commands/ls/ls_entity.rb +0 -70
  174. data/lib/pry/commands/ls/methods.rb +0 -57
  175. data/lib/pry/commands/ls/methods_helper.rb +0 -46
  176. data/lib/pry/commands/ls/self_methods.rb +0 -32
  177. data/lib/pry/commands/watch_expression.rb +0 -105
  178. data/lib/pry/commands/watch_expression/expression.rb +0 -38
  179. data/lib/pry/config/behavior.rb +0 -139
  180. data/lib/pry/config/convenience.rb +0 -25
  181. data/lib/pry/config/default.rb +0 -161
  182. data/lib/pry/exceptions.rb +0 -78
  183. data/lib/pry/input_completer.rb +0 -242
  184. data/lib/pry/input_lock.rb +0 -132
  185. data/lib/pry/inspector.rb +0 -27
  186. data/lib/pry/last_exception.rb +0 -61
  187. data/lib/pry/object_path.rb +0 -82
  188. data/lib/pry/output.rb +0 -50
  189. data/lib/pry/prompt.rb +0 -26
@@ -1,103 +0,0 @@
1
- class Pry
2
- class CodeFile
3
- DEFAULT_EXT = '.rb'
4
-
5
- # List of all supported languages.
6
- # @return [Hash]
7
- EXTENSIONS = {
8
- %w(.py) => :python,
9
- %w(.js) => :javascript,
10
- %w(.css) => :css,
11
- %w(.xml) => :xml,
12
- %w(.php) => :php,
13
- %w(.html) => :html,
14
- %w(.diff) => :diff,
15
- %w(.java) => :java,
16
- %w(.json) => :json,
17
- %w(.c .h) => :c,
18
- %w(.rhtml) => :rhtml,
19
- %w(.yaml .yml) => :yaml,
20
- %w(.cpp .hpp .cc .h cxx) => :cpp,
21
- %w(.rb .ru .irbrc .gemspec .pryrc) => :ruby,
22
- }
23
-
24
- # @return [Symbol] The type of code stored in this wrapper.
25
- attr_reader :code_type
26
-
27
- # @param [String] filename The name of a file with code to be detected
28
- # @param [Symbol] code_type The type of code the `filename` contains
29
- def initialize(filename, code_type = type_from_filename(filename))
30
- @filename = filename
31
- @code_type = code_type
32
- end
33
-
34
- # @return [String] The code contained in the current `@filename`.
35
- def code
36
- if @filename == Pry.eval_path
37
- Pry.line_buffer.drop(1)
38
- elsif Pry::Method::Patcher.code_for(@filename)
39
- Pry::Method::Patcher.code_for(@filename)
40
- elsif RbxPath.is_core_path?(@filename)
41
- File.read(RbxPath.convert_path_to_full(@filename))
42
- else
43
- path = abs_path
44
- @code_type = type_from_filename(path)
45
- File.read(path)
46
- end
47
- end
48
-
49
- private
50
-
51
- # @raise [MethodSource::SourceNotFoundError] if the `filename` is not
52
- # readable for some reason.
53
- # @return [String] absolute path for the given `filename`.
54
- def abs_path
55
- code_path.detect { |path| readable?(path) } or
56
- raise MethodSource::SourceNotFoundError,
57
- "Cannot open #{ @filename.inspect } for reading."
58
- end
59
-
60
- # @param [String] path
61
- # @return [Boolean] if the path, with or without the default ext,
62
- # is a readable file then `true`, otherwise `false`.
63
- def readable?(path)
64
- File.readable?(path) && !File.directory?(path) or
65
- File.readable?(path << DEFAULT_EXT)
66
- end
67
-
68
- # @return [Array] All the paths that contain code that Pry can use for its
69
- # API's. Skips directories.
70
- def code_path
71
- [from_pwd, from_pry_init_pwd, *from_load_path]
72
- end
73
-
74
- # @param [String] filename
75
- # @param [Symbol] default (:unknown) the file type to assume if none could be
76
- # detected.
77
- # @return [Symbol, nil] The CodeRay type of a file from its extension, or
78
- # `nil` if `:unknown`.
79
- def type_from_filename(filename, default = :unknown)
80
- _, @code_type = EXTENSIONS.find do |k, _|
81
- k.any? { |ext| ext == File.extname(filename) }
82
- end
83
-
84
- code_type || default
85
- end
86
-
87
- # @return [String]
88
- def from_pwd
89
- File.expand_path(@filename, Dir.pwd)
90
- end
91
-
92
- # @return [String]
93
- def from_pry_init_pwd
94
- File.expand_path(@filename, Pry::INITIAL_PWD)
95
- end
96
-
97
- # @return [String]
98
- def from_load_path
99
- $LOAD_PATH.map { |path| File.expand_path(@filename, path) }
100
- end
101
-
102
- end
103
- end
@@ -1,55 +0,0 @@
1
- # PP subclass for streaming inspect output in color.
2
- class Pry
3
- class ColorPrinter < ::PP
4
- OBJ_COLOR = begin
5
- code = CodeRay::Encoders::Terminal::TOKEN_COLORS[:keyword]
6
- if code.start_with? "\e"
7
- code
8
- else
9
- "\e[0m\e[0;#{code}m"
10
- end
11
- end
12
-
13
- CodeRay::Encoders::Terminal::TOKEN_COLORS[:comment][:self] = "\e[1;34m"
14
-
15
- def self.pp(obj, out = $>, width = 79)
16
- q = ColorPrinter.new(out, width)
17
- q.guard_inspect_key { q.pp obj }
18
- q.flush
19
- out << "\n"
20
- end
21
-
22
- def text(str, width = str.length)
23
- # Don't recolorize output with color [Issue #751]
24
- if str.include?("\e[")
25
- super "#{str}\e[0m", width
26
- elsif str.start_with?('#<') || str == '=' || str == '>'
27
- super highlight_object_literal(str), width
28
- else
29
- super CodeRay.scan(str, :ruby).term, width
30
- end
31
- end
32
-
33
- def pp(obj)
34
- super
35
- rescue => e
36
- raise if e.is_a? Pry::Pager::StopPaging
37
-
38
- # Read the class name off of the singleton class to provide a default
39
- # inspect.
40
- singleton = class << obj; self; end
41
- ancestors = Pry::Method.safe_send(singleton, :ancestors)
42
- klass = ancestors.reject { |k| k == singleton }.first
43
- obj_id = obj.__id__.to_s(16) rescue 0
44
- str = "#<#{klass}:0x#{obj_id}>"
45
-
46
- text highlight_object_literal(str)
47
- end
48
-
49
- private
50
-
51
- def highlight_object_literal(object_literal)
52
- "#{OBJ_COLOR}#{object_literal}\e[0m"
53
- end
54
- end
55
- end
@@ -1,27 +0,0 @@
1
- class Pry::Command::ChangeInspector < Pry::ClassCommand
2
- match 'change-inspector'
3
- group 'Input and Output'
4
- description 'Change the current inspector proc.'
5
- command_options argument_required: true
6
- banner <<-BANNER
7
- Usage: change-inspector NAME
8
-
9
- Change the proc used to print return values. See list-inspectors for a list
10
- of available procs and a short description of what each one does.
11
- BANNER
12
-
13
- def process(inspector)
14
- if inspector_map.key?(inspector)
15
- _pry_.print = inspector_map[inspector][:value]
16
- output.puts "Switched to the '#{inspector}' inspector!"
17
- else
18
- raise Pry::CommandError, "'#{inspector}' isn't a known inspector!"
19
- end
20
- end
21
-
22
- private
23
- def inspector_map
24
- Pry::Inspector::MAP
25
- end
26
- Pry::Commands.add_command(self)
27
- end
@@ -1,26 +0,0 @@
1
- class Pry::Command::ChangePrompt < Pry::ClassCommand
2
- match 'change-prompt'
3
- group 'Input and Output'
4
- description 'Change the current prompt.'
5
- command_options argument_required: true
6
- banner <<-BANNER
7
- Usage: change-prompt NAME
8
-
9
- Change the current prompt. See list-prompts for a list of available
10
- prompts.
11
- BANNER
12
-
13
- def process(prompt)
14
- if prompt_map.key?(prompt)
15
- _pry_.prompt = prompt_map[prompt][:value]
16
- else
17
- raise Pry::CommandError, "'#{prompt}' isn't a known prompt!"
18
- end
19
- end
20
-
21
- private
22
- def prompt_map
23
- Pry::Prompt::MAP
24
- end
25
- Pry::Commands.add_command(self)
26
- end
@@ -1,35 +0,0 @@
1
- class Pry::Command::ListInspectors < Pry::ClassCommand
2
- match 'list-inspectors'
3
- group 'Input and Output'
4
- description 'List the inspector procs available for use.'
5
- banner <<-BANNER
6
- Usage: list-inspectors
7
-
8
- List the inspector procs available to print return values. You can use
9
- change-inspector to switch between them.
10
- BANNER
11
-
12
- def process
13
- output.puts heading("Available inspectors") + "\n"
14
- inspector_map.each do |name, inspector|
15
- output.write "Name: #{text.bold(name)}"
16
- output.puts selected_inspector?(inspector) ? selected_text : ""
17
- output.puts inspector[:description]
18
- output.puts
19
- end
20
- end
21
-
22
- private
23
- def inspector_map
24
- Pry::Inspector::MAP
25
- end
26
-
27
- def selected_text
28
- text.red " (selected) "
29
- end
30
-
31
- def selected_inspector?(inspector)
32
- _pry_.print == inspector[:value]
33
- end
34
- Pry::Commands.add_command(self)
35
- end
@@ -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,47 +0,0 @@
1
- require 'pry/commands/ls/interrogatable'
2
-
3
- class Pry
4
- class Command::Ls < Pry::ClassCommand
5
- class Constants < Pry::Command::Ls::Formatter
6
- include Pry::Command::Ls::Interrogatable
7
-
8
-
9
- def initialize(interrogatee, no_user_opts, opts, _pry_)
10
- super(_pry_)
11
- @interrogatee = interrogatee
12
- @no_user_opts = no_user_opts
13
- @default_switch = opts[:constants]
14
- @verbose_switch = opts[:verbose]
15
- end
16
-
17
- def correct_opts?
18
- super || (@no_user_opts && interrogating_a_module?)
19
- end
20
-
21
- def output_self
22
- mod = interrogatee_mod
23
- constants = WrappedModule.new(mod).constants(@verbose_switch)
24
- output_section('constants', grep.regexp[format(mod, constants)])
25
- end
26
-
27
- private
28
-
29
- def format(mod, constants)
30
- constants.sort_by(&:downcase).map do |name|
31
- if const = (!mod.autoload?(name) && (mod.const_get(name) || true) rescue nil)
32
- if (const < Exception rescue false)
33
- color(:exception_constant, name)
34
- elsif (Module === mod.const_get(name) rescue false)
35
- color(:class_constant, name)
36
- else
37
- color(:constant, name)
38
- end
39
- else
40
- color(:unloaded_constant, name)
41
- end
42
- end
43
- end
44
-
45
- end
46
- end
47
- end
@@ -1,49 +0,0 @@
1
- class Pry
2
- class Command::Ls < Pry::ClassCommand
3
- class Formatter
4
- attr_writer :grep
5
- attr_reader :_pry_
6
-
7
- def initialize(_pry_)
8
- @_pry_ = _pry_
9
- @target = _pry_.current_context
10
- end
11
-
12
- def write_out
13
- return false unless correct_opts?
14
- output_self
15
- end
16
-
17
- private
18
-
19
- def color(type, str)
20
- Pry::Helpers::Text.send _pry_.config.ls["#{type}_color"], str
21
- end
22
-
23
- # Add a new section to the output.
24
- # Outputs nothing if the section would be empty.
25
- def output_section(heading, body)
26
- return '' if body.compact.empty?
27
- fancy_heading = Pry::Helpers::Text.bold(color(:heading, heading))
28
- Pry::Helpers.tablify_or_one_line(fancy_heading, body)
29
- end
30
-
31
- def format_value(value)
32
- Pry::ColorPrinter.pp(value, '')
33
- end
34
-
35
- def correct_opts?
36
- @default_switch
37
- end
38
-
39
- def output_self
40
- raise NotImplementedError
41
- end
42
-
43
- def grep
44
- @grep || proc { |x| x }
45
- end
46
-
47
- end
48
- end
49
- end
@@ -1,48 +0,0 @@
1
- class Pry
2
- class Command::Ls < Pry::ClassCommand
3
- class Globals < Pry::Command::Ls::Formatter
4
-
5
- # Taken from "puts global_variables.inspect".
6
- BUILTIN_GLOBALS =
7
- %w($" $$ $* $, $-0 $-F $-I $-K $-W $-a $-d $-i $-l $-p $-v $-w $. $/ $\\
8
- $: $; $< $= $> $0 $ARGV $CONSOLE $DEBUG $DEFAULT_INPUT $DEFAULT_OUTPUT
9
- $FIELD_SEPARATOR $FILENAME $FS $IGNORECASE $INPUT_LINE_NUMBER
10
- $INPUT_RECORD_SEPARATOR $KCODE $LOADED_FEATURES $LOAD_PATH $NR $OFS
11
- $ORS $OUTPUT_FIELD_SEPARATOR $OUTPUT_RECORD_SEPARATOR $PID $PROCESS_ID
12
- $PROGRAM_NAME $RS $VERBOSE $deferr $defout $stderr $stdin $stdout)
13
-
14
- # `$SAFE` and `$?` are thread-local, the exception stuff only works in a
15
- # rescue clause, everything else is basically a local variable with a `$`
16
- # in its name.
17
- PSEUDO_GLOBALS =
18
- %w($! $' $& $` $@ $? $+ $_ $~ $1 $2 $3 $4 $5 $6 $7 $8 $9
19
- $CHILD_STATUS $SAFE $ERROR_INFO $ERROR_POSITION $LAST_MATCH_INFO
20
- $LAST_PAREN_MATCH $LAST_READ_LINE $MATCH $POSTMATCH $PREMATCH)
21
-
22
- def initialize(opts, _pry_)
23
- super(_pry_)
24
- @default_switch = opts[:globals]
25
- end
26
-
27
- def output_self
28
- variables = format(@target.eval('global_variables'))
29
- output_section('global variables', grep.regexp[variables])
30
- end
31
-
32
- private
33
-
34
- def format(globals)
35
- globals.map(&:to_s).sort_by(&:downcase).map do |name|
36
- if PSEUDO_GLOBALS.include?(name)
37
- color(:pseudo_global, name)
38
- elsif BUILTIN_GLOBALS.include?(name)
39
- color(:builtin_global, name)
40
- else
41
- color(:global_var, name)
42
- end
43
- end
44
- end
45
-
46
- end
47
- end
48
- end
@@ -1,21 +0,0 @@
1
- class Pry
2
- class Command::Ls < Pry::ClassCommand
3
- class Grep
4
-
5
- def initialize(grep_regexp)
6
- @grep_regexp = grep_regexp
7
- end
8
-
9
- def regexp
10
- proc { |x|
11
- if x.instance_of?(Array)
12
- x.grep(@grep_regexp)
13
- else
14
- x =~ @grep_regexp
15
- end
16
- }
17
- end
18
-
19
- end
20
- end
21
- end