pry 0.13.1 → 0.14.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9a8834347bff9e94179a35d225768c377a94b33750c989983f42c6cd90b9f0a5
4
- data.tar.gz: 363c3c38dea1cba4b0b0b0b0b617b36a91a3d0761c349687deeff54711210886
3
+ metadata.gz: 6d8bac7565d29bff46039481c17aa6a88fec28084916dd8dad12cd4e83b146c1
4
+ data.tar.gz: 90b46a979aaac6d01ddf589217baca57bc2d7ce8197c8f27bc22f823eeaffcdd
5
5
  SHA512:
6
- metadata.gz: deda71757450c541d7e0e9981058244817c1ea8ccf9f8ffec81c1d1919bf8bc45493cd392f8ef44baaac4e70e69c4170dd893e3cb5204770494124b033668507
7
- data.tar.gz: bbdeb8c6e1f41f107d49ffd9c042121011870516c0228662e98b905bd41c5714748aa9dd09763a9d8c88a030daa3a317e8121d2882cc97ff72554c09fcee685e
6
+ metadata.gz: 2e671cca56deb75c1c47ba9108155bec171ebe34d5ba740b3dd7ea3e848fc789291111e40b7c604835b3d90209873a4a3364ec72a5f4c0f062dea98e5b466a30
7
+ data.tar.gz: f4c80ad6f3187823c18e1fff35306fc1e0a0ee4045a06b190f4742c92099b89d7ef5bafcb1c1dd68c8ae09b251a9a9b64bfd33179c2a7778f3122c90d636afa5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,68 @@
1
1
  ### master
2
2
 
