pry 0.10.4 → 0.11.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 (77) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +52 -18
  3. data/LICENSE +1 -1
  4. data/README.md +32 -31
  5. data/bin/pry +3 -7
  6. data/lib/pry/basic_object.rb +6 -0
  7. data/lib/pry/cli.rb +39 -34
  8. data/lib/pry/code/code_file.rb +8 -2
  9. data/lib/pry/code.rb +6 -1
  10. data/lib/pry/code_object.rb +23 -0
  11. data/lib/pry/color_printer.rb +20 -11
  12. data/lib/pry/command.rb +40 -16
  13. data/lib/pry/command_set.rb +9 -2
  14. data/lib/pry/commands/cat/exception_formatter.rb +11 -10
  15. data/lib/pry/commands/cat/file_formatter.rb +7 -3
  16. data/lib/pry/commands/code_collector.rb +16 -14
  17. data/lib/pry/commands/easter_eggs.rb +9 -9
  18. data/lib/pry/commands/edit/file_and_line_locator.rb +1 -1
  19. data/lib/pry/commands/edit.rb +7 -3
  20. data/lib/pry/commands/find_method.rb +1 -1
  21. data/lib/pry/commands/gem_open.rb +1 -1
  22. data/lib/pry/commands/gem_readme.rb +25 -0
  23. data/lib/pry/commands/gem_search.rb +40 -0
  24. data/lib/pry/commands/hist.rb +2 -2
  25. data/lib/pry/commands/jump_to.rb +7 -7
  26. data/lib/pry/commands/ls/constants.rb +12 -1
  27. data/lib/pry/commands/ls/formatter.rb +1 -0
  28. data/lib/pry/commands/ls/jruby_hacks.rb +2 -2
  29. data/lib/pry/commands/ls/self_methods.rb +2 -0
  30. data/lib/pry/commands/ls.rb +3 -1
  31. data/lib/pry/commands/play.rb +2 -2
  32. data/lib/pry/commands/reload_code.rb +2 -2
  33. data/lib/pry/commands/ri.rb +4 -0
  34. data/lib/pry/commands/shell_command.rb +34 -8
  35. data/lib/pry/commands/show_info.rb +10 -2
  36. data/lib/pry/commands/watch_expression/expression.rb +1 -1
  37. data/lib/pry/commands/whereami.rb +7 -6
  38. data/lib/pry/config/behavior.rb +140 -49
  39. data/lib/pry/config/default.rb +21 -33
  40. data/lib/pry/config/memoization.rb +44 -0
  41. data/lib/pry/config.rb +3 -16
  42. data/lib/pry/core_extensions.rb +12 -2
  43. data/lib/pry/editor.rb +1 -1
  44. data/lib/pry/exceptions.rb +1 -1
  45. data/lib/pry/forwardable.rb +23 -0
  46. data/lib/pry/helpers/base_helpers.rb +6 -10
  47. data/lib/pry/helpers/documentation_helpers.rb +1 -0
  48. data/lib/pry/helpers/options_helpers.rb +1 -1
  49. data/lib/pry/helpers/text.rb +69 -75
  50. data/lib/pry/history.rb +22 -1
  51. data/lib/pry/history_array.rb +1 -1
  52. data/lib/pry/hooks.rb +48 -107
  53. data/lib/pry/indent.rb +6 -2
  54. data/lib/pry/input_completer.rb +138 -120
  55. data/lib/pry/last_exception.rb +2 -2
  56. data/lib/pry/method/disowned.rb +1 -0
  57. data/lib/pry/method/patcher.rb +0 -3
  58. data/lib/pry/method.rb +15 -15
  59. data/lib/pry/output.rb +37 -38
  60. data/lib/pry/pager.rb +11 -8
  61. data/lib/pry/plugins.rb +20 -5
  62. data/lib/pry/pry_class.rb +30 -4
  63. data/lib/pry/pry_instance.rb +8 -6
  64. data/lib/pry/repl.rb +38 -8
  65. data/lib/pry/repl_file_loader.rb +1 -1
  66. data/lib/pry/rubygem.rb +3 -1
  67. data/lib/pry/slop/LICENSE +20 -0
  68. data/lib/pry/slop/commands.rb +196 -0
  69. data/lib/pry/slop/option.rb +208 -0
  70. data/lib/pry/slop.rb +661 -0
  71. data/lib/pry/terminal.rb +16 -5
  72. data/lib/pry/test/helper.rb +12 -3
  73. data/lib/pry/version.rb +1 -1
  74. data/lib/pry/{module_candidate.rb → wrapped_module/candidate.rb} +7 -13
  75. data/lib/pry/wrapped_module.rb +7 -7
  76. data/lib/pry.rb +4 -4
  77. metadata +14 -19
