pry 0.14.1 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +68 -2
- data/README.md +47 -30
- data/lib/pry/basic_object.rb +1 -1
- data/lib/pry/class_command.rb +2 -2
- data/lib/pry/cli.rb +6 -2
- data/lib/pry/code.rb +0 -8
- data/lib/pry/code_object.rb +2 -2
- data/lib/pry/command.rb +1 -1
- data/lib/pry/command_set.rb +2 -2
- data/lib/pry/command_state.rb +11 -6
- data/lib/pry/commands/amend_line.rb +1 -1
- data/lib/pry/commands/cd.rb +2 -0
- data/lib/pry/commands/edit.rb +2 -0
- data/lib/pry/commands/find_method.rb +1 -1
- data/lib/pry/commands/ls/config.rb +51 -0
- data/lib/pry/commands/ls/constants.rb +2 -2
- data/lib/pry/commands/ls.rb +0 -21
- data/lib/pry/commands/raise_up.rb +1 -1
- data/lib/pry/commands/ri.rb +1 -1
- data/lib/pry/commands/shell_command.rb +1 -1
- data/lib/pry/commands/shell_mode.rb +1 -0
- data/lib/pry/commands/watch_expression/expression.rb +1 -1
- data/lib/pry/commands/watch_expression.rb +4 -6
- data/lib/pry/config.rb +26 -29
- data/lib/pry/control_d_handler.rb +1 -1
- data/lib/pry/core_extensions.rb +1 -1
- data/lib/pry/editor.rb +3 -1
- data/lib/pry/exception_handler.rb +7 -2
- data/lib/pry/helpers/command_helpers.rb +1 -1
- data/lib/pry/helpers/platform.rb +1 -6
- data/lib/pry/helpers/text.rb +5 -5
- data/lib/pry/indent.rb +13 -11
- data/lib/pry/input/simple_stdio.rb +13 -0
- data/lib/pry/input_completer.rb +2 -2
- data/lib/pry/method/patcher.rb +2 -2
- data/lib/pry/method/weird_method_locator.rb +2 -2
- data/lib/pry/method.rb +4 -4
- data/lib/pry/pry_class.rb +17 -2
- data/lib/pry/pry_instance.rb +7 -45
- data/lib/pry/repl.rb +66 -4
- data/lib/pry/ring.rb +2 -2
- data/lib/pry/slop.rb +1 -1
- data/lib/pry/syntax_highlighter.rb +1 -1
- data/lib/pry/version.rb +1 -1
- data/lib/pry/warning.rb +3 -10
- data/lib/pry/wrapped_module/candidate.rb +9 -8
- data/lib/pry/wrapped_module.rb +3 -8
- data/lib/pry.rb +3 -0
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e614551c579377a965416df68c4e2a90f0e0e6731d78010f7a570d4b730cfb2a
|
4
|
+
data.tar.gz: 86ed82a2dc55f826d38ae2a20f22929dbbf11b7f5d79dcfc0740a20f6779ca01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 902a35c83b2b00518504054939ab688f883ecf78f2358f90462a6b06290a80de7c52735d4d71e40e27e1d47914fd7bac6b537bdf916a322d7da35483b21afef9
|
7
|
+
data.tar.gz: b03f296f12ed93fb92e7b6f7243f250cc4ada6c08b70e52a5b8df81c6707aa9c3124d60b03e0e922b5626b543c59059c7300e626858b59706140df7cd19d9fb8
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,70 @@
|
|
1
|
-
###
|
1
|
+
### [v0.15.0][v0.15.0] (November 15, 2024)
|
2
|
+
|
3
|
+
#### Features
|
4
|
+
|
5
|
+
* Added support for Reline
|
6
|
+
([#2298](https://github.com/pry/pry/pull/2298))
|
7
|
+
* Added support for Ruby 3.3
|
8
|
+
([#2295](https://github.com/pry/pry/pull/2295))
|
9
|
+
* Added Pry::Input::SimpleStdio for dumb terminals when Reline is in use
|
10
|
+
([#2304](https://github.com/pry/pry/pull/2304))
|
11
|
+
* Remove OpenStruct usage
|
12
|
+
([#2307](https://github.com/pry/pry/pull/2307))
|
13
|
+
([#2309](https://github.com/pry/pry/pull/2309))
|
14
|
+
* Disable coloring of output when NO_COLOR is set.
|
15
|
+
([#2323])(https://github.com/pry/pry/pull/2323))
|
16
|
+
* Add `pry --no-multiline` flag to keep single line prompt.
|
17
|
+
([#2327](https://github.com/pry/pry/pull/2327))
|
18
|
+
|
19
|
+
#### Bug Fixes
|
20
|
+
|
21
|
+
* Fix typos on docs and and comments
|
22
|
+
([#2300](https://github.com/pry/pry/pull/2300))
|
23
|
+
([#2301](https://github.com/pry/pry/pull/2301))
|
24
|
+
* Fix 'calling clear method' on user code when defined in pry context.
|
25
|
+
([#2291](https://github.com/pry/pry/pull/2291))
|
26
|
+
* Fix arguments WatchExpression#add_expression
|
27
|
+
([#2278](https://github.com/pry/pry/pull/2278))
|
28
|
+
|
29
|
+
### Breaking changes
|
30
|
+
|
31
|
+
* Remove support for deprecated `Pry.config.prompt = [proc {}, proc {}]`
|
32
|
+
Use Pry::Prompt API instead
|
33
|
+
([#2308](https://github.com/pry/pry/pull/2308))
|
34
|
+
* Remove deprecated `Pry.config.exception_whitelist`.
|
35
|
+
Use `Pry.config.unrescued_exceptions` instead.
|
36
|
+
([#2326](https://github.com/pry/pry/pull/2326))
|
37
|
+
|
38
|
+
### [v0.14.2][v0.14.2] (January 9, 2023)
|
39
|
+
|
40
|
+
#### Features
|
41
|
+
|
42
|
+
* Configure `code` as a supported editor on Pry::Editor
|
43
|
+
([#2236](https://github.com/pry/pry/pull/2236))
|
44
|
+
* Added support for Ruby 3.2
|
45
|
+
([#2263](https://github.com/pry/pry/pull/2263))
|
46
|
+
* Added support for Ruby 3.1
|
47
|
+
([#2228](https://github.com/pry/pry/pull/2228))
|
48
|
+
|
49
|
+
#### Bug fixes
|
50
|
+
|
51
|
+
* Short circuit eval regexes in finding module definition
|
52
|
+
([#2253](https://github.com/pry/pry/pull/2253))
|
53
|
+
* Revert "Escape non-printing characters"
|
54
|
+
([#2235](https://github.com/pry/pry/pull/2235))
|
55
|
+
* Fixed bug where WeirdMethodLocator would fail to find the source of a method breaking whereami
|
56
|
+
([#2244](https://github.com/pry/pry/pull/2244))
|
57
|
+
* Fixed bug where pry would throw an FrozenError when dealing with incomplete tokens
|
58
|
+
([#2136](https://github.com/pry/pry/pull/2136))
|
59
|
+
* Restore --no-history CLI flag functionality
|
60
|
+
([#2196](https://github.com/pry/pry/pull/2196))
|
61
|
+
* Fixed bug where reading from the `_out_` sticky local variable could return
|
62
|
+
wrong results ([#2201](https://github.com/pry/pry/pull/2201))
|
63
|
+
|
64
|
+
#### Breaking Changes
|
65
|
+
|
66
|
+
* Remove support for Ruby 1.9 and JRuby < 9.0
|
67
|
+
([#2239](https://github.com/pry/pry/pull/2239))
|
2
68
|
|
3
69
|
### [v0.14.1][v0.14.1] (April 12, 2021)
|
4
70
|
|
@@ -946,7 +1012,7 @@ complete CHANGELOG:
|
|
946
1012
|
* _pry_ now passed as 3rd parameter to :before_session hook
|
947
1013
|
* ls colors now configurable via Pry.config.ls.local_var_color = :bright_red etc
|
948
1014
|
* ls separator configurable via, e.g Pry.config.ls.separator = " "
|
949
|
-
* Pry.view_clip() now only calls inspect on a few immediates, otherwise uses the #<> syntax, which has been truncated further to exclude
|
1015
|
+
* Pry.view_clip() now only calls inspect on a few immediates, otherwise uses the #<> syntax, which has been truncated further to exclude the mem address, again related to #245
|
950
1016
|
|
951
1017
|
### 0.9.3 (2011/7/27)
|
952
1018
|
* cat --ex (cats 5 lines above and below line in file where exception was raised)
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Pry
|
2
2
|
===
|
3
3
|
|
4
|
-
[![
|
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://pry.github.
|
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.
|
84
|
+
gem 'pry', '~> 0.15.0'
|
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
|
-
=>
|
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 '
|
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
|
274
|
-
Pry#methods:
|
275
|
-
pry(Pry):1> show-source
|
276
|
-
|
277
|
-
From: /home/john/ruby/projects/pry/lib/pry/pry_instance.rb:
|
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
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
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.
|
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-
|
344
|
+
pry(Gem):1> show-source try_activate -d
|
343
345
|
|
344
|
-
From: /Users/john
|
345
|
-
|
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
|
|
@@ -399,18 +413,21 @@ description if the `--help` option is available.
|
|
399
413
|
|
400
414
|
### Use Pry as your Rails Console
|
401
415
|
|
402
|
-
|
403
|
-
gem](https://github.com/rweng/pry-rails) to your Gemfile. This replaces the
|
404
|
-
default console with Pry, in addition to loading the Rails console helpers and
|
405
|
-
adding some useful Rails-specific commands.
|
406
|
-
|
407
|
-
If you don't want to change your Gemfile, you can still run a Pry console in
|
408
|
-
your app's environment using Pry's `-r` flag:
|
416
|
+
You can run a Pry console in your app's environment using Pry's `-r` flag:
|
409
417
|
|
410
418
|
```sh
|
411
419
|
pry -r ./config/environment
|
412
420
|
```
|
413
421
|
|
422
|
+
Or start the rails console (`bin/rails console`) and then type `pry`.
|
423
|
+
|
424
|
+
It's also possible to use Pry as your Rails console by adding [the pry-rails
|
425
|
+
gem](https://github.com/pry/pry-rails) to your Gemfile. This replaces the
|
426
|
+
default console with Pry, in addition to loading the Rails console helpers and
|
427
|
+
adding some useful Rails-specific commands.
|
428
|
+
|
429
|
+
**Note that `pry-rails` is not currently maintained.**
|
430
|
+
|
414
431
|
Also check out the
|
415
432
|
[wiki](https://github.com/pry/pry/wiki/Setting-up-Rails-or-Heroku-to-use-Pry)
|
416
433
|
for more information about integrating Pry with Rails.
|
@@ -427,8 +444,8 @@ putting the line `Pry.color = false` in your `pryrc` file.
|
|
427
444
|
Supported Rubies
|
428
445
|
----------------
|
429
446
|
|
430
|
-
* CRuby >=
|
431
|
-
* JRuby >=
|
447
|
+
* CRuby >= 2.0.0
|
448
|
+
* JRuby >= 9.0
|
432
449
|
|
433
450
|
Contact
|
434
451
|
-------
|
data/lib/pry/basic_object.rb
CHANGED
data/lib/pry/class_command.rb
CHANGED
@@ -137,7 +137,7 @@ class Pry
|
|
137
137
|
# end
|
138
138
|
# end
|
139
139
|
#
|
140
|
-
# @example Define the
|
140
|
+
# @example Define the invocation block anywhere you want
|
141
141
|
# def subcommands(cmd)
|
142
142
|
# cmd.command :download do |opt|
|
143
143
|
# description 'Downloads a content from a server'
|
@@ -172,7 +172,7 @@ class Pry
|
|
172
172
|
|
173
173
|
# The actual body of your command should go here.
|
174
174
|
#
|
175
|
-
# The `opts`
|
175
|
+
# The `opts` method can be called to get the options that Pry::Slop has passed,
|
176
176
|
# and `args` gives the remaining, unparsed arguments.
|
177
177
|
#
|
178
178
|
# The return value of this method is discarded unless the command was
|
data/lib/pry/cli.rb
CHANGED
@@ -122,7 +122,7 @@ Pry::CLI.add_options do
|
|
122
122
|
banner(
|
123
123
|
"Usage: pry [OPTIONS]\n" \
|
124
124
|
"Start a Pry session.\n" \
|
125
|
-
"See http://
|
125
|
+
"See http://pry.github.io/ for more information.\n" \
|
126
126
|
"Copyright (c) 2016 John Mair (banisterfiend)" \
|
127
127
|
)
|
128
128
|
|
@@ -138,13 +138,17 @@ Pry::CLI.add_options do
|
|
138
138
|
end
|
139
139
|
|
140
140
|
on "no-history", "Disable history loading" do
|
141
|
-
Pry.config.
|
141
|
+
Pry.config.history_load = false
|
142
142
|
end
|
143
143
|
|
144
144
|
on "no-color", "Disable syntax highlighting for session" do
|
145
145
|
Pry.config.color = false
|
146
146
|
end
|
147
147
|
|
148
|
+
on "no-multiline", "Disables multiline (defaults to true with Reline)" do
|
149
|
+
Pry.config.multiline = false
|
150
|
+
end
|
151
|
+
|
148
152
|
on :f, "Suppress loading of pryrc" do
|
149
153
|
Pry.config.should_load_rc = false
|
150
154
|
Pry.config.should_load_local_rc = false
|
data/lib/pry/code.rb
CHANGED
@@ -346,14 +346,6 @@ class Pry
|
|
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
|
data/lib/pry/code_object.rb
CHANGED
@@ -11,7 +11,7 @@ class Pry
|
|
11
11
|
# object the user wants (applying precedence rules in doing so -- i.e methods
|
12
12
|
# get precedence over commands with the same name) and 2. Returning
|
13
13
|
# the appropriate object. If the user fails to provide a string
|
14
|
-
#
|
14
|
+
# identifier for the object (i.e they pass in `nil` or "") then the
|
15
15
|
# object looked up will be the 'current method' or 'current class'
|
16
16
|
# associated with the Binding.
|
17
17
|
#
|
@@ -97,7 +97,7 @@ class Pry
|
|
97
97
|
nil
|
98
98
|
end
|
99
99
|
|
100
|
-
# when no
|
100
|
+
# when no parameter is given (i.e CodeObject.lookup(nil)), then we
|
101
101
|
# lookup the 'current object' from the binding.
|
102
102
|
def empty_lookup
|
103
103
|
return nil if str && !str.empty?
|
data/lib/pry/command.rb
CHANGED
data/lib/pry/command_set.rb
CHANGED
@@ -145,7 +145,7 @@ class Pry
|
|
145
145
|
# Imports all the commands from one or more sets.
|
146
146
|
# @param [Array<CommandSet>] sets Command sets, all of the commands of which
|
147
147
|
# will be imported.
|
148
|
-
# @return [Pry::CommandSet] Returns the
|
148
|
+
# @return [Pry::CommandSet] Returns the receiver (a command set).
|
149
149
|
def import(*sets)
|
150
150
|
sets.each do |set|
|
151
151
|
@commands.merge! set.to_hash
|
@@ -157,7 +157,7 @@ class Pry
|
|
157
157
|
# Imports some commands from a set
|
158
158
|
# @param [CommandSet] set Set to import commands from
|
159
159
|
# @param [Array<String>] matches Commands to import
|
160
|
-
# @return [Pry::CommandSet] Returns the
|
160
|
+
# @return [Pry::CommandSet] Returns the receiver (a command set).
|
161
161
|
def import_from(set, *matches)
|
162
162
|
helper_module.send :include, set.helper_module
|
163
163
|
matches.each do |match|
|
data/lib/pry/command_state.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'ostruct'
|
4
|
-
|
5
3
|
class Pry
|
6
4
|
# CommandState is a data structure to hold per-command state.
|
7
5
|
#
|
@@ -20,12 +18,19 @@ class Pry
|
|
20
18
|
@command_state = {}
|
21
19
|
end
|
22
20
|
|
23
|
-
def state_for(
|
24
|
-
@command_state[
|
21
|
+
def state_for(command_class)
|
22
|
+
@command_state[command_class] ||= command_struct(command_class)
|
23
|
+
end
|
24
|
+
|
25
|
+
def reset(command_class)
|
26
|
+
@command_state[command_class] = command_struct(command_class)
|
25
27
|
end
|
26
28
|
|
27
|
-
|
28
|
-
|
29
|
+
private
|
30
|
+
|
31
|
+
def command_struct(command_class)
|
32
|
+
Struct.new(:command, *command_class.command_options[:state])
|
33
|
+
.new(command: command_class)
|
29
34
|
end
|
30
35
|
end
|
31
36
|
end
|
@@ -76,7 +76,7 @@ class Pry
|
|
76
76
|
|
77
77
|
# Takes two numbers that are 1-indexed, and returns a range (or
|
78
78
|
# number) that is 0-indexed. 1-indexed means the first element is
|
79
|
-
#
|
79
|
+
# identified by 1 rather than by 0 (as is the case for Ruby arrays).
|
80
80
|
# @param [Fixnum] start_line_number One-indexed number.
|
81
81
|
# @param [Fixnum] end_line_number One-indexed number.
|
82
82
|
# @return [Range] The zero-indexed range.
|
data/lib/pry/commands/cd.rb
CHANGED
data/lib/pry/commands/edit.rb
CHANGED
@@ -128,7 +128,7 @@ class Pry
|
|
128
128
|
next if klass.autoload?(name)
|
129
129
|
|
130
130
|
begin
|
131
|
-
const = klass.const_get(name)
|
131
|
+
const = Pry::Method.singleton_class_of(klass.const_get(name))
|
132
132
|
rescue RescuableException # rubocop:disable Lint/HandleExceptions
|
133
133
|
# constant loading is an inexact science at the best of times,
|
134
134
|
# this often happens when a constant was .autoload? but someone
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Pry
|
4
|
+
class Command
|
5
|
+
class Ls < Pry::ClassCommand
|
6
|
+
class Config
|
7
|
+
attr_accessor :heading_color,
|
8
|
+
:public_method_color,
|
9
|
+
:private_method_color,
|
10
|
+
:protected_method_color,
|
11
|
+
:method_missing_color,
|
12
|
+
:local_var_color,
|
13
|
+
:pry_var_color, # e.g. _, pry_instance, _file_
|
14
|
+
:instance_var_color, # e.g. @foo
|
15
|
+
:class_var_color, # e.g. @@foo
|
16
|
+
:global_var_color, # e.g. $CODERAY_DEBUG, $foo
|
17
|
+
:builtin_global_color, # e.g. $stdin, $-w, $PID
|
18
|
+
:pseudo_global_color, # e.g. $~, $1..$9, $LAST_MATCH_INFO
|
19
|
+
:constant_color, # e.g. VERSION, ARGF
|
20
|
+
:class_constant_color, # e.g. Object, Kernel
|
21
|
+
:exception_constant_color, # e.g. Exception, RuntimeError
|
22
|
+
:unloaded_constant_color, # Constant that is still in .autoload?
|
23
|
+
:separator,
|
24
|
+
:ceiling
|
25
|
+
|
26
|
+
def self.default
|
27
|
+
config = new
|
28
|
+
config.heading_color = :bright_blue
|
29
|
+
config.public_method_color = :default
|
30
|
+
config.private_method_color = :blue
|
31
|
+
config.protected_method_color = :blue
|
32
|
+
config.method_missing_color = :bright_red
|
33
|
+
config.local_var_color = :yellow
|
34
|
+
config.pry_var_color = :default
|
35
|
+
config.instance_var_color = :blue
|
36
|
+
config.class_var_color = :bright_blue
|
37
|
+
config.global_var_color = :default
|
38
|
+
config.builtin_global_color = :cyan
|
39
|
+
config.pseudo_global_color = :cyan
|
40
|
+
config.constant_color = :default
|
41
|
+
config.class_constant_color = :blue
|
42
|
+
config.exception_constant_color = :magenta
|
43
|
+
config.unloaded_constant_color = :yellow
|
44
|
+
config.separator = " "
|
45
|
+
config.ceiling = [Object, Module, Class]
|
46
|
+
config
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -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
|
-
|
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
|
data/lib/pry/commands/ls.rb
CHANGED
@@ -3,27 +3,6 @@
|
|
3
3
|
class Pry
|
4
4
|
class Command
|
5
5
|
class Ls < Pry::ClassCommand
|
6
|
-
DEFAULT_OPTIONS = {
|
7
|
-
heading_color: :bright_blue,
|
8
|
-
public_method_color: :default,
|
9
|
-
private_method_color: :blue,
|
10
|
-
protected_method_color: :blue,
|
11
|
-
method_missing_color: :bright_red,
|
12
|
-
local_var_color: :yellow,
|
13
|
-
pry_var_color: :default, # e.g. _, pry_instance, _file_
|
14
|
-
instance_var_color: :blue, # e.g. @foo
|
15
|
-
class_var_color: :bright_blue, # e.g. @@foo
|
16
|
-
global_var_color: :default, # e.g. $CODERAY_DEBUG, $eventmachine_library
|
17
|
-
builtin_global_color: :cyan, # e.g. $stdin, $-w, $PID
|
18
|
-
pseudo_global_color: :cyan, # e.g. $~, $1..$9, $LAST_MATCH_INFO
|
19
|
-
constant_color: :default, # e.g. VERSION, ARGF
|
20
|
-
class_constant_color: :blue, # e.g. Object, Kernel
|
21
|
-
exception_constant_color: :magenta, # e.g. Exception, RuntimeError
|
22
|
-
unloaded_constant_color: :yellow, # Any constant that is still in .autoload? state
|
23
|
-
separator: " ",
|
24
|
-
ceiling: [Object, Module, Class]
|
25
|
-
}.freeze
|
26
|
-
|
27
6
|
match 'ls'
|
28
7
|
group 'Context'
|
29
8
|
description 'Show the list of vars and methods in the current scope.'
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class Pry
|
4
|
-
# N.B. using a regular
|
4
|
+
# N.B. using a regular expression here so that "raise-up 'foo'" does the right thing.
|
5
5
|
class Command
|
6
6
|
class RaiseUp < Pry::ClassCommand
|
7
7
|
match(/raise-up(!?\b.*)/)
|
data/lib/pry/commands/ri.rb
CHANGED
@@ -7,7 +7,7 @@ class Pry
|
|
7
7
|
group 'Input and Output'
|
8
8
|
description "All text following a '.' is forwarded to the shell."
|
9
9
|
command_options listing: '.<shell command>', use_prefix: false,
|
10
|
-
takes_block: true
|
10
|
+
takes_block: true, state: %i[old_pwd]
|
11
11
|
|
12
12
|
banner <<-'BANNER'
|
13
13
|
Usage: .COMMAND_NAME
|
@@ -6,6 +6,7 @@ class Pry
|
|
6
6
|
match 'shell-mode'
|
7
7
|
group 'Input and Output'
|
8
8
|
description 'Toggle shell mode. Bring in pwd prompt and file completion.'
|
9
|
+
command_options state: %i[disabled prev_prompt]
|
9
10
|
|
10
11
|
banner <<-'BANNER'
|
11
12
|
Toggle shell mode. Bring in pwd prompt and file completion.
|
@@ -23,7 +23,7 @@ class Pry
|
|
23
23
|
|
24
24
|
# Has the value of the expression changed?
|
25
25
|
#
|
26
|
-
# We use the pretty-printed string
|
26
|
+
# We use the pretty-printed string representation to detect differences
|
27
27
|
# as this avoids problems with dup (causes too many differences) and ==
|
28
28
|
# (causes too few)
|
29
29
|
def changed?
|
@@ -7,7 +7,7 @@ class Pry
|
|
7
7
|
group 'Context'
|
8
8
|
description 'Watch the value of an expression and print a notification ' \
|
9
9
|
'whenever it changes.'
|
10
|
-
command_options use_prefix: false
|
10
|
+
command_options use_prefix: false, state: %i[watch_expressions]
|
11
11
|
|
12
12
|
banner <<-'BANNER'
|
13
13
|
Usage: watch [EXPRESSION]
|
@@ -46,7 +46,7 @@ class Pry
|
|
46
46
|
list
|
47
47
|
else
|
48
48
|
add_hook
|
49
|
-
add_expression
|
49
|
+
add_expression
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
@@ -88,15 +88,13 @@ class Pry
|
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
|
-
|
92
|
-
# https://github.com/pry/pry/commit/b031df2f2f5850ee6e9018f33d35f3485a9b0423
|
93
|
-
def add_expression(_arguments)
|
91
|
+
def add_expression
|
94
92
|
expressions << Expression.new(pry_instance, target, arg_string)
|
95
93
|
output.puts "Watching #{Code.new(arg_string).highlighted}"
|
96
94
|
end
|
97
95
|
|
98
96
|
def add_hook
|
99
|
-
hook = [
|
97
|
+
hook = %i[after_eval watch_expression]
|
100
98
|
return if pry_instance.hooks.hook_exists?(*hook)
|
101
99
|
|
102
100
|
pry_instance.hooks.add_hook(*hook) do |_, pry_instance|
|