pry 0.14.2 → 0.16.0

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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +72 -2
  3. data/LICENSE +1 -1
  4. data/README.md +13 -10
  5. data/lib/pry/class_command.rb +2 -2
  6. data/lib/pry/cli.rb +5 -1
  7. data/lib/pry/code_object.rb +2 -2
  8. data/lib/pry/command.rb +1 -1
  9. data/lib/pry/command_set.rb +2 -2
  10. data/lib/pry/command_state.rb +11 -6
  11. data/lib/pry/commands/amend_line.rb +1 -1
  12. data/lib/pry/commands/cd.rb +2 -0
  13. data/lib/pry/commands/edit.rb +2 -0
  14. data/lib/pry/commands/find_method.rb +1 -1
  15. data/lib/pry/commands/ls/config.rb +54 -0
  16. data/lib/pry/commands/ls.rb +0 -21
  17. data/lib/pry/commands/raise_up.rb +1 -1
  18. data/lib/pry/commands/ri.rb +1 -1
  19. data/lib/pry/commands/shell_command.rb +1 -1
  20. data/lib/pry/commands/shell_mode.rb +1 -0
  21. data/lib/pry/commands/show_doc.rb +1 -10
  22. data/lib/pry/commands/show_source.rb +3 -64
  23. data/lib/pry/commands/watch_expression/expression.rb +1 -1
  24. data/lib/pry/commands/watch_expression.rb +3 -5
  25. data/lib/pry/config.rb +33 -26
  26. data/lib/pry/control_d_handler.rb +1 -1
  27. data/lib/pry/exception_handler.rb +7 -2
  28. data/lib/pry/helpers/command_helpers.rb +1 -1
  29. data/lib/pry/indent.rb +6 -4
  30. data/lib/pry/input/simple_stdio.rb +13 -0
  31. data/lib/pry/input_completer.rb +1 -1
  32. data/lib/pry/method/patcher.rb +2 -2
  33. data/lib/pry/method/weird_method_locator.rb +4 -4
  34. data/lib/pry/method.rb +2 -3
  35. data/lib/pry/pry_class.rb +4 -29
  36. data/lib/pry/pry_instance.rb +6 -44
  37. data/lib/pry/repl.rb +72 -2
  38. data/lib/pry/ring.rb +1 -1
  39. data/lib/pry/slop.rb +1 -1
  40. data/lib/pry/syntax_highlighter.rb +1 -1
  41. data/lib/pry/version.rb +1 -1
  42. data/lib/pry/wrapped_module/candidate.rb +7 -1
  43. data/lib/pry/wrapped_module.rb +1 -1
  44. data/lib/pry.rb +4 -1
  45. metadata +20 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6d8bac7565d29bff46039481c17aa6a88fec28084916dd8dad12cd4e83b146c1
4
- data.tar.gz: 90b46a979aaac6d01ddf589217baca57bc2d7ce8197c8f27bc22f823eeaffcdd
3
+ metadata.gz: f45a7ece4b6117e2ecb650b850bbafc729d1575d810ae709dff957979782b030
4
+ data.tar.gz: f3977bcef3004c4643ea02320dc4f3ca1d2958ea813665559bc2f0db01325efd
5
5
  SHA512:
6
- metadata.gz: 2e671cca56deb75c1c47ba9108155bec171ebe34d5ba740b3dd7ea3e848fc789291111e40b7c604835b3d90209873a4a3364ec72a5f4c0f062dea98e5b466a30
7
- data.tar.gz: f4c80ad6f3187823c18e1fff35306fc1e0a0ee4045a06b190f4742c92099b89d7ef5bafcb1c1dd68c8ae09b251a9a9b64bfd33179c2a7778f3122c90d636afa5
6
+ metadata.gz: 276887cb72b590db134890f41b44dd6844bc1e5cd8307ca72236028967026c7f24fd07e14ae1d99840330672941740945a502ca965e2d7d00df400095af7a12a
7
+ data.tar.gz: 52146474624b386e394aaf5a21e371c5e52744a2aeff67468603a25b81bfb4bd83be027b7b2bf9aa9b987b22aa3a0efb3debc86d892536c00ad6a33465a33d85
data/CHANGELOG.md CHANGED
@@ -1,4 +1,74 @@
1
- ### master
1
+ ### [v0.16.0](v0.16.0) (December 26, 2025)
2
+
3
+ #### Features
4
+
5
+ * Ruby 4.0 Support.
6
+ Pry will now require and default to Reline for newer Rubies.
7
+ ([#2357](https://github.com/pry/pry/pull/2357))
8
+ ([#2349](https://github.com/pry/pry/pull/2349))
9
+ * Revert 'Unify show-doc with show-source'.
10
+ ([#2346](https://github.com/pry/pry/pull/2346))
11
+
12
+ #### Breaking Changes
13
+
14
+ * Remove experimental `Pry.auto_resize!`
15
+ Returns a warning. The code will be removed later.
16
+ ([#2359](https://github.com/pry/pry/pull/2359))
17
+ * Drop support for Ruby < 2.6
18
+ ([#2349](https://github.com/pry/pry/pull/2349))
19
+
20
+ ### [v0.15.2](v0.15.2) (December 24, 2024)
21
+
22
+ #### Bug Fixes
23
+
24
+ * Avoid breaking reading input if Prism version is undetectable
25
+ ([#2340](https://github.com/pry/pry/pull/2340))
26
+
27
+ ### [v0.15.1](v0.15.1) (December 24, 2024)
28
+
29
+ #### Bug Fixes
30
+
31
+ * Restore Pry.config.ls compatibility
32
+ ([#2335](https://github.com/pry/pry/pull/2335))
33
+ * Avoid breaking reading inputs if Prism is not available
34
+ ([#2338](https://github.com/pry/pry/pull/2338))
35
+
36
+ ### [v0.15.0][v0.15.0] (November 15, 2024)
37
+
38
+ #### Features
39
+
40
+ * Added support for Reline
41
+ ([#2298](https://github.com/pry/pry/pull/2298))
42
+ * Added support for Ruby 3.3
43
+ ([#2295](https://github.com/pry/pry/pull/2295))
44
+ * Added Pry::Input::SimpleStdio for dumb terminals when Reline is in use
45
+ ([#2304](https://github.com/pry/pry/pull/2304))
46
+ * Remove OpenStruct usage
47
+ ([#2307](https://github.com/pry/pry/pull/2307))
48
+ ([#2309](https://github.com/pry/pry/pull/2309))
49
+ * Disable coloring of output when NO_COLOR is set.
50
+ ([#2323])(https://github.com/pry/pry/pull/2323))
51
+ * Add `pry --no-multiline` flag to keep single line prompt.
52
+ ([#2327](https://github.com/pry/pry/pull/2327))
53
+
54
+ #### Bug Fixes
55
+
56
+ * Fix typos on docs and and comments
57
+ ([#2300](https://github.com/pry/pry/pull/2300))
58
+ ([#2301](https://github.com/pry/pry/pull/2301))
59
+ * Fix 'calling clear method' on user code when defined in pry context.
60
+ ([#2291](https://github.com/pry/pry/pull/2291))
61
+ * Fix arguments WatchExpression#add_expression
62
+ ([#2278](https://github.com/pry/pry/pull/2278))
63
+
64
+ ### Breaking changes
65
+
66
+ * Remove support for deprecated `Pry.config.prompt = [proc {}, proc {}]`
67
+ Use Pry::Prompt API instead
68
+ ([#2308](https://github.com/pry/pry/pull/2308))
69
+ * Remove deprecated `Pry.config.exception_whitelist`.
70
+ Use `Pry.config.unrescued_exceptions` instead.
71
+ ([#2326](https://github.com/pry/pry/pull/2326))
2
72
 
3
73
  ### [v0.14.2][v0.14.2] (January 9, 2023)
4
74
 
@@ -977,7 +1047,7 @@ complete CHANGELOG:
977
1047
  * _pry_ now passed as 3rd parameter to :before_session hook
978
1048
  * ls colors now configurable via Pry.config.ls.local_var_color = :bright_red etc
979
1049
  * ls separator configurable via, e.g Pry.config.ls.separator = " "
980
- * Pry.view_clip() now only calls inspect on a few immediates, otherwise uses the #<> syntax, which has been truncated further to exclude teh mem address, again related to #245
1050
+ * 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
981
1051
 
982
1052
  ### 0.9.3 (2011/7/27)
983
1053
  * cat --ex (cats 5 lines above and below line in file where exception was raised)
data/LICENSE CHANGED
@@ -3,7 +3,7 @@ License
3
3
 
4
4
  (The MIT License)
5
5
 
6
- Copyright (c) 2018 John Mair (banisterfiend)
6
+ Copyright (c) 2010 John Mair (banisterfiend)
7
7
 
8
8
  Permission is hereby granted, free of charge, to any person obtaining
9
9
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -9,9 +9,9 @@ Pry
9
9
 
10
10
  ![Pry logo](https://www.dropbox.com/s/zp8o63kquby2rln/pry_logo_350.png?raw=1)
11
11
 
12
- © John Mair ([banisterfiend](https://twitter.com/banisterfiend)) 2018<br> (Creator)
12
+ © John Mair ([banisterfiend](https://twitter.com/banisterfiend)) 2010<br> (Creator)
13
13
 
14
- © Kyrylo Silin ([kyrylosilin](https://twitter.com/kyrylosilin)) 2018<br> (Maintainer)
14
+ © Kyrylo Silin ([kyrylosilin](https://twitter.com/kyrylosilin)) 2010<br> (Maintainer)
15
15
 
16
16
  **Alumni:**
17
17
 
@@ -81,7 +81,7 @@ Installation
81
81
  ### Bundler
82
82
 
83
83
  ```ruby
84
- gem 'pry', '~> 0.13.1'
84
+ gem 'pry', '~> 0.15.0'
85
85
  ```
86
86
 
87
87
  ### Manual
@@ -413,18 +413,21 @@ description if the `--help` option is available.
413
413
 
414
414
  ### Use Pry as your Rails Console
415
415
 
416
- The recommended way to use Pry as your Rails console is to add [the `pry-rails`
417
- gem](https://github.com/rweng/pry-rails) to your Gemfile. This replaces the
418
- default console with Pry, in addition to loading the Rails console helpers and
419
- adding some useful Rails-specific commands.
420
-
421
- If you don't want to change your Gemfile, you can still run a Pry console in
422
- 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:
423
417
 
424
418
  ```sh
425
419
  pry -r ./config/environment
426
420
  ```
427
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
+
428
431
  Also check out the
429
432
  [wiki](https://github.com/pry/pry/wiki/Setting-up-Rails-or-Heroku-to-use-Pry)
430
433
  for more information about integrating Pry with Rails.
@@ -137,7 +137,7 @@ class Pry
137
137
  # end
138
138
  # end
139
139
  #
140
- # @example Define the invokation block anywhere you want
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` mehod can be called to get the options that Pry::Slop has passed,
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
@@ -123,7 +123,7 @@ Pry::CLI.add_options do
123
123
  "Usage: pry [OPTIONS]\n" \
124
124
  "Start a Pry session.\n" \
125
125
  "See http://pry.github.io/ for more information.\n" \
126
- "Copyright (c) 2016 John Mair (banisterfiend)" \
126
+ "Copyright (c) 2010 John Mair (banisterfiend)" \
127
127
  )
128
128
 
129
129
  on(
@@ -145,6 +145,10 @@ Pry::CLI.add_options 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
@@ -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
- # identifer for the object (i.e they pass in `nil` or "") then the
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 paramter is given (i.e CodeObject.lookup(nil)), then we
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
@@ -200,7 +200,7 @@ class Pry
200
200
  end
201
201
 
202
202
  def state
203
- Pry::CommandState.default.state_for(match)
203
+ Pry::CommandState.default.state_for(self)
204
204
  end
205
205
  end
206
206
 
@@ -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 reciever (a command set).
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 reciever (a command set).
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|
@@ -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(command_name)
24
- @command_state[command_name] ||= OpenStruct.new
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
- def reset(command_name)
28
- @command_state[command_name] = OpenStruct.new
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
- # indentified by 1 rather than by 0 (as is the case for Ruby arrays).
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.
@@ -22,6 +22,8 @@ class Pry
22
22
  https://github.com/pry/pry/wiki/State-navigation#wiki-Changing_scope
23
23
  BANNER
24
24
 
25
+ command_options state: %i[old_stack]
26
+
25
27
  def process
26
28
  state.old_stack ||= []
27
29
 
@@ -22,6 +22,8 @@ class Pry
22
22
  https://github.com/pry/pry/wiki/Editor-integration#wiki-Edit_command
23
23
  BANNER
24
24
 
25
+ command_options state: %i[dynamical_ex_file]
26
+
25
27
  def options(opt)
26
28
  opt.on :e, :ex, "Open the file that raised the most recent exception " \
27
29
  "(_ex_.file)",
@@ -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,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'forwardable'
4
+
5
+ class Pry
6
+ class Command
7
+ class Ls < Pry::ClassCommand
8
+ class Config
9
+ extend Forwardable
10
+
11
+ DEFAULT_OPTIONS = {
12
+ heading_color: :bright_blue,
13
+ public_method_color: :default,
14
+ private_method_color: :blue,
15
+ protected_method_color: :blue,
16
+ method_missing_color: :bright_red,
17
+ local_var_color: :yellow,
18
+ pry_var_color: :default, # e.g. _, pry_instance, _file_
19
+ instance_var_color: :blue, # e.g. @foo
20
+ class_var_color: :bright_blue, # e.g. @@foo
21
+ global_var_color: :default, # e.g. $CODERAY_DEBUG, $eventmachine_library
22
+ builtin_global_color: :cyan, # e.g. $stdin, $-w, $PID
23
+ pseudo_global_color: :cyan, # e.g. $~, $1..$9, $LAST_MATCH_INFO
24
+ constant_color: :default, # e.g. VERSION, ARGF
25
+ class_constant_color: :blue, # e.g. Object, Kernel
26
+ exception_constant_color: :magenta, # e.g. Exception, RuntimeError
27
+ unloaded_constant_color: :yellow, # Constant still in .autoload? state
28
+ separator: " ",
29
+ ceiling: [Object, Module, Class]
30
+ }.freeze
31
+
32
+ DEFAULT_OPTIONS.each_key do |key|
33
+ define_method key do
34
+ @config[key]
35
+ end
36
+
37
+ define_method "#{key}=" do |value|
38
+ @config[key] = value
39
+ end
40
+ end
41
+
42
+ def_delegators :@config, :[], :[]=, :each, :each_pair, :values, :keys, :to_a
43
+
44
+ def initialize(config)
45
+ @config = config
46
+ end
47
+
48
+ def self.default
49
+ new(DEFAULT_OPTIONS.dup)
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -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 expresion here so that "raise-up 'foo'" does the right thing.
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.*)/)
@@ -57,7 +57,7 @@ class Pry
57
57
  RDoc::RI.const_set :PryDriver, subclass # hook it up!
58
58
  end
59
59
 
60
- # Spin-up an RI insance.
60
+ # Spin-up an RI instance.
61
61
  ri = RDoc::RI::PryDriver.new(
62
62
  pry_instance.pager, use_stdout: true, interactive: false
63
63
  )
@@ -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.
@@ -21,16 +21,6 @@ class Pry
21
21
  show-doc Pry -a # for all definitions of Pry class (all monkey patches)
22
22
  BANNER
23
23
 
24
- def process
25
- super
26
-
27
- output.puts(
28
- "\nWARNING: the show-doc command is deprecated. It will be removed " \
29
- "from future Pry versions.\nPlease use 'show-source' with the -d " \
30
- "(or --doc) switch instead\nExample: show-source #{obj_name} -d"
31
- )
32
- end
33
-
34
24
  # The docs for code_object prepared for display.
35
25
  def content_for(code_object)
36
26
  Code.new(
@@ -89,5 +79,6 @@ class Pry
89
79
  end
90
80
 
91
81
  Pry::Commands.add_command(Pry::Command::ShowDoc)
82
+ Pry::Commands.alias_command '?', 'show-doc'
92
83
  end
93
84
  end
@@ -3,8 +3,6 @@
3
3
  class Pry
4
4
  class Command
5
5
  class ShowSource < Command::ShowInfo
6
- include Pry::Helpers::DocumentationHelpers
7
-
8
6
  match 'show-source'
9
7
  group 'Introspection'
10
8
  description 'Show the source for a method or class.'
@@ -23,7 +21,6 @@ class Pry
23
21
  show-source Pry -a # for all Pry class definitions (all monkey patches)
24
22
  show-source Pry.foo -e # for class of the return value of expression `Pry.foo`
25
23
  show-source Pry --super # for superclass of Pry (Object class)
26
- show-source Pry -d # include documentation
27
24
 
28
25
  https://github.com/pry/pry/wiki/Source-browsing#wiki-Show_method
29
26
  BANNER
@@ -31,7 +28,6 @@ class Pry
31
28
  def options(opt)
32
29
  opt.on :e, :eval, "evaluate the command's argument as a ruby " \
33
30
  "expression and show the class its return value"
34
- opt.on :d, :doc, 'include documentation in the output'
35
31
  super(opt)
36
32
  end
37
33
 
@@ -46,73 +42,16 @@ class Pry
46
42
 
47
43
  # The source for code_object prepared for display.
48
44
  def content_for(code_object)
49
- content = ''
50
- if opts.present?(:d)
51
- code = Code.new(
52
- render_doc_markup_for(code_object), start_line_for(code_object), :text
53
- )
54
- content += code.with_line_numbers(use_line_numbers?).to_s
55
- content += "\n"
56
- end
57
-
58
45
  code = Code.new(
59
- code_object.source || [], start_line_for(code_object)
46
+ code_object.source || [],
47
+ start_line_for(code_object)
60
48
  )
61
- content += code.with_line_numbers(use_line_numbers?).highlighted
62
- content
63
- end
64
-
65
- # process the markup (if necessary) and apply colors
66
- def render_doc_markup_for(code_object)
67
- docs = docs_for(code_object)
68
-
69
- if code_object.command?
70
- # command '--help' shouldn't use markup highlighting
71
- docs
72
- else
73
- if docs.empty?
74
- raise CommandError, "No docs found for: #{obj_name || 'current context'}"
75
- end
76
-
77
- process_comment_markup(docs)
78
- end
79
- end
80
-
81
- # Return docs for the code_object, adjusting for whether the code_object
82
- # has yard docs available, in which case it returns those.
83
- # (note we only have to check yard docs for modules since they can
84
- # have multiple docs, but methods can only be doc'd once so we
85
- # dont need to check them)
86
- def docs_for(code_object)
87
- if code_object.module_with_yard_docs?
88
- # yard docs
89
- code_object.yard_doc
90
- else
91
- # normal docs (i.e comments above method/module/command)
92
- code_object.doc
93
- end
94
- end
95
-
96
- # Which sections to include in the 'header', can toggle: :owner,
97
- # :signature and visibility.
98
- def header_options
99
- super.merge signature: true
100
- end
101
-
102
- # figure out start line of docs by back-calculating based on
103
- # number of lines in the comment and the start line of the code_object
104
- # @return [Fixnum] start line of docs
105
- def start_line_for(code_object)
106
- return 1 if code_object.command? || opts.present?(:'base-one')
107
- return 1 unless code_object.source_line
108
-
109
- code_object.source_line - code_object.doc.lines.count
49
+ code.with_line_numbers(use_line_numbers?).highlighted
110
50
  end
111
51
  end
112
52
 
113
53
  Pry::Commands.add_command(Pry::Command::ShowSource)
114
54
  Pry::Commands.alias_command 'show-method', 'show-source'
115
55
  Pry::Commands.alias_command '$', 'show-source'
116
- Pry::Commands.alias_command '?', 'show-source -d'
117
56
  end
118
57
  end
@@ -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 represenation to detect differences
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(args)
49
+ add_expression
50
50
  end
51
51
  end
52
52
 
@@ -88,9 +88,7 @@ class Pry
88
88
  end
89
89
  end
90
90
 
91
- # TODO: fix arguments.
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