@@ -54,7 +54,7 @@ module PryTestHelpers
54
54
  yield file
55
55
  ensure
56
56
  file.close(true) if file
57
- File.unlink("#{file.path}c") if File.exists?("#{file.path}c") # rbx
57
+ File.unlink("#{file.path}c") if File.exist?("#{file.path}c") # rbx
58
58
  end
59
59
 
60
60
  def unindent(*args)
@@ -73,6 +73,12 @@ module PryTestHelpers
73
73
  e.define_singleton_method(:backtrace) { mock_backtrace }
74
74
  end
75
75
  end
76
+
77
+ def inner_scope
78
+ catch(:inner_scope) do
79
+ yield ->{ throw(:inner_scope, self) }
80
+ end
81
+ end
76
82
  end
77
83
 
78
84
  def pry_tester(*args, &block)
@@ -96,7 +102,7 @@ def pry_eval(*eval_strs)
96
102
  end
97
103
 
98
104
  class PryTester
99
- extend Forwardable
105
+ extend Pry::Forwardable
100
106
 
101
107
  attr_reader :pry, :out
102
108
 
@@ -115,7 +121,10 @@ class PryTester
115
121
  result = nil
116
122
 
117
123
  strs.flatten.each do |str|
118
- str = "#{str.strip}\n"
124
+ # Check for space prefix. See #1369.
125
+ if str !~ /^\s\S/
126
+ str = "#{str.strip}\n"
127
+ end
119
128
  @history.push str if @history
120
129
 
121
130
  if @pry.process_command(str)
data/lib/pry/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Pry
2
- VERSION = "0.10.4"
2
+ VERSION = "0.11.0"
3
3
  end
@@ -1,5 +1,4 @@
1
1
  require 'pry/helpers/documentation_helpers'
2
- require 'forwardable'
3
2
 
4
3
  class Pry
5
4
  class WrappedModule
@@ -10,7 +9,7 @@ class Pry
10
9
  class Candidate
11
10
  include Pry::Helpers::DocumentationHelpers
12
11
  include Pry::CodeObject::Helpers
13
- extend Forwardable
12
+ extend Pry::Forwardable
14
13
 
15
14
  # @return [String] The file where the module definition is located.
16
15
  attr_reader :file
@@ -22,15 +21,12 @@ class Pry
22
21
 
23
22
  # Methods to delegate to associated `Pry::WrappedModule
24
23
  # instance`.