3
+ ### [v0.14.2][v0.14.2] (January 9, 2023)
4
+
5
+ #### Features
6
+
7
+ * Configure `code` as a supported editor on Pry::Editor
8
+ ([#2236](https://github.com/pry/pry/pull/2236))
9
+ * Added support for Ruby 3.2
10
+ ([#2263](https://github.com/pry/pry/pull/2263))
11
+ * Added support for Ruby 3.1
12
+ ([#2228](https://github.com/pry/pry/pull/2228))
13
+
14
+ #### Bug fixes
15
+
16
+ * Short circuit eval regexes in finding module definition
17
+ ([#2253](https://github.com/pry/pry/pull/2253))
18
+ * Revert "Escape non-printing characters"
19
+ ([#2235](https://github.com/pry/pry/pull/2235))
20
+ * Fixed bug where WeirdMethodLocator would fail to find the source of a method breaking whereami
21
+ ([#2244](https://github.com/pry/pry/pull/2244))
22
+ * Fixed bug where pry would throw an FrozenError when dealing with incomplete tokens
23
+ ([#2136](https://github.com/pry/pry/pull/2136))
24
+ * Restore --no-history CLI flag functionality
25
+ ([#2196](https://github.com/pry/pry/pull/2196))
26
+ * Fixed bug where reading from the `_out_` sticky local variable could return
27
+ wrong results ([#2201](https://github.com/pry/pry/pull/2201))
28
+
29
+ #### Breaking Changes
30
+
31
+ * Remove support for Ruby 1.9 and JRuby < 9.0
32
+ ([#2239](https://github.com/pry/pry/pull/2239))
33
+
34
+ ### [v0.14.1][v0.14.1] (April 12, 2021)
35
+
36
+ #### Bug fixes
37
+
38
+ * Fixed bad coloring of some RDoc-style docs
39
+ ([#2182](https://github.com/pry/pry/pull/2182))
40
+ * Fixed broken `--plugins` option. It shows a warning now
41
+ ([#2180](https://github.com/pry/pry/pull/2180))
42
+ * Fixed bad output on printing non-visible characters with color codes
43
+ ([#2154](https://github.com/pry/pry/pull/2154))
44
+ * Fixed bad output when colors are disabled and a string with color codes is
45
+ printed ([#2158](https://github.com/pry/pry/pull/2158))
46
+
47
+ ### [v0.14.0][v0.14.0] (February 8, 2021)
48
+
49
+ #### Features
50
+
51
+ * Made `?` an alias to `show-source -d`
52
+ ([#2133](https://github.com/pry/pry/pull/2133))
53
+ * Added support for Ruby 3.0
54
+
55
+ #### Breaking changes
56
+
57
+ * Deleted support for plugin autoloading
58
+ ([#2119](https://github.com/pry/pry/pull/2119)). In order to load a Pry plugin
59
+ you must `require` it from your `pryrc` or add it to your Gemfile.
60
+
61
+ ```rb
62
+ # ~/.pryrc
63
+ require 'pryrc'
64
+ ```
65
+
3
66
  ### [v0.13.1][v0.13.1] (April 12, 2020)
4
67
 
5
68
  #### Bug fixes
@@ -1074,3 +1137,5 @@ complete CHANGELOG:
1074
1137
  [v0.12.2]: https://github.com/pry/pry/releases/tag/v0.12.2
1075
1138
  [v0.13.0]: https://github.com/pry/pry/releases/tag/v0.13.0
1076
1139
  [v0.13.1]: https://github.com/pry/pry/releases/tag/v0.13.1
1140
+ [v0.14.0]: https://github.com/pry/pry/releases/tag/v0.14.0
1141
+ [v0.14.1]: https://github.com/pry/pry/releases/tag/v0.14.1
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  Pry
2
2
  ===
3
3
 
4
- [![Circle Build Status](https://circleci.com/gh/pry/pry.svg?style=shield)](https://circleci.com/gh/pry/pry)
4
+ [![Pry Build Status](https://github.com/pry/pry/workflows/pry/badge.svg)](https://github.com/pry/pry/actions)
5
5
  [![Code Climate](https://codeclimate.com/github/pry/pry.svg)](https://codeclimate.com/github/pry/pry)
6
6
  [![Gem Version](https://badge.fury.io/rb/pry.svg)](https://badge.fury.io/rb/pry)
7
7
  [![Documentation Status](https://inch-ci.org/github/pry/pry.svg?branch=master)](https://inch-ci.org/github/pry/pry)
@@ -21,7 +21,7 @@ Pry
21
21
 
22
22
  **Links:**
23
23
 
24
- * https://pryrepl.org/
24
+ * https://pry.github.io/
25
25
  * [YARD API documentation](https://www.rubydoc.info/gems/pry)
26
26
  * [Wiki](https://github.com/pry/pry/wiki)
27
27
 
@@ -38,7 +38,6 @@ Table of Contents
38
38
  * [Command Shell Integration](#command-shell-integration)
39
39
  * [Code Browsing](#code-browsing)
40
40
  * [Documentation Browsing](#documentation-browsing)
41
- * [Gist integration](#gist-integration)
42
41
  * [Edit methods](#edit-methods)
43
42
  * [Live Help System](#live-help-system)
44
43
  * [Use Pry as your Rails Console](#use-pry-as-your-rails-console)
@@ -82,7 +81,7 @@ Installation
82
81
  ### Bundler
83
82
 
84
83
  ```ruby
85
- gem 'pry', '~> 0.12.2'
84
+ gem 'pry', '~> 0.13.1'
86
85
  ```
87
86
 
88
87
  ### Manual
@@ -208,7 +207,7 @@ hello world!
208
207
  pry(main)> def a.goodbye
209
208
  pry(main)* puts "goodbye cruel world!"
210
209
  pry(main)* end
211
- => nil
210
+ => :goodbye
212
211
  pry(main)> a.goodbye
213
212
  goodbye cruel world!
214
213
  => nil
@@ -266,23 +265,26 @@ syntax and also simply the name of a method that's in scope. You can optionally
266
265
  pass the `-l` option to `show-source` to include line numbers in the output.
267
266
 
268
267
  In the following example we will enter the `Pry` class, list the instance
269
- methods beginning with 're' and display the source code for the `rep` method:
268
+ methods beginning with 'se' and display the source code for the `set_last_result` method:
270
269
 
271
270
  ```ruby
272
271
  pry(main)> cd Pry
273
- pry(Pry):1> ls -M --grep re
274
- Pry#methods: re readline refresh rep repl repl_epilogue repl_prologue retrieve_line
275
- pry(Pry):1> show-source rep -l
276
-
277
- From: /home/john/ruby/projects/pry/lib/pry/pry_instance.rb:143
272
+ pry(Pry):1> ls -M --grep se
273
+ Pry#methods: raise_up raise_up! raise_up_common reset_eval_string select_prompt set_last_result
274
+ pry(Pry):1> show-source set_last_result -l
275
+
276
+ From: /home/john/ruby/projects/pry/lib/pry/pry_instance.rb:405:
277
+ Owner: Pry
278
+ Visibility: public
279
+ Signature: set_last_result(result, code=?)
278
280
  Number of lines: 6
279
281
 
280
- 143: def rep(target=TOPLEVEL_BINDING)
281
- 144: target = Pry.binding_for(target)
282
- 145: result = re(target)
283
- 146:
284
- 147: show_result(result) if should_print?
285
- 148: end
282
+ 405: def set_last_result(result, code = "")
283
+ 406: @last_result_is_exception = false
284
+ 407: @output_ring << result
285
+ 408:
286
+ 409: self.last_result = result unless code =~ /\A\s*\z/
287
+ 410: end
286
288
  ```
287
289
 
288
290
  Note that we can also view C methods (from Ruby Core) using the
@@ -317,7 +319,7 @@ rb_ary_select(VALUE ary)
317
319
  One use-case for Pry is to explore a program at run-time by `cd`-ing in and out
318
320
  of objects and viewing and invoking methods. In the course of exploring it may
319
321
  be useful to read the documentation for a specific method that you come
320
- across. Like `show-source` the `show-doc` command supports two syntaxes - the
322
+ across. `show-source` command supports two syntaxes - the
321
323
  normal `ri` syntax as well as accepting the name of any method that is currently
322
324
  in scope.
323
325
 
@@ -339,14 +341,26 @@ In our example we will enter the `Gem` class and view the documentation for the
339
341
 
340
342
  ```ruby
341
343
  pry(main)> cd Gem
342
- pry(Gem):1> show-doc try_activate
344
+ pry(Gem):1> show-source try_activate -d
343
345
 
344
- From: /Users/john/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems.rb:201
345
- Number of lines: 3
346
+ From: /Users/john/rbenv/versions/2.7.1/lib/ruby/2.7.0/rubygems.rb:194:
347
+ Owner: #<Class:Gem>
348
+ Visibility: public
349
+ Signature: try_activate(path)
350
+ Number of lines: 28
346
351
 
347
352
  Try to activate a gem containing path. Returns true if
348
353
  activation succeeded or wasn't needed because it was already
349
354
  activated. Returns false if it can't find the path in a gem.
355
+
356
+ def self.try_activate(path)
357
+ # finds the _latest_ version... regardless of loaded specs and their deps
358
+ # if another gem had a requirement that would mean we shouldn't
359
+ # activate the latest version, then either it would already be activated
360
+ # or if it was ambiguous (and thus unresolved) the code in our custom
361
+ # require will try to activate the more specific version.
362
+
363
+ spec = Gem::Specification.find_by_path path
350
364
  pry(Gem):1>
351
365
  ```
352
366
 
@@ -427,8 +441,8 @@ putting the line `Pry.color = false` in your `pryrc` file.
427
441
  Supported Rubies
428
442
  ----------------
429
443
 
430
- * CRuby >= 1.9.3
431
- * JRuby >= 1.7
444
+ * CRuby >= 2.0.0
445
+ * JRuby >= 9.0
432
446
 
433
447
  Contact
434
448
  -------
@@ -2,7 +2,7 @@
2
2
 
3
3
  class Pry
4
4
  class BasicObject < BasicObject
5
- [:Kernel, :File, :Dir, :LoadError, :ENV, :Pry].each do |constant|
5
+ %i[Kernel File Dir LoadError ENV Pry].each do |constant|
6
6
  const_set constant, ::Object.const_get(constant)
7
7
  end
8
8
  include Kernel
data/lib/pry/cli.rb CHANGED
@@ -35,13 +35,6 @@ class Pry
35
35
  self
36
36
  end
37
37
 
38
- # Bring in options defined in plugins
39
- def add_plugin_options
40
- Pry.plugins.values.each(&:load_cli_options)
41
-
42
- self
43
- end
44
-
45
38
  # Add a block responsible for processing parsed options.
46
39
  def add_option_processor(&block)
47
40
  self.option_processors ||= []
@@ -124,21 +117,12 @@ class Pry
124
117
  end
125
118
  end
126
119
 
127
- # Bring in options defined by plugins
128
- Pry::Slop.new do
129
- on "no-plugins" do
130
- Pry.config.should_load_plugins = false
131
- end
132
- end.parse(ARGV.dup)
133
-
134
- Pry::CLI.add_plugin_options if Pry.config.should_load_plugins
135
-
136
120
  # The default Pry command line options (before plugin options are included)
137
121
  Pry::CLI.add_options do
138
122
  banner(
139
123
  "Usage: pry [OPTIONS]\n" \
140
124
  "Start a Pry session.\n" \
141
- "See http://pryrepl.org/ for more information.\n" \
125
+ "See http://pry.github.io/ for more information.\n" \
142
126
  "Copyright (c) 2016 John Mair (banisterfiend)" \
143
127
  )
144
128
 
@@ -154,7 +138,7 @@ Pry::CLI.add_options do
154
138
  end
155
139
 
156
140
  on "no-history", "Disable history loading" do
157
- Pry.config.history.should_load = false
141
+ Pry.config.history_load = false
158
142
  end
159
143
 
160
144
  on "no-color", "Disable syntax highlighting for session" do
@@ -166,25 +150,21 @@ Pry::CLI.add_options do
166
150
  Pry.config.should_load_local_rc = false
167
151
  end
168
152
 
169
- on :s, "select-plugin=", "Only load specified plugin (and no others)." do |plugin_name|
170
- Pry.config.should_load_plugins = false
171
- Pry.plugins[plugin_name].activate!
153
+ on :s, "select-plugin=", "Only load specified plugin (and no others)." do |_plugin_name|
154
+ warn "The --select-plugin option is deprecated and has no effect"
172
155
  end
173
156
 
174
- on :d, "disable-plugin=", "Disable a specific plugin." do |plugin_name|
175
- Pry.plugins[plugin_name].disable!
157
+ on :d, "disable-plugin=", "Disable a specific plugin." do |_plugin_name|
158
+ warn "The --disable-plugin option is deprecated and has no effect"
176
159
  end
177
160
 
178
161
  on "no-plugins", "Suppress loading of plugins." do
179
- Pry.config.should_load_plugins = false
162
+ warn "The --no-plugins option is deprecated and has no effect"
180
163
  end
181
164
 
182
165
  on "plugins", "List installed plugins." do
183
- puts "Installed Plugins:"
184
- puts "--"
185
- Pry.locate_plugins.each do |plugin|
186
- puts plugin.name.to_s.ljust(18) << plugin.spec.summary
187
- end
166
+ warn "The --plugins option is deprecated and has no effect"
167
+ warn "Try using `gem list pry-`"
188
168
  Kernel.exit
189
169
  end
190
170
 
data/lib/pry/code.rb CHANGED
@@ -339,21 +339,13 @@ class Pry
339
339
  super
340
340
  end
341
341
  end
342
- undef =~
342
+ undef =~ if method_defined?(:=~)
343
343
 
344
344
  # Check whether String responds to missing methods.
345
345
  def respond_to_missing?(method_name, include_private = false)
346
346
  ''.respond_to?(method_name, include_private) || super
347
347
  end
348
348
 
349
- if RUBY_VERSION.start_with?('1.9')
350
- # @todo This is needed for Ruby 1.9 support where `lines` return an
351
- # Enumerator. Newer Rubies return an Array
352
- def lines
353
- super.to_a
354
- end
355
- end
356
-
357
349
  protected
358
350
 
359
351
  # An abstraction of the `dup.instance_eval` pattern used throughout this
@@ -4,8 +4,8 @@ class Pry
4
4
  class Command
5
5
  class Ls < Pry::ClassCommand
6
6
  class Constants < Pry::Command::Ls::Formatter
7
- DEPRECATED_CONSTANTS = [
8
- :Data, :Fixnum, :Bignum, :TimeoutError, :NIL, :FALSE, :TRUE
7
+ DEPRECATED_CONSTANTS = %i[
8
+ Data Fixnum Bignum TimeoutError NIL FALSE TRUE
9
9
  ].tap do |constants|
10
10
  constants << :JavaPackageModuleTemplate if Helpers::Platform.jruby?
11
11
  end
@@ -89,6 +89,5 @@ class Pry
89
89
  end
90
90
 
91
91
  Pry::Commands.add_command(Pry::Command::ShowDoc)
92
- Pry::Commands.alias_command '?', 'show-doc'
93
92
  end
94
93
  end
@@ -113,5 +113,6 @@ class Pry
113
113
  Pry::Commands.add_command(Pry::Command::ShowSource)
114
114
  Pry::Commands.alias_command 'show-method', 'show-source'
115
115
  Pry::Commands.alias_command '$', 'show-source'
116
+ Pry::Commands.alias_command '?', 'show-source -d'
116
117
  end
117
118
  end
@@ -96,7 +96,7 @@ class Pry
96
96
  end
97
97
 
98
98
  def add_hook
99
- hook = [:after_eval, :watch_expression]
99
+ hook = %i[after_eval watch_expression]
100
100
  return if pry_instance.hooks.hook_exists?(*hook)
101
101
 
102
102
  pry_instance.hooks.add_hook(*hook) do |_, pry_instance|
data/lib/pry/config.rb CHANGED
@@ -73,9 +73,6 @@ class Pry
73
73
  # @return [Boolean] whether the local ./.pryrc should be loaded
74
74
  attribute :should_load_local_rc
75
75
 
76
- # @return [Boolean]
77
- attribute :should_load_plugins
78
-
79
76
  # @return [Boolean] whether to load files specified with the -r flag
80
77
  attribute :should_load_requires
81
78
 
@@ -196,7 +193,6 @@ class Pry
196
193
  output_prefix: '=> ',
197
194
  requires: [],
198
195
  should_load_requires: true,
199
- should_load_plugins: true,
200
196
  windows_console_warning: true,
201
197
  control_d_handler: Pry::ControlDHandler.method(:default),
202
198
  memory_size: 100,
@@ -305,17 +301,14 @@ class Pry
305
301
  end
306
302
 
307
303
  def default_rc_file
308
- if (pryrc = Pry::Env['PRYRC'])
309
- pryrc
310
- elsif (xdg_home = Pry::Env['XDG_CONFIG_HOME'])
311
- # See XDG Base Directory Specification at
312
- # https://standards.freedesktop.org/basedir-spec/basedir-spec-0.8.html
313
- xdg_home + '/pry/pryrc'
314
- elsif File.exist?(File.expand_path('~/.pryrc'))
315
- '~/.pryrc'
316
- else
317
- '~/.config/pry/pryrc'
318
- end
304
+ [Pry::Env['PRYRC'],
305
+ # See XDG Base Directory Specification at
306
+ # https://specifications.freedesktop.org/basedir-spec/latest/
307
+ "#{Pry::Env['XDG_CONFIG_HOME']}/pry/pryrc",
308
+ File.expand_path('~/.pryrc'),
309
+ File.expand_path('~/.config/pry/pryrc')]
310
+ .compact
311
+ .find { |file| File.exist?(file) }
319
312
  end
320
313
  end
321
314
  end
@@ -78,7 +78,7 @@ class Object
78
78
  # Module.new.class_eval("binding") has different behaviour than CRuby,
79
79
  # where this is not needed: class_eval("binding") vs class_eval{binding}.
80
80
  # Using a block works around the difference of behaviour on JRuby.
81
- # The scope is clear of local variabless. Don't add any.
81
+ # The scope is clear of local variables. Don't add any.
82
82
  #
83
83
  # This fixes the following two spec failures, at https://travis-ci.org/pry/pry/jobs/274470002
84
84
  # 1) ./spec/pry_spec.rb:360:in `block in (root)'
data/lib/pry/editor.rb CHANGED
@@ -105,7 +105,7 @@ class Pry
105
105
  '--nofork' if blocking
106
106
  when /^jedit/
107
107
  '-wait' if blocking
108
- when /^mate/, /^subl/, /^redcar/
108
+ when /^mate/, /^subl/, /^redcar/, /^code/
109
109
  '-w' if blocking
110
110
  end
111
111
  end
@@ -121,6 +121,8 @@ class Pry
121
121
  "+#{line_number} #{file_name}"
122
122
  when /^mate/, /^geany/
123
123
  "-l #{line_number} #{file_name}"
124
+ when /^code/
125
+ "-g #{file_name}:#{line_number}"
124
126
  when /^subl/
125
127
  "#{file_name}:#{line_number}"
126
128
  when /^uedit32/
@@ -17,12 +17,13 @@ class Pry
17
17
  last_match_ruby = proc do
18
18
  SyntaxHighlighter.highlight(Regexp.last_match(1))
19
19
  end
20
+
20
21
  comment.gsub(%r{<code>(?:\s*\n)?(.*?)\s*</code>}m, &last_match_ruby)
21
22
  .gsub(%r{<em>(?:\s*\n)?(.*?)\s*</em>}m) { "\e[1m#{Regexp.last_match(1)}\e[0m" }
22
23
  .gsub(%r{<i>(?:\s*\n)?(.*?)\s*</i>}m) { "\e[1m#{Regexp.last_match(1)}\e[0m" }
23
24
  .gsub(%r{<tt>(?:\s*\n)?(.*?)\s*</tt>}m, &last_match_ruby)
24
25
  .gsub(/\B\+(\w+?)\+\B/) { "\e[32m#{Regexp.last_match(1)}\e[0m" }
25
- .gsub(/((?:^[ \t]+.+(?:\n+|\Z))+)/, &last_match_ruby)
26
+ .gsub(/((?:^[ \t]+(?:(?!.+\e\[)).+(?:\n+|\Z))+)/, &last_match_ruby)
26
27
  .gsub(/`(?:\s*\n)?([^\e]*?)\s*`/) { "`#{last_match_ruby.call}`" }
27
28
  end
28
29
 
@@ -28,7 +28,7 @@ class Pry
28
28
  def self.windows_ansi?
29
29
  return false unless windows?
30
30
 
31
- !!(defined?(Win32::Console) || Pry::Env['ANSICON'] || mri_2?)
31
+ !!(defined?(Win32::Console) || Pry::Env['ANSICON'] || mri?)
32
32
  end
33
33
 
34
34
  # @return [Boolean]
@@ -46,11 +46,6 @@ class Pry
46
46
  RbConfig::CONFIG['ruby_install_name'] == 'ruby'
47
47
  end
48
48
 
49
- # @return [Boolean]
50
- def self.mri_19?
51
- mri? && RUBY_VERSION.start_with?('1.9')
52
- end
53
-
54
49
  # @return [Boolean]
55
50
  def self.mri_2?
56
51
  mri? && RUBY_VERSION.start_with?('2')
@@ -44,7 +44,7 @@ class Pry
44
44
  # @param [String, #to_s] text
45
45
  # @return [String] _text_ stripped of any color codes.
46
46
  def strip_color(text)
47
- text.to_s.gsub(/(\001)?\e\[.*?(\d)+m(\002)?/, '')
47
+ text.to_s.gsub(/(\001)?(\e\[(\d[;\d]?)*m)(\002)?/, '')
48
48
  end
49
49
 
50
50
  # Returns _text_ as bold text for use on a terminal.
data/lib/pry/indent.rb CHANGED
@@ -57,8 +57,8 @@ class Pry
57
57
  #
58
58
  # :pre_constant and :preserved_constant are the CodeRay 0.9.8 and 1.0.0
59
59
  # classifications of "true", "false", and "nil".
60
- IGNORE_TOKENS = [:space, :content, :string, :method, :ident,
61
- :constant, :pre_constant, :predefined_constant].freeze
60
+ IGNORE_TOKENS = %i[space content string method ident
61
+ constant pre_constant predefined_constant].freeze
62
62
 
63
63
  # Tokens that indicate the end of a statement (i.e. that, if they appear
64
64
  # directly before an "if" indicates that that if applies to the same line,
@@ -66,10 +66,10 @@ class Pry
66
66
  #
67
67
  # :reserved and :keywords are the CodeRay 0.9.8 and 1.0.0 respectively
68
68
  # classifications of "super", "next", "return", etc.
69
- STATEMENT_END_TOKENS = IGNORE_TOKENS + [:regexp, :integer, :float,
70
- :keyword, :delimiter, :reserved,
71
- :instance_variable,
72
- :class_variable, :global_variable]
69
+ STATEMENT_END_TOKENS = IGNORE_TOKENS + %i[regexp integer float
70
+ keyword delimiter reserved
71
+ instance_variable
72
+ class_variable global_variable]
73
73
 
74
74
  # Collection of tokens that should appear dedented even though they
75
75
  # don't affect the surrounding code.
@@ -109,7 +109,7 @@ class Pry
109
109
  # reset internal state
110
110
  def reset
111
111
  @stack = []
112
- @indent_level = ''
112
+ @indent_level = String.new # rubocop:disable Style/EmptyLiteral
113
113
  @heredoc_queue = []
114
114
  @close_heredocs = {}
115
115
  @string_start = nil
@@ -270,7 +270,7 @@ class Pry
270
270
  end
271
271
 
272
272
  # FIXME: Add Pry here as well?
273
- [:IRB, :SLex, :RubyLex, :RubyToken].each do |module_name|
273
+ %i[IRB SLex RubyLex RubyToken].each do |module_name|
274
274
  next unless Object.const_defined?(module_name)
275
275
 
276
276
  scanner.call(Object.const_get(module_name))
@@ -158,7 +158,7 @@ class Pry
158
158
 
159
159
  alias_name = all_methods_for(target_self).find do |v|
160
160
  location = target_self.method(v).source_location
161
- expanded_source_location(location) == renamed_method_source_location
161
+ location && expanded_source_location(location) == renamed_method_source_location
162
162
  end
163
163
 
164
164
  alias_name && Pry::Method(target_self.method(alias_name))
data/lib/pry/method.rb CHANGED
@@ -530,8 +530,9 @@ class Pry
530
530
  else
531
531
  fail_msg = "Cannot locate this method: #{name}."
532
532
  if Helpers::Platform.mri?
533
- fail_msg += " Invoke the 'gem-install pry-doc' Pry command to get " \
534
- "access to Ruby Core documentation.\n"
533
+ fail_msg += " Run `gem install pry-doc` to install" \
534
+ " Ruby Core documentation," \
535
+ " and `require 'pry-doc'` to load it.\n"
535
536
  end
536
537
  raise CommandError, fail_msg
537
538
  end
data/lib/pry/pry_class.rb CHANGED
@@ -24,8 +24,6 @@ class Pry
24
24
  attr_accessor :last_internal_error
25
25
  attr_accessor :config
26
26
 
27
- def_delegators :@plugin_manager, :plugins, :load_plugins, :locate_plugins
28
-
29
27
  def_delegators(
30
28
  :@config, :input, :input=, :output, :output=, :commands,
31
29
  :commands=, :print, :print=, :exception_handler, :exception_handler=,
@@ -87,7 +85,7 @@ class Pry
87
85
  # Load the local RC file (./.pryrc)
88
86
  def self.rc_files_to_load
89
87
  files = []
90
- files << Pry.config.rc_file if Pry.config.should_load_rc
88
+ files << Pry.config.rc_file if Pry.config.rc_file && Pry.config.should_load_rc
91
89
  files << LOCAL_RC_FILE if Pry.config.should_load_local_rc
92
90
  files.map { |file| real_path_to(file) }.compact.uniq
93
91
  end
@@ -142,7 +140,6 @@ you can add "Pry.config.windows_console_warning = false" to your pryrc.
142
140
  return if @session_finalized
143
141
 
144
142
  @session_finalized = true
145
- load_plugins if Pry.config.should_load_plugins
146
143
  load_requires if Pry.config.should_load_requires
147
144
  load_history if Pry.config.history_load
148
145
  load_traps if Pry.config.should_trap_interrupts
@@ -171,6 +168,12 @@ you can add "Pry.config.windows_console_warning = false" to your pryrc.
171
168
  return
172
169
  end
173
170
 
171
+ unless mutex_available?
172
+ output.puts "ERROR: Unable to obtain mutex lock."
173
+ output.puts "This can happen if binding.pry is called from a signal handler"
174
+ return
175
+ end
176
+
174
177
  options[:target] = Pry.binding_for(target || toplevel_binding)
175
178
  initial_session_setup
176
179
  final_session_setup
@@ -333,9 +336,7 @@ Readline version #{Readline::VERSION} detected - will not auto_resize! correctly
333
336
 
334
337
  # Basic initialization.
335
338
  def self.init
336
- @plugin_manager ||= PluginManager.new
337
339
  reset_defaults
338
- locate_plugins
339
340
  end
340
341
 
341
342
  # Return a `Binding` object for `target` or return `target` if it is
@@ -383,6 +384,13 @@ Readline version #{Readline::VERSION} detected - will not auto_resize! correctly
383
384
  ensure
384
385
  Thread.current[:pry_critical_section] -= 1
385
386
  end
387
+
388
+ def self.mutex_available?
389
+ Mutex.new.synchronize { true }
390
+ rescue ThreadError
391
+ false
392
+ end
393
+ private_class_method :mutex_available?
386
394
  end
387
395
 
388
396
  Pry.init
@@ -20,7 +20,7 @@ require 'ostruct'
20
20
  # This will show a list of available commands and their usage. For more
21
21
  # information about Pry you can refer to the following resources:
22
22
  #
23
- # * http://pryrepl.org/
23
+ # * https://pry.github.io
24
24
  # * https://github.com/pry/pry
25
25
  # * the IRC channel, which is #pry on the Freenode network
26
26
  #
data/lib/pry/repl.rb CHANGED
@@ -141,8 +141,7 @@ class Pry
141
141
  retry
142
142
 
143
143
  # Handle <Ctrl+C> like Bash: empty the current input buffer, but don't
144
- # quit. This is only for MRI 1.9; other versions of Ruby don't let you
145
- # send Interrupt from within Readline.
144
+ # quit.
146
145
  rescue Interrupt
147
146
  return :control_c
148
147
 
data/lib/pry/ring.rb CHANGED
@@ -56,8 +56,8 @@ class Pry
56
56
  # exist
57
57
  def [](index)
58
58
  @mutex.synchronize do
59
- return @buffer[(count + index) % max_size] if index.is_a?(Integer)
60
59
  return @buffer[index] if count <= max_size
60
+ return @buffer[(count + index) % max_size] if index.is_a?(Integer)
61
61
 
62
62
  transpose_buffer_tail[index]
63
63
  end
data/lib/pry/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Pry
4
- VERSION = '0.13.1'.freeze
4
+ VERSION = '0.14.2'.freeze
5
5
  end
data/lib/pry/warning.rb CHANGED
@@ -10,16 +10,9 @@ class Pry
10
10
  # @param [String] message
11
11
  # @return [void]
12
12
  def self.warn(message)
13
- if Kernel.respond_to?(:caller_locations)
14
- location = caller_locations(2..2).first
15
- path = location.path
16
- lineno = location.lineno
17
- else
18
- # Ruby 1.9.3 support.
19
- frame = caller[1].split(':') # rubocop:disable Performance/Caller
20
- path = frame.first
21
- lineno = frame[1]
22
- end
13
+ location = caller_locations(2..2).first
14
+ path = location.path
15
+ lineno = location.lineno
23
16
 
24
17
  Kernel.warn("#{path}:#{lineno}: warning: #{message}")
25
18
  end
@@ -20,9 +20,9 @@ class Pry
20
20
 
21
21
  # Methods to delegate to associated `Pry::WrappedModule
22
22
  # instance`.
23
- private_delegates = [:lines_for_file, :method_candidates, :yard_docs?, :name]
24
- public_delegates = [:wrapped, :module?, :class?, :nonblank_name,
25
- :number_of_candidates]
23
+ private_delegates = %i[lines_for_file method_candidates yard_docs? name]
24
+ public_delegates = %i[wrapped module? class? nonblank_name
25
+ number_of_candidates]
26
26
 
27
27
  def_delegators :@wrapper, *public_delegates
28
28
  def_private_delegators :@wrapper, *private_delegates
@@ -98,14 +98,15 @@ class Pry
98
98
  # line number is one-indexed.
99
99
  def first_line_of_module_definition(file, line)
100
100
  searchable_lines = lines_for_file(file)[0..(line - 2)]
101
- searchable_lines.rindex { |v| class_regexes.any? { |r| r =~ v } } + 1
101
+ searchable_lines.rindex { |v| module_definition_first_line?(v) } + 1
102
102
  end
103
103
 
104
- def class_regexes
104
+ def module_definition_first_line?(line)
105
105
  mod_type_string = wrapped.class.to_s.downcase
106
- [/(^|=)\s*#{mod_type_string}\s+(?:(?:\w*)::)*?#{wrapped.name.split(/::/).last}/,
107
- /^\s*(::)?#{wrapped.name.split(/::/).last}\s*?=\s*?#{wrapped.class}/,
108
- /^\s*(::)?#{wrapped.name.split(/::/).last}\.(class|instance)_eval/]
106
+ wrapped_name_last = wrapped.name.split(/::/).last
107
+ /(^|=)\s*#{mod_type_string}\s+(?:(?:\w*)::)*?#{wrapped_name_last}/ =~ line ||
108
+ /^\s*(::)?#{wrapped_name_last}\s*?=\s*?#{wrapped.class}/ =~ line ||
109
+ /^\s*(::)?#{wrapped_name_last}\.(class|instance)_eval/ =~ line
109
110
  end
110
111
 
111
112
  # This method is used by `Candidate#source_location` as a
@@ -246,19 +246,14 @@ class Pry
246
246
  method_candidates.count
247
247
  end
248
248
 
249
- # @note On JRuby 1.9 and higher, in certain conditions, this method chucks
250
- # away its ability to be quick (when there are lots of monkey patches,
251
- # like in Rails). However, it should be efficient enough on other rubies.
252
- # @see https://github.com/jruby/jruby/issues/525
253
- # @return [Enumerator, Array] on JRuby 1.9 and higher returns Array, on
254
- # other rubies returns Enumerator
249
+ # @return [Array]
255
250
  def candidates
256
251
  enum = Enumerator.new do |y|
257
252
  (0...number_of_candidates).each do |num|
258
253
  y.yield candidate(num)
259
254
  end
260
255
  end
261
- Helpers::Platform.jruby_19? ? enum.to_a : enum
256
+ enum
262
257
  end
263
258
 
264
259
  # @return [Boolean] Whether YARD docs are available for this module.
data/lib/pry.rb CHANGED
@@ -13,7 +13,6 @@ require 'pry/helpers'
13
13
 
14
14
  require 'pry/basic_object'
15
15
  require 'pry/prompt'
16
- require 'pry/plugins'
17
16
  require 'pry/code_object'
18
17
  require 'pry/exceptions'
19
18
  require 'pry/hooks'
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.1
4
+ version: 0.14.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Mair (banisterfiend)
8
8
  - Conrad Irwin
9
9
  - Ryan Fitzgerald
10
10
  - Kyrylo Silin
11
- autorequire:
11
+ autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2020-04-12 00:00:00.000000000 Z
14
+ date: 2023-01-09 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: coderay
@@ -171,7 +171,6 @@ files:
171
171
  - lib/pry/object_path.rb
172
172
  - lib/pry/output.rb
173
173
  - lib/pry/pager.rb
174
- - lib/pry/plugins.rb
175
174
  - lib/pry/prompt.rb
176
175
  - lib/pry/pry_class.rb
177
176
  - lib/pry/pry_instance.rb
@@ -201,7 +200,7 @@ metadata:
201
200
  changelog_uri: https://github.com/pry/pry/blob/master/CHANGELOG.md
202
201
  source_code_uri: https://github.com/pry/pry
203
202
  bug_tracker_uri: https://github.com/pry/pry/issues
204
- post_install_message:
203
+ post_install_message:
205
204
  rdoc_options: []
206
205
  require_paths:
207
206
  - lib
@@ -209,15 +208,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
209
208
  requirements:
210
209
  - - ">="
211
210
  - !ruby/object:Gem::Version
212
- version: 1.9.3
211
+ version: '2.0'
213
212
  required_rubygems_version: !ruby/object:Gem::Requirement
214
213
  requirements:
215
214
  - - ">="
216
215
  - !ruby/object:Gem::Version
217
216
  version: '0'
218
217
  requirements: []
219
- rubygems_version: 3.1.2
220
- signing_key:
218
+ rubygems_version: 3.4.1
219
+ signing_key:
221
220
  specification_version: 4
222
221
  summary: A runtime developer console and IRB alternative with powerful introspection
223
222
  capabilities.
data/lib/pry/plugins.rb DELETED
@@ -1,139 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'ostruct'
4
-
5
- class Pry
6
- class PluginManager
7
- PRY_PLUGIN_PREFIX = /^pry-/.freeze
8
-
9
- # Placeholder when no associated gem found, displays warning
10
- class NoPlugin
11
- def initialize(name)
12
- @name = name
13
- end
14
-
15
- def method_missing(*)
16
- warn "Warning: The plugin '#{@name}' was not found! (no gem found)"
17
- super
18
- end
19
-
20
- def respond_to_missing?(*)
21
- false
22
- end
23
- end
24
-
25
- class Plugin
26
- attr_accessor :name, :gem_name, :enabled, :spec, :active
27
-
28
- def initialize(name, gem_name, spec, enabled)
29
- @name = name
30
- @gem_name = gem_name
31
- @enabled = enabled
32
- @spec = spec
33
- end
34
-
35
- # Disable a plugin. (prevents plugin from being loaded, cannot
36
- # disable an already activated plugin)
37
- def disable!
38
- self.enabled = false
39
- end
40
-
41
- # Enable a plugin. (does not load it immediately but puts on
42
- # 'white list' to be loaded)
43
- def enable!
44
- self.enabled = true
45
- end
46
-
47
- # Load the Command line options defined by this plugin (if they exist)
48
- def load_cli_options
49
- cli_options_file = File.join(spec.full_gem_path, "lib/#{spec.name}/cli.rb")
50
- return unless File.exist?(cli_options_file)
51
-
52
- if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.4.4")
53
- cli_options_file = File.realpath(cli_options_file)
54
- end
55
- require cli_options_file
56
- end
57
-
58
- # Activate the plugin (require the gem - enables/loads the
59
- # plugin immediately at point of call, even if plugin is
60
- # disabled)
61
- # Does not reload plugin if it's already active.
62
- def activate!
63
- # Create the configuration object for the plugin.
64
- Pry.config.send("#{gem_name.tr('-', '_')}=", OpenStruct.new)
65
-
66
- begin
67
- require gem_name unless active?
68
- rescue LoadError => e
69
- warn "Found plugin #{gem_name}, but could not require '#{gem_name}'"
70
- warn e
71
- rescue StandardError => e
72
- warn "require '#{gem_name}' # Failed, saying: #{e}"
73
- end
74
-
75
- self.active = true
76
- self.enabled = true
77
- end
78
-
79
- alias active? active
80
- alias enabled? enabled
81
-
82
- def supported?
83
- pry_version = Gem::Version.new(VERSION)
84
- spec.dependencies.each do |dependency|
85
- if dependency.name == "pry"
86
- return dependency.requirement.satisfied_by?(pry_version)
87
- end
88
- end
89
- true
90
- end
91
- end
92
-
93
- def initialize
94
- @plugins = []
95
- end
96
-
97
- # Find all installed Pry plugins and store them in an internal array.
98
- def locate_plugins
99
- gem_list.each do |gem|
100
- next if gem.name !~ PRY_PLUGIN_PREFIX
101
-
102
- plugin_name = gem.name.split('-', 2).last
103
- plugin = Plugin.new(plugin_name, gem.name, gem, false)
104
- @plugins << plugin.tap(&:enable!) if plugin.supported? && !plugin_located?(plugin)
105
- end
106
- @plugins
107
- end
108
-
109
- # @return [Hash] A hash with all plugin names (minus the 'pry-') as
110
- # keys and Plugin objects as values.
111
- def plugins
112
- h = Hash.new { |_, key| NoPlugin.new(key) }
113
- @plugins.each do |plugin|
114
- h[plugin.name] = plugin
115
- end
116
- h
117
- end
118
-
119
- # Require all enabled plugins, disabled plugins are skipped.
120
- def load_plugins
121
- @plugins.each do |plugin|
122
- plugin.activate! if plugin.enabled?
123
- end
124
- end
125
-
126
- private
127
-
128
- def plugin_located?(plugin)
129
- @plugins.any? { |existing| existing.gem_name == plugin.gem_name }
130
- end
131
-
132
- def gem_list
133
- Gem.refresh
134
- return Gem::Specification if Gem::Specification.respond_to?(:each)
135
-
136
- Gem.source_index.find_name('')
137
- end
138
- end
139
- end