pry 0.11.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 +157 -1
- data/LICENSE +1 -1
- data/README.md +13 -30
- data/bin/pry +0 -4
- data/lib/pry/cli.rb +17 -24
- data/lib/pry/code/code_file.rb +5 -4
- data/lib/pry/code/code_range.rb +3 -3
- data/lib/pry/code/loc.rb +14 -8
- data/lib/pry/code.rb +6 -6
- data/lib/pry/code_object.rb +4 -4
- data/lib/pry/color_printer.rb +1 -0
- data/lib/pry/command.rb +36 -29
- data/lib/pry/command_set.rb +17 -52
- 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 +9 -8
- 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 +9 -9
- data/lib/pry/commands/easter_eggs.rb +3 -3
- data/lib/pry/commands/edit.rb +8 -7
- data/lib/pry/commands/exit.rb +2 -1
- data/lib/pry/commands/find_method.rb +11 -13
- 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 +1 -1
- data/lib/pry/commands/gem_search.rb +2 -2
- 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 +9 -8
- data/lib/pry/commands/import_set.rb +2 -1
- data/lib/pry/commands/install_command.rb +7 -6
- data/lib/pry/commands/list_inspectors.rb +2 -2
- data/lib/pry/commands/ls/constants.rb +4 -4
- data/lib/pry/commands/ls/formatter.rb +3 -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/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 +0 -1
- data/lib/pry/commands/ls.rb +27 -30
- data/lib/pry/commands/play.rb +1 -2
- data/lib/pry/commands/pry_backtrace.rb +1 -1
- data/lib/pry/commands/raise_up.rb +2 -1
- data/lib/pry/commands/ri.rb +5 -4
- data/lib/pry/commands/shell_command.rb +3 -2
- 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 +25 -18
- data/lib/pry/commands/show_source.rb +5 -2
- data/lib/pry/commands/stat.rb +1 -1
- data/lib/pry/commands/watch_expression.rb +9 -7
- data/lib/pry/commands/whereami.rb +4 -4
- data/lib/pry/commands/wtf.rb +15 -2
- data/lib/pry/config/behavior.rb +229 -205
- data/lib/pry/config/convenience.rb +24 -21
- data/lib/pry/config/default.rb +153 -143
- data/lib/pry/config/memoization.rb +41 -37
- data/lib/pry/config.rb +33 -9
- data/lib/pry/core_extensions.rb +4 -3
- data/lib/pry/editor.rb +5 -12
- data/lib/pry/exceptions.rb +0 -2
- data/lib/pry/helpers/base_helpers.rb +133 -4
- data/lib/pry/helpers/command_helpers.rb +5 -4
- data/lib/pry/helpers/documentation_helpers.rb +2 -2
- data/lib/pry/helpers/options_helpers.rb +5 -5
- data/lib/pry/helpers/platform.rb +58 -0
- data/lib/pry/helpers/table.rb +20 -15
- data/lib/pry/helpers/text.rb +3 -4
- data/lib/pry/helpers.rb +1 -0
- data/lib/pry/history.rb +21 -8
- data/lib/pry/hooks.rb +3 -3
- data/lib/pry/indent.rb +15 -17
- data/lib/pry/input_completer.rb +12 -7
- data/lib/pry/input_lock.rb +0 -2
- data/lib/pry/last_exception.rb +1 -1
- data/lib/pry/method/disowned.rb +2 -1
- data/lib/pry/method/patcher.rb +2 -2
- data/lib/pry/method/weird_method_locator.rb +7 -8
- data/lib/pry/method.rb +37 -31
- data/lib/pry/object_path.rb +5 -4
- data/lib/pry/output.rb +3 -2
- data/lib/pry/pager.rb +194 -186
- data/lib/pry/platform.rb +79 -81
- data/lib/pry/plugins.rb +7 -3
- data/lib/pry/prompt.rb +144 -25
- data/lib/pry/pry_class.rb +53 -29
- data/lib/pry/pry_instance.rb +88 -55
- data/lib/pry/repl.rb +33 -4
- data/lib/pry/repl_file_loader.rb +1 -2
- data/lib/pry/ring.rb +84 -0
- data/lib/pry/rubygem.rb +6 -6
- data/lib/pry/slop/commands.rb +3 -4
- data/lib/pry/slop/option.rb +19 -21
- data/lib/pry/slop.rb +17 -17
- data/lib/pry/terminal.rb +2 -1
- data/lib/pry/testable/mockable.rb +2 -2
- data/lib/pry/testable/pry_tester.rb +1 -1
- data/lib/pry/testable/utility.rb +2 -2
- data/lib/pry/testable/variables.rb +1 -1
- data/lib/pry/version.rb +1 -1
- data/lib/pry/wrapped_module/candidate.rb +2 -2
- data/lib/pry/wrapped_module.rb +15 -15
- data/lib/pry.rb +17 -47
- metadata +8 -20
- 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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6320662aa62bb2b7410cb900e5e0d75e075413da
|
|
4
|
+
data.tar.gz: d72635ecb0613ee87e6bf7fbc37c71573f1137ce
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 396ab2db71196633ab518104409ae367d67c9c9e64a318bdecbef0e40010364cc207211f808f2e616d9909ec93b256b5bc0f58a458f7ac97d195eee8ee6d7e71
|
|
7
|
+
data.tar.gz: f74d3c223f09b7d06af0a30500176a6caa10474646ce59fb787d6a5936ab420828a399679d55f7fa0a106ab2f5f45d622748cb13804af85032621151c1147a94
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,156 @@
|
|
|
1
1
|
### HEAD
|
|
2
2
|
|
|
3
|
+
### [v0.12.2][v0.12.2] (November 12, 2018)
|
|
4
|
+
|
|
5
|
+
#### Bug fixes
|
|
6
|
+
|
|
7
|
+
* Restore removed deprecations, which were removed by accident due to a bad
|
|
8
|
+
rebase.
|
|
9
|
+
|
|
10
|
+
### [v0.12.1][v0.12.1] (November 12, 2018)
|
|
11
|
+
|
|
12
|
+
#### Bug fixes
|
|
13
|
+
|
|
14
|
+
* Stopped creating a new hash each time `Pry::Prompt#[]` is invoked
|
|
15
|
+
([#1855](https://github.com/pry/pry/pull/1855))
|
|
16
|
+
* Fixed `less` pager not working when it's available
|
|
17
|
+
([#1861](https://github.com/pry/pry/pull/1861))
|
|
18
|
+
|
|
19
|
+
### [v0.12.0][v0.12.0] (November 5, 2018)
|
|
20
|
+
|
|
21
|
+
#### Major changes
|
|
22
|
+
|
|
23
|
+
* Dropped support for Rubinius ([#1785](https://github.com/pry/pry/pull/1785))
|
|
24
|
+
|
|
25
|
+
#### Features
|
|
26
|
+
|
|
27
|
+
* Added a new command, `clear-screen`, that clears the content of the screen Pry
|
|
28
|
+
is running in regardless of platform (Windows or UNIX-like)
|
|
29
|
+
([#1723](https://github.com/pry/pry/pull/1723))
|
|
30
|
+
* Added a new command, `gem-stat`, that prints gem statistics such as gem
|
|
31
|
+
dependencies and downloads ([#1707](https://github.com/pry/pry/pull/1707))
|
|
32
|
+
* Added support for nested exceptions for the `wtf` command
|
|
33
|
+
([#1791](https://github.com/pry/pry/pull/1791))
|
|
34
|
+
* Added support for dynamic prompt names
|
|
35
|
+
([#1833](https://github.com/pry/pry/pull/1833))
|
|
36
|
+
|
|
37
|
+
```rb
|
|
38
|
+
# pryrc
|
|
39
|
+
Pry.config.prompt_name = Pry.lazy { rand(100) }
|
|
40
|
+
|
|
41
|
+
# Session
|
|
42
|
+
[1] 80(main)>
|
|
43
|
+
[2] 87(main)>
|
|
44
|
+
[3] 30(main)>
|
|
45
|
+
```
|
|
46
|
+
* Added support for XDG Base Directory Specification
|
|
47
|
+
([#1609](https://github.com/pry/pry/pull/1609),
|
|
48
|
+
[#1844](https://github.com/pry/pry/pull/1844),
|
|
49
|
+
([#1848](https://github.com/pry/pry/pull/1848)))
|
|
50
|
+
* Removed the `simple-prompt`. Use `change-prompt simple` instead. The
|
|
51
|
+
`list-prompt` command was removed and embedded as `change-prompt --list`
|
|
52
|
+
([#1849](https://github.com/pry/pry/pull/1849))
|
|
53
|
+
|
|
54
|
+
#### API changes
|
|
55
|
+
|
|
56
|
+
* The following methods started accepting the new optional `config` parameter
|
|
57
|
+
([#1809](https://github.com/pry/pry/pull/1809)):
|
|
58
|
+
* `Pry::Helpers.tablify(things, line_length, config = Pry.config)`
|
|
59
|
+
* `Pry::Helpers.tablify_or_one_line(heading, things, config = Pry.config)`
|
|
60
|
+
* `Pry::Helpers.tablify_to_screen_width(things, options, config = Pry.config)`
|
|
61
|
+
* `Pry::Helpers::Table.new(items, args, config = Pry.config)`
|
|
62
|
+
|
|
63
|
+
You are expected to pass a session-local `_pry_.config` instead of the global
|
|
64
|
+
one.
|
|
65
|
+
|
|
66
|
+
* Added new method `Pry::Config.assign`, for creating a Config non-recursively
|
|
67
|
+
([#1725](https://github.com/pry/pry/issues/1725))
|
|
68
|
+
* Added `Pry.lazy`, which is a helper method for values that need to be
|
|
69
|
+
calculated dynamically. Currently, only `config.prompt_name` supports it
|
|
70
|
+
([#1833](https://github.com/pry/pry/pull/1833))
|
|
71
|
+
* `Pry::Prompt` responds to `.[]`, `.all` & `.add` now. The `Pry::Prompt.add`
|
|
72
|
+
method must be used for implementing custom prompts. See the API in the
|
|
73
|
+
documentation for the class ([#1846](https://github.com/pry/pry/pull/1846))
|
|
74
|
+
|
|
75
|
+
#### Breaking changes
|
|
76
|
+
|
|
77
|
+
* Deleted the `Pry::Helpers::Text.bright_default` alias for
|
|
78
|
+
`Pry::Helpers::Text.bold` ([#1795](https://github.com/pry/pry/pull/1795))
|
|
79
|
+
* `Pry::Helpers.tablify_to_screen_width(things, options, config = Pry.config)`
|
|
80
|
+
requires `options` or `nil` in place of them.
|
|
81
|
+
* `Pry::Helpers::Table.new(items, args, config = Pry.config)` requires `args`
|
|
82
|
+
or `nil` in place of them.
|
|
83
|
+
* Completely revamped `Pry::HistoryArray`
|
|
84
|
+
([#1818](https://github.com/pry/pry/pull/1818)).
|
|
85
|
+
* It's been renamed to `Pry::Ring`
|
|
86
|
+
([#1817](https://github.com/pry/pry/pull/1817))
|
|
87
|
+
* The implementation has changed and as result, the following methods were
|
|
88
|
+
removed:
|
|
89
|
+
* `Pry::Ring#length` (use `Pry::Ring#count` instead)
|
|
90
|
+
* `#empty?`, `#each`, `#inspect`, `#pop!`, `#to_h`
|
|
91
|
+
* To access old Enumerable methods convert the ring to Array with `#to_a`
|
|
92
|
+
* Fixed indexing for elements (e.g. `_pry_.input_ring[0]` always return some
|
|
93
|
+
element and not `nil`)
|
|
94
|
+
* Renamed `Pry.config.prompt_safe_objects` to `Pry.config.prompt_safe_contexts`
|
|
95
|
+
* Removed deprecated `Pry::CommandSet#before_command` &
|
|
96
|
+
`Pry::CommandSet#after_command` ([#1838](https://github.com/pry/pry/pull/1838))
|
|
97
|
+
|
|
98
|
+
#### Deprecations
|
|
99
|
+
|
|
100
|
+
* Deprecated `_pry_.input_array` & `_pry_.output_array` in favour of
|
|
101
|
+
`_pry_.input_ring` & `_pry_.output_ring` respectively
|
|
102
|
+
([#1814](https://github.com/pry/pry/pull/1814))
|
|
103
|
+
* Deprecated `Pry::Command#text`. Please use `#black`, `#white`, etc. directly
|
|
104
|
+
instead (as you would with helper functions from `BaseHelpers` and
|
|
105
|
+
`CommandHelpers`) ([#1701](https://github.com/pry/pry/pull/1701))
|
|
106
|
+
* Deprecated `_pry_.input_array` & `_pry_.output_array` in favour of
|
|
107
|
+
`_pry_.input_ring` and `_pry_.output_ring` respectively
|
|
108
|
+
([#1817](https://github.com/pry/pry/pull/1817))
|
|
109
|
+
* Deprecated `Pry::Platform`. Use `Pry::Helpers::Platform` instead. Note that
|
|
110
|
+
`Pry::Helpers::BaseHelpers` still includes the `Platform` methods but emits a
|
|
111
|
+
warning. You must switch to `Pry::Helpers::Platform` in your code
|
|
112
|
+
([#1838](https://github.com/pry/pry/pull/1838),
|
|
113
|
+
([#1845](https://github.com/pry/pry/pull/1845)))
|
|
114
|
+
* Deprecated `Pry::Prompt::MAP`. You should use `Pry::Prompt.all` instead to
|
|
115
|
+
access the same map ([#1846](https://github.com/pry/pry/pull/1846))
|
|
116
|
+
|
|
117
|
+
#### Bug fixes
|
|
118
|
+
|
|
119
|
+
* Fixed a bug where `cd Hash.new` reported `self` as an instance of Pry::Config
|
|
120
|
+
in the prompt ([#1725](https://github.com/pry/pry/pull/1725))
|
|
121
|
+
* Silenced the `Could not find files for the given pattern(s)` error message
|
|
122
|
+
coming from `where` on Windows, when `less` or another pager is not installed
|
|
123
|
+
([#1767](https://github.com/pry/pry/pull/1767))
|
|
124
|
+
* Fixed possible double loading of Pry plugins' `cli.rb` on Ruby (>= 2.4) due to
|
|
125
|
+
[the `realpath` changes while invoking
|
|
126
|
+
`require`](https://bugs.ruby-lang.org/issues/10222)
|
|
127
|
+
([#1762](https://github.com/pry/pry/pull/1762),
|
|
128
|
+
[#1774](https://github.com/pry/pry/pull/1762))
|
|
129
|
+
* Fixed `NoMethodError` on code objects that have a comment but no source when
|
|
130
|
+
invoking `show-source` ([#1779](https://github.com/pry/pry/pull/1779))
|
|
131
|
+
* Fixed `negative argument (ArgumentError)` upon pasting code with tabs, which
|
|
132
|
+
used to confuse automatic indentation
|
|
133
|
+
([#1771](https://github.com/pry/pry/pull/1771))
|
|
134
|
+
* Fixed Pry not being able to load history on Ruby 2.4.4+ when it contains the
|
|
135
|
+
null character ([#1789](https://github.com/pry/pry/pull/1789))
|
|
136
|
+
* Fixed Pry raising errors on `cd`'ing into some objects that redefine
|
|
137
|
+
`method_missing` and `respond_to?`
|
|
138
|
+
([#1811](https://github.com/pry/pry/pull/1811))
|
|
139
|
+
* Fixed bug when indentation leaves parts of input after pressing enter when
|
|
140
|
+
Readline is enabled with mode indicators for vi mode
|
|
141
|
+
([#1813](https://github.com/pry/pry/pull/1813),
|
|
142
|
+
[#1820](https://github.com/pry/pry/pull/1820),
|
|
143
|
+
[#1825](https://github.com/pry/pry/pull/1825))
|
|
144
|
+
* Fixed `edit` not writing to history
|
|
145
|
+
([#1749](https://github.com/pry/pry/issues/1749))
|
|
146
|
+
|
|
147
|
+
#### Other changes
|
|
148
|
+
|
|
149
|
+
* Deprecated the `Data` constant to match Ruby 2.5 in the `ls` command
|
|
150
|
+
([#1731](https://github.com/pry/pry/pull/1731))
|
|
151
|
+
|
|
152
|
+
### 0.11.3
|
|
153
|
+
|
|
3
154
|
#### Features
|
|
4
155
|
|
|
5
156
|
* Add Pry::Testable, an improved modular replacement for PryTestHelpers.
|
|
@@ -25,7 +176,7 @@ See pull request [#1673](https://github.com/pry/pry/pull/1673).
|
|
|
25
176
|
that users of the [Hanami](http://hanamirb.org/) web framework experienced and
|
|
26
177
|
reported since 2015.
|
|
27
178
|
|
|
28
|
-
See pull request [#
|
|
179
|
+
See pull request [#1689](https://github.com/pry/pry/pull/1689).
|
|
29
180
|
|
|
30
181
|
* Fix a bug where Method objects were not returned for setters inherited
|
|
31
182
|
from a default (Pry::Config::Default). Eg, this is no longer an error:
|
|
@@ -44,6 +195,7 @@ See pull request [#1691](https://github.com/pry/pry/pull/1691).
|
|
|
44
195
|
|
|
45
196
|
See pull request [#1674](https://github.com/pry/pry/pull/1674).
|
|
46
197
|
|
|
198
|
+
|
|
47
199
|
### 0.11.0
|
|
48
200
|
|
|
49
201
|
* Add alias 'whereami[?!]+' for 'whereami' command. ([#1597](https://github.com/pry/pry/pull/1597))
|
|
@@ -795,3 +947,7 @@ complete CHANGELOG:
|
|
|
795
947
|
|
|
796
948
|
### 0.1.0 (2010/12/8)
|
|
797
949
|
* release!
|
|
950
|
+
|
|
951
|
+
[v0.12.0]: https://github.com/pry/pry/releases/tag/v0.12.0
|
|
952
|
+
[v0.12.1]: https://github.com/pry/pry/releases/tag/v0.12.1
|
|
953
|
+
[v0.12.2]: https://github.com/pry/pry/releases/tag/v0.12.2
|
data/LICENSE
CHANGED
data/README.md
CHANGED
|
@@ -1,20 +1,10 @@
|
|
|
1
|
-
[](https://circleci.com/gh/pry/pry)
|
|
2
|
+
[](https://codeclimate.com/github/pry/pry)
|
|
3
|
+
[](http://badge.fury.io/rb/pry)
|
|
4
|
+
[](http://inch-ci.org/github/pry/pry)
|
|
5
|
+
[](https://rubygems.org/gems/pry)
|
|
4
6
|
<br><br>
|
|
5
|
-
) 2016<br>
|
|
8
|
-
|
|
9
|
-
**Please** [DONATE](http://pledgie.com/campaigns/15899) to the Pry project - Pry was a **huge** amount of work and every donation received is encouraging and supports Pry's continued development!
|
|
10
|
-
|
|
11
|
-
**Sponsors**
|
|
12
|
-
|
|
13
|
-
[Launch School](https://launchschool.com)<br/>
|
|
14
|
-
[Atomic Object](https://atomicobject.com/)<br/>
|
|
15
|
-
[Hashrocket](https://hashrocket.com/)<br/>
|
|
16
|
-
[Intridea](http://www.intridea.com)<br/>
|
|
17
|
-
[Gaslight](https://teamgaslight.com)<br/>
|
|
7
|
+

|
|
18
8
|
|
|
19
9
|
**Other Resources**
|
|
20
10
|
|
|
@@ -52,10 +42,10 @@ is trivial to set it to read from any object that has a `readline` method and wr
|
|
|
52
42
|
`puts` method - many other aspects of Pry are also configurable making
|
|
53
43
|
it a good choice for implementing custom shells.
|
|
54
44
|
|
|
55
|
-
Pry comes with an executable so it can be invoked at the command line.
|
|
56
|
-
|
|
57
|
-
be loaded if it exists. Type `pry --help` at the command
|
|
58
|
-
information.
|
|
45
|
+
Pry comes with an executable so it can be invoked at the command line. Just
|
|
46
|
+
enter `pry` to start. A `pryrc` file in `$XDG_CONFIG_HOME/pry/` or the user's
|
|
47
|
+
home directory will be loaded if it exists. Type `pry --help` at the command
|
|
48
|
+
line for more information.
|
|
59
49
|
|
|
60
50
|
Try `gem install pry-doc` for additional documentation on Ruby Core
|
|
61
51
|
methods. The additional docs are accessed through the `show-doc` and
|
|
@@ -180,9 +170,8 @@ present working directory into the Pry prompt and bring in (limited at this stag
|
|
|
180
170
|
We can also interpolate Ruby code directly into the shell by
|
|
181
171
|
using the normal `#{}` string interpolation syntax.
|
|
182
172
|
|
|
183
|
-
In the code below we're going to switch to `shell-mode` and edit the
|
|
184
|
-
|
|
185
|
-
reload the file.
|
|
173
|
+
In the code below we're going to switch to `shell-mode` and edit the `pryrc`
|
|
174
|
+
file. We'll then cat its contents and reload the file.
|
|
186
175
|
|
|
187
176
|
pry(main)> shell-mode
|
|
188
177
|
pry main:/home/john/ruby/projects/pry $ .cd ~
|
|
@@ -383,7 +372,7 @@ gem.
|
|
|
383
372
|
|
|
384
373
|
You can toggle the syntax highlighting on and off in a session by
|
|
385
374
|
using the `toggle-color` command. Alternatively, you can turn it off
|
|
386
|
-
permanently by putting the line `Pry.color = false` in your
|
|
375
|
+
permanently by putting the line `Pry.color = false` in your `pryrc`
|
|
387
376
|
file.
|
|
388
377
|
|
|
389
378
|
### Future Directions
|
|
@@ -399,9 +388,3 @@ between commands and running commands in background
|
|
|
399
388
|
### Contact
|
|
400
389
|
|
|
401
390
|
Problems or questions? File an issue at [GitHub](https://github.com/pry/pry/issues).
|
|
402
|
-
|
|
403
|
-
### Contributors
|
|
404
|
-
|
|
405
|
-
Pry is primarily the work of [John Mair (banisterfiend)](https://github.com/banister), for full list
|
|
406
|
-
of contributors see the
|
|
407
|
-
[CONTRIBUTORS](https://github.com/pry/pry/blob/master/CONTRIBUTORS) file.
|
data/bin/pry
CHANGED
data/lib/pry/cli.rb
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
class Pry
|
|
2
|
-
|
|
3
2
|
# Manage the processing of command line options
|
|
4
3
|
class CLI
|
|
5
|
-
|
|
6
4
|
NoOptionsError = Class.new(StandardError)
|
|
7
5
|
|
|
8
6
|
class << self
|
|
9
|
-
|
|
10
7
|
# @return [Proc] The Proc defining the valid command line options.
|
|
11
8
|
attr_accessor :options
|
|
12
9
|
|
|
@@ -57,22 +54,19 @@ class Pry
|
|
|
57
54
|
self.option_processors = nil
|
|
58
55
|
end
|
|
59
56
|
|
|
60
|
-
def parse_options(args=ARGV)
|
|
57
|
+
def parse_options(args = ARGV)
|
|
61
58
|
unless options
|
|
62
59
|
raise NoOptionsError, "No command line options defined! Use Pry::CLI.add_options to add command line options."
|
|
63
60
|
end
|
|
64
61
|
|
|
65
|
-
# Load config files etc first, ensuring that cli options will take precedence.
|
|
66
|
-
Pry.initial_session_setup
|
|
67
|
-
|
|
68
62
|
self.input_args = args
|
|
69
63
|
|
|
70
64
|
begin
|
|
71
65
|
opts = Pry::Slop.parse!(
|
|
72
66
|
args,
|
|
73
|
-
:
|
|
74
|
-
:
|
|
75
|
-
:
|
|
67
|
+
help: true,
|
|
68
|
+
multiple_switches: false,
|
|
69
|
+
strict: true,
|
|
76
70
|
&options
|
|
77
71
|
)
|
|
78
72
|
rescue Pry::Slop::InvalidOptionError
|
|
@@ -81,6 +75,7 @@ class Pry
|
|
|
81
75
|
exit
|
|
82
76
|
end
|
|
83
77
|
|
|
78
|
+
Pry.initial_session_setup
|
|
84
79
|
Pry.final_session_setup
|
|
85
80
|
|
|
86
81
|
# Option processors are optional.
|
|
@@ -113,16 +108,14 @@ class Pry
|
|
|
113
108
|
end
|
|
114
109
|
|
|
115
110
|
# Start the session (running any code passed with -e, if there is any)
|
|
116
|
-
Pry.start(context, :
|
|
111
|
+
Pry.start(context, input: StringIO.new(Pry.config.exec_string))
|
|
117
112
|
end
|
|
118
|
-
|
|
119
113
|
end
|
|
120
114
|
|
|
121
115
|
reset
|
|
122
116
|
end
|
|
123
117
|
end
|
|
124
118
|
|
|
125
|
-
|
|
126
119
|
# Bring in options defined by plugins
|
|
127
120
|
Pry::Slop.new do
|
|
128
121
|
on "no-plugins" do
|
|
@@ -136,12 +129,12 @@ end
|
|
|
136
129
|
|
|
137
130
|
# The default Pry command line options (before plugin options are included)
|
|
138
131
|
Pry::CLI.add_options do
|
|
139
|
-
banner
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
132
|
+
banner(
|
|
133
|
+
"Usage: pry [OPTIONS]\n" \
|
|
134
|
+
"Start a Pry session.\n" \
|
|
135
|
+
"See http://pryrepl.org/ for more information.\n"
|
|
136
|
+
)
|
|
137
|
+
|
|
145
138
|
on :e, :exec=, "A line of code to execute in context before the session starts" do |input|
|
|
146
139
|
Pry.config.exec_string += "\n" if Pry.config.exec_string.length > 0
|
|
147
140
|
Pry.config.exec_string += input
|
|
@@ -159,7 +152,7 @@ Copyright (c) 2016 John Mair (banisterfiend)
|
|
|
159
152
|
Pry.config.color = false
|
|
160
153
|
end
|
|
161
154
|
|
|
162
|
-
on :f, "Suppress loading of
|
|
155
|
+
on :f, "Suppress loading of pryrc" do
|
|
163
156
|
Pry.config.should_load_rc = false
|
|
164
157
|
Pry.config.should_load_local_rc = false
|
|
165
158
|
end
|
|
@@ -187,18 +180,18 @@ Copyright (c) 2016 John Mair (banisterfiend)
|
|
|
187
180
|
end
|
|
188
181
|
|
|
189
182
|
on "simple-prompt", "Enable simple prompt mode" do
|
|
190
|
-
Pry.config.prompt = Pry::
|
|
183
|
+
Pry.config.prompt = Pry::Prompt[:simple][:value]
|
|
191
184
|
end
|
|
192
185
|
|
|
193
186
|
on "noprompt", "No prompt mode" do
|
|
194
|
-
Pry.config.prompt = Pry::
|
|
187
|
+
Pry.config.prompt = Pry::Prompt[:none][:value]
|
|
195
188
|
end
|
|
196
189
|
|
|
197
190
|
on :r, :require=, "`require` a Ruby script at startup" do |file|
|
|
198
191
|
Pry.config.requires << file
|
|
199
192
|
end
|
|
200
193
|
|
|
201
|
-
on :I=, "Add a path to the $LOAD_PATH", :
|
|
194
|
+
on :I=, "Add a path to the $LOAD_PATH", as: Array, delimiter: ":" do |load_path|
|
|
202
195
|
load_path.map! do |path|
|
|
203
196
|
/\A\.\// =~ path ? path : File.expand_path(path)
|
|
204
197
|
end
|
|
@@ -220,6 +213,6 @@ Copyright (c) 2016 John Mair (banisterfiend)
|
|
|
220
213
|
|
|
221
214
|
on(:c, :context=,
|
|
222
215
|
"Start the session in the specified context. Equivalent to `context.pry` in a session.",
|
|
223
|
-
:
|
|
216
|
+
default: "Pry.toplevel_binding"
|
|
224
217
|
)
|
|
225
218
|
end
|
data/lib/pry/code/code_file.rb
CHANGED
|
@@ -25,6 +25,10 @@ class Pry
|
|
|
25
25
|
%w(Gemfile Rakefile Guardfile Capfile) => :ruby
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
# Store the current working directory. This allows show-source etc. to work if
|
|
29
|
+
# your process has changed directory since boot. [Issue #675]
|
|
30
|
+
INITIAL_PWD = Dir.pwd
|
|
31
|
+
|
|
28
32
|
# @return [Symbol] The type of code stored in this wrapper.
|
|
29
33
|
attr_reader :code_type
|
|
30
34
|
|
|
@@ -41,8 +45,6 @@ class Pry
|
|
|
41
45
|
Pry.line_buffer.drop(1)
|
|
42
46
|
elsif Pry::Method::Patcher.code_for(@filename)
|
|
43
47
|
Pry::Method::Patcher.code_for(@filename)
|
|
44
|
-
elsif RbxPath.is_core_path?(@filename)
|
|
45
|
-
File.read(RbxPath.convert_path_to_full(@filename))
|
|
46
48
|
else
|
|
47
49
|
path = abs_path
|
|
48
50
|
@code_type = type_from_filename(path)
|
|
@@ -97,13 +99,12 @@ class Pry
|
|
|
97
99
|
|
|
98
100
|
# @return [String]
|
|
99
101
|
def from_pry_init_pwd
|
|
100
|
-
File.expand_path(@filename,
|
|
102
|
+
File.expand_path(@filename, INITIAL_PWD)
|
|
101
103
|
end
|
|
102
104
|
|
|
103
105
|
# @return [String]
|
|
104
106
|
def from_load_path
|
|
105
107
|
$LOAD_PATH.map { |path| File.expand_path(@filename, path) }
|
|
106
108
|
end
|
|
107
|
-
|
|
108
109
|
end
|
|
109
110
|
end
|
data/lib/pry/code/code_range.rb
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
class Pry
|
|
2
2
|
class Code
|
|
3
|
-
|
|
4
3
|
# Represents a range of lines in a code listing.
|
|
5
4
|
#
|
|
6
5
|
# @api private
|
|
7
6
|
class CodeRange
|
|
8
|
-
|
|
9
7
|
# @param [Integer] start_line
|
|
10
8
|
# @param [Integer?] end_line
|
|
11
9
|
def initialize(start_line, end_line = nil)
|
|
@@ -23,6 +21,7 @@ class Pry
|
|
|
23
21
|
private
|
|
24
22
|
|
|
25
23
|
def start_line; @start_line; end
|
|
24
|
+
|
|
26
25
|
def end_line; @end_line; end
|
|
27
26
|
|
|
28
27
|
# If `end_line` is equal to `nil`, then calculate it from the first
|
|
@@ -48,12 +47,14 @@ class Pry
|
|
|
48
47
|
# @return [Integer]
|
|
49
48
|
def find_start_index(lines)
|
|
50
49
|
return start_line if start_line < 0
|
|
50
|
+
|
|
51
51
|
lines.index { |loc| loc.lineno >= start_line } || lines.length
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
# @return [Integer]
|
|
55
55
|
def find_end_index(lines)
|
|
56
56
|
return end_line if end_line < 0
|
|
57
|
+
|
|
57
58
|
(lines.index { |loc| loc.lineno > end_line } || 0) - 1
|
|
58
59
|
end
|
|
59
60
|
|
|
@@ -66,6 +67,5 @@ class Pry
|
|
|
66
67
|
@start_line = start_line.first
|
|
67
68
|
end
|
|
68
69
|
end
|
|
69
|
-
|
|
70
70
|
end
|
|
71
71
|
end
|
data/lib/pry/code/loc.rb
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
class Pry
|
|
2
2
|
class Code
|
|
3
|
-
|
|
4
|
-
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
3
|
+
# Represents a line of code (which may, in fact, contain multiple lines if the
|
|
4
|
+
# entirety was eval'd as a single unit following the `edit` command).
|
|
5
|
+
#
|
|
6
|
+
# A line of code is a tuple, which consists of a line and a line number. A
|
|
7
|
+
# `LOC` object's state (namely, the line parameter) can be changed via
|
|
8
|
+
# instance methods. `Pry::Code` heavily uses this class.
|
|
8
9
|
#
|
|
9
10
|
# @api private
|
|
10
11
|
# @example
|
|
@@ -18,7 +19,6 @@ class Pry
|
|
|
18
19
|
# loc.indent(3)
|
|
19
20
|
# loc.line #=> " def example\n :example\nend"
|
|
20
21
|
class LOC
|
|
21
|
-
|
|
22
22
|
# @return [Array<String, Integer>]
|
|
23
23
|
attr_reader :tuple
|
|
24
24
|
|
|
@@ -62,7 +62,8 @@ class Pry
|
|
|
62
62
|
def add_line_number(max_width = 0, color = false)
|
|
63
63
|
padded = lineno.to_s.rjust(max_width)
|
|
64
64
|
colorized_lineno = color ? Pry::Helpers::BaseHelpers.colorize_code(padded) : padded
|
|
65
|
-
|
|
65
|
+
properly_padded_line = handle_multiline_entries_from_edit_command(line, max_width)
|
|
66
|
+
tuple[0] = "#{ colorized_lineno }: #{ properly_padded_line }"
|
|
66
67
|
end
|
|
67
68
|
|
|
68
69
|
# Prepends a marker "=>" or an empty marker to the +line+.
|
|
@@ -86,7 +87,12 @@ class Pry
|
|
|
86
87
|
def indent(distance)
|
|
87
88
|
tuple[0] = "#{ ' ' * distance }#{ line }"
|
|
88
89
|
end
|
|
89
|
-
end
|
|
90
90
|
|
|
91
|
+
def handle_multiline_entries_from_edit_command(line, max_width)
|
|
92
|
+
line.split("\n").map.with_index do |inner_line, i|
|
|
93
|
+
i.zero? ? inner_line : "#{' ' * (max_width + 2)}#{inner_line}"
|
|
94
|
+
end.join("\n")
|
|
95
|
+
end
|
|
96
|
+
end
|
|
91
97
|
end
|
|
92
98
|
end
|
data/lib/pry/code.rb
CHANGED
|
@@ -66,7 +66,7 @@ class Pry
|
|
|
66
66
|
# @param [Integer, nil] start_line The line number to start on, or nil to
|
|
67
67
|
# use the method's original line numbers.
|
|
68
68
|
# @return [Code]
|
|
69
|
-
def from_module(mod, candidate_rank = 0, start_line=nil)
|
|
69
|
+
def from_module(mod, candidate_rank = 0, start_line = nil)
|
|
70
70
|
candidate = Pry::WrappedModule(mod).candidate(candidate_rank)
|
|
71
71
|
start_line ||= candidate.line
|
|
72
72
|
new(candidate.source, start_line, :ruby)
|
|
@@ -201,6 +201,7 @@ class Pry
|
|
|
201
201
|
# @return [Code]
|
|
202
202
|
def grep(pattern)
|
|
203
203
|
return self unless pattern
|
|
204
|
+
|
|
204
205
|
pattern = Regexp.new(pattern)
|
|
205
206
|
|
|
206
207
|
select do |loc|
|
|
@@ -265,7 +266,7 @@ class Pry
|
|
|
265
266
|
|
|
266
267
|
# Writes a formatted representation (based on the configuration of the
|
|
267
268
|
# object) to the given output, which must respond to `#<<`.
|
|
268
|
-
def print_to_output(output, color=false)
|
|
269
|
+
def print_to_output(output, color = false)
|
|
269
270
|
@lines.each do |loc|
|
|
270
271
|
loc = loc.dup
|
|
271
272
|
loc.colorize(@code_type) if color
|
|
@@ -291,15 +292,14 @@ class Pry
|
|
|
291
292
|
# @param [Integer] line_number (1-based)
|
|
292
293
|
# @return [String] the code.
|
|
293
294
|
def expression_at(line_number, consume = 0)
|
|
294
|
-
self.class.expression_at(raw, line_number, :
|
|
295
|
+
self.class.expression_at(raw, line_number, consume: consume)
|
|
295
296
|
end
|
|
296
297
|
|
|
297
298
|
# Get the (approximate) Module.nesting at the give line number.
|
|
298
299
|
#
|
|
299
300
|
# @param [Integer] line_number line number starting from 1
|
|
300
|
-
# @param [Module] top_module the module in which this code exists
|
|
301
301
|
# @return [Array<Module>] a list of open modules.
|
|
302
|
-
def nesting_at(line_number
|
|
302
|
+
def nesting_at(line_number)
|
|
303
303
|
Pry::Indent.nesting_at(raw, line_number)
|
|
304
304
|
end
|
|
305
305
|
|
|
@@ -338,7 +338,7 @@ class Pry
|
|
|
338
338
|
undef =~
|
|
339
339
|
|
|
340
340
|
# Check whether String responds to missing methods.
|
|
341
|
-
def respond_to_missing?(name, include_all=false)
|
|
341
|
+
def respond_to_missing?(name, include_all = false)
|
|
342
342
|
''.respond_to?(name, include_all)
|
|
343
343
|
end
|
|
344
344
|
|
data/lib/pry/code_object.rb
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
class Pry
|
|
2
|
-
|
|
3
2
|
# This class is responsible for taking a string (identifying a
|
|
4
3
|
# command/class/method/etc) and returning the relevant type of object.
|
|
5
4
|
# For example, if the user looks up "show-source" then a
|
|
@@ -64,7 +63,7 @@ class Pry
|
|
|
64
63
|
include Pry::Helpers::CommandHelpers
|
|
65
64
|
|
|
66
65
|
class << self
|
|
67
|
-
def lookup(str, _pry_, options={})
|
|
66
|
+
def lookup(str, _pry_, options = {})
|
|
68
67
|
co = new(str, _pry_, options)
|
|
69
68
|
|
|
70
69
|
co.default_lookup || co.method_or_class_lookup ||
|
|
@@ -77,9 +76,9 @@ class Pry
|
|
|
77
76
|
attr_accessor :_pry_
|
|
78
77
|
attr_accessor :super_level
|
|
79
78
|
|
|
80
|
-
def initialize(str, _pry_, options={})
|
|
79
|
+
def initialize(str, _pry_, options = {})
|
|
81
80
|
options = {
|
|
82
|
-
:
|
|
81
|
+
super: 0,
|
|
83
82
|
}.merge!(options)
|
|
84
83
|
|
|
85
84
|
@str = str
|
|
@@ -170,6 +169,7 @@ class Pry
|
|
|
170
169
|
def safe_to_evaluate?(str)
|
|
171
170
|
return true if str.strip == "self"
|
|
172
171
|
return false if str =~ /%/
|
|
172
|
+
|
|
173
173
|
kind = target.eval("defined?(#{str})")
|
|
174
174
|
kind =~ /variable|constant/
|
|
175
175
|
end
|