25
- private_delegates = [:lines_for_file, :method_candidates,
26
- :yard_docs?]
27
-
28
- public_delegates = [:wrapped, :module?, :class?, :name, :nonblank_name,
24
+ private_delegates = [:lines_for_file, :method_candidates, :yard_docs?, :name]
25
+ public_delegates = [:wrapped, :module?, :class?, :nonblank_name,
29
26
  :number_of_candidates]
30
27
 
31
- def_delegators :@wrapper, *(private_delegates + public_delegates)
32
- private(*private_delegates)
33
- public(*public_delegates)
28
+ def_delegators :@wrapper, *public_delegates
29
+ def_private_delegators :@wrapper, *private_delegates
34
30
 
35
31
  # @raise [Pry::CommandError] If `rank` is out of bounds.
36
32
  # @param [Pry::WrappedModule] wrapper The associated
@@ -61,16 +57,14 @@ class Pry
61
57
  return nil if file.nil?
62
58
  return @source if @source
63
59
 
64
- @source = strip_leading_whitespace(Pry::Code.from_file(file).expression_at(line, number_of_lines_in_first_chunk))
60
+ @source ||= strip_leading_whitespace(Pry::Code.from_file(file).expression_at(line, number_of_lines_in_first_chunk))
65
61
  end
66
62
 
67
63
  # @raise [Pry::CommandError] If documentation cannot be found.
68
64
  # @return [String] The documentation for the candidate.
69
65
  def doc
70
66
  return nil if file.nil?
71
- return @doc if @doc
72
-
73
- @doc = get_comment_content(Pry::Code.from_file(file).comment_describing(line))
67
+ @doc ||= get_comment_content(Pry::Code.from_file(file).comment_describing(line))
74
68
  end
75
69
 
76
70
  # @return [Array, nil] A `[String, Fixnum]` pair representing the
@@ -1,4 +1,4 @@
1
- require 'pry/module_candidate'
1
+ require 'pry/wrapped_module/candidate'
2
2
 
3
3
  class Pry
4
4
  class << self
@@ -48,6 +48,7 @@ class Pry
48
48
  # @return [Boolean]
49
49
  def safe_to_evaluate?(str, target)
50
50
  return true if str.strip == "self"
51
+ return false if str =~ /%/
51
52
  kind = target.eval("defined?(#{str})")
52
53
  kind =~ /variable|constant/
53
54
  end
@@ -149,15 +150,14 @@ class Pry
149
150
  wrapped.send(method_name, *args, &block)
150
151
  end
151
152
 
152
- def respond_to?(method_name)
153
- super || wrapped.respond_to?(method_name)
153
+ def respond_to?(method_name, include_all=false)
154
+ super || wrapped.respond_to?(method_name, include_all)
154
155
  end
155
156
 
156
157
  # Retrieve the source location of a module. Return value is in same
157
158
  # format as Method#source_location. If the source location
158
159
  # cannot be found this method returns `nil`.
159
160
  #
160
- # @param [Module] mod The module (or class).
161
161
  # @return [Array<String, Fixnum>, nil] The source location of the
162
162
  # module (or class), or `nil` if no source location found.
163
163
  def source_location
@@ -232,7 +232,7 @@ class Pry
232
232
  # @param [Fixnum] rank
233
233
  # @return [Pry::WrappedModule::Candidate]
234
234
  def candidate(rank)
235
- @memoized_candidates[rank] ||= Candidate.new(self, rank)
235
+ @memoized_candidates[rank] ||= WrappedModule::Candidate.new(self, rank)
236
236
  end
237
237
 
238
238
  # @return [Fixnum] The number of candidate definitions for the
@@ -331,13 +331,13 @@ class Pry
331
331
 
332
332
  return methods unless methods.empty?
333
333
 
334
- safe_send(mod, :constants).map do |const_name|
334
+ safe_send(mod, :constants).flat_map do |const_name|
335
335
  if const = nested_module?(mod, const_name)
336
336
  all_relevant_methods_for(const)
337
337
  else
338
338
  []
339
339
  end
340
- end.flatten
340
+ end
341
341
  end
342
342
 
343
343
  # Return all methods (instance methods and class methods) for a
data/lib/pry.rb CHANGED
@@ -1,13 +1,12 @@
1
- # (C) John Mair (banisterfiend) 2013
1
+ # (C) John Mair (banisterfiend) 2016
2
2
  # MIT License
3
3
  #
4
4
  require 'pp'
5
-
5
+ require 'pry/forwardable'
6
6
  require 'pry/input_lock'
7
7
  require 'pry/exceptions'
8
8
  require 'pry/helpers/base_helpers'
9
9
  require 'pry/hooks'
10
- require 'forwardable'
11
10
 
12
11
  class Pry
13
12
  # The default hooks - display messages when beginning and ending Pry sessions.
@@ -124,8 +123,9 @@ end
124
123
  require 'method_source'
125
124
  require 'shellwords'
126
125
  require 'stringio'
126
+ require 'strscan'
127
127
  require 'coderay'
128
- require 'slop'
128
+ require 'pry/slop'
129
129
  require 'rbconfig'
130
130
  require 'tempfile'
131
131
  require 'pathname'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.4
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Mair (banisterfiend)
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-07-11 00:00:00.000000000 Z
13
+ date: 2017-09-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: coderay
@@ -26,20 +26,6 @@ dependencies:
26
26
  - - "~>"
27
27
  - !ruby/object:Gem::Version
28
28
  version: 1.1.0
29
- - !ruby/object:Gem::Dependency
30
- name: slop
31
- requirement: !ruby/object:Gem::Requirement
32
- requirements:
33
- - - "~>"
34
- - !ruby/object:Gem::Version
35
- version: '3.4'
36
- type: :runtime
37
- prerelease: false
38
- version_requirements: !ruby/object:Gem::Requirement
39
- requirements:
40
- - - "~>"
41
- - !ruby/object:Gem::Version
42
- version: '3.4'
43
29
  - !ruby/object:Gem::Dependency
44
30
  name: method_source
45
31
  requirement: !ruby/object:Gem::Requirement
@@ -83,6 +69,7 @@ files:
83
69
  - README.md
84
70
  - bin/pry
85
71
  - lib/pry.rb
72
+ - lib/pry/basic_object.rb
86
73
  - lib/pry/cli.rb
87
74
  - lib/pry/code.rb
88
75
  - lib/pry/code/code_file.rb
@@ -120,6 +107,8 @@ files:
120
107
  - lib/pry/commands/gem_install.rb
121
108
  - lib/pry/commands/gem_list.rb
122
109
  - lib/pry/commands/gem_open.rb
110
+ - lib/pry/commands/gem_readme.rb
111
+ - lib/pry/commands/gem_search.rb
123
112
  - lib/pry/commands/gist.rb
124
113
  - lib/pry/commands/help.rb
125
114
  - lib/pry/commands/hist.rb
@@ -169,9 +158,11 @@ files:
169
158
  - lib/pry/config/behavior.rb
170
159
  - lib/pry/config/convenience.rb
171
160
  - lib/pry/config/default.rb
161
+ - lib/pry/config/memoization.rb
172
162
  - lib/pry/core_extensions.rb
173
163
  - lib/pry/editor.rb
174
164
  - lib/pry/exceptions.rb
165
+ - lib/pry/forwardable.rb
175
166
  - lib/pry/helpers.rb
176
167
  - lib/pry/helpers/base_helpers.rb
177
168
  - lib/pry/helpers/command_helpers.rb
@@ -191,7 +182,6 @@ files:
191
182
  - lib/pry/method/disowned.rb
192
183
  - lib/pry/method/patcher.rb
193
184
  - lib/pry/method/weird_method_locator.rb
194
- - lib/pry/module_candidate.rb
195
185
  - lib/pry/object_path.rb
196
186
  - lib/pry/output.rb
197
187
  - lib/pry/pager.rb
@@ -203,10 +193,15 @@ files:
203
193
  - lib/pry/repl.rb
204
194
  - lib/pry/repl_file_loader.rb
205
195
  - lib/pry/rubygem.rb
196
+ - lib/pry/slop.rb
197
+ - lib/pry/slop/LICENSE
198
+ - lib/pry/slop/commands.rb
199
+ - lib/pry/slop/option.rb
206
200
  - lib/pry/terminal.rb
207
201
  - lib/pry/test/helper.rb
208
202
  - lib/pry/version.rb
209
203
  - lib/pry/wrapped_module.rb
204
+ - lib/pry/wrapped_module/candidate.rb
210
205
  homepage: http://pryrepl.org
211
206
  licenses:
212
207
  - MIT
@@ -219,7 +214,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
219
214
  requirements:
220
215
  - - ">="
221
216
  - !ruby/object:Gem::Version
222
- version: '0'
217
+ version: 1.9.3
223
218
  required_rubygems_version: !ruby/object:Gem::Requirement
224
219
  requirements:
225
220
  - - ">="
@@ -227,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
227
222
  version: '0'
228
223
  requirements: []
229
224
  rubyforge_project:
230
- rubygems_version: 2.5.1
225
+ rubygems_version: 2.6.12
231
226
  signing_key:
232
227
  specification_version: 4
233
228
  summary: An IRB alternative and runtime developer console