pry 0.10.4 → 0.11.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +45 -18
  3. data/LICENSE +1 -1
  4. data/README.md +28 -26
  5. data/bin/pry +3 -7
  6. data/lib/pry.rb +3 -2
  7. data/lib/pry/basic_object.rb +6 -0
  8. data/lib/pry/cli.rb +39 -34
  9. data/lib/pry/code.rb +6 -1
  10. data/lib/pry/code/code_file.rb +8 -2
  11. data/lib/pry/code_object.rb +23 -0
  12. data/lib/pry/color_printer.rb +11 -8
  13. data/lib/pry/command.rb +40 -16
  14. data/lib/pry/command_set.rb +9 -2
  15. data/lib/pry/commands/cat/exception_formatter.rb +11 -10
  16. data/lib/pry/commands/cat/file_formatter.rb +7 -3
  17. data/lib/pry/commands/code_collector.rb +16 -14
  18. data/lib/pry/commands/easter_eggs.rb +9 -9
  19. data/lib/pry/commands/edit.rb +6 -2
  20. data/lib/pry/commands/edit/file_and_line_locator.rb +1 -1
  21. data/lib/pry/commands/find_method.rb +1 -1
  22. data/lib/pry/commands/gem_open.rb +1 -1
  23. data/lib/pry/commands/gem_readme.rb +25 -0
  24. data/lib/pry/commands/gem_search.rb +40 -0
  25. data/lib/pry/commands/hist.rb +2 -2
  26. data/lib/pry/commands/jump_to.rb +7 -7
  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/play.rb +2 -2
  31. data/lib/pry/commands/reload_code.rb +2 -2
  32. data/lib/pry/commands/ri.rb +4 -0
  33. data/lib/pry/commands/shell_command.rb +34 -8
  34. data/lib/pry/commands/show_info.rb +10 -2
  35. data/lib/pry/commands/watch_expression/expression.rb +1 -1
  36. data/lib/pry/commands/whereami.rb +6 -6
  37. data/lib/pry/config.rb +3 -16
  38. data/lib/pry/config/behavior.rb +139 -49
  39. data/lib/pry/config/default.rb +21 -33
  40. data/lib/pry/config/lazy.rb +25 -0
  41. data/lib/pry/editor.rb +1 -1
  42. data/lib/pry/exceptions.rb +1 -1
  43. data/lib/pry/helpers/base_helpers.rb +6 -10
  44. data/lib/pry/helpers/documentation_helpers.rb +1 -0
  45. data/lib/pry/helpers/options_helpers.rb +1 -1
  46. data/lib/pry/helpers/text.rb +69 -76
  47. data/lib/pry/history.rb +22 -1
  48. data/lib/pry/history_array.rb +1 -1
  49. data/lib/pry/hooks.rb +48 -107
  50. data/lib/pry/indent.rb +6 -2
  51. data/lib/pry/input_completer.rb +118 -118
  52. data/lib/pry/method.rb +13 -13
  53. data/lib/pry/method/disowned.rb +1 -0
  54. data/lib/pry/method/patcher.rb +0 -3
  55. data/lib/pry/output.rb +37 -38
  56. data/lib/pry/pager.rb +11 -8
  57. data/lib/pry/plugins.rb +20 -5
  58. data/lib/pry/pry_class.rb +29 -3
  59. data/lib/pry/pry_instance.rb +8 -6
  60. data/lib/pry/repl.rb +37 -5
  61. data/lib/pry/repl_file_loader.rb +1 -1
  62. data/lib/pry/rubygem.rb +3 -1
  63. data/lib/pry/slop.rb +661 -0
  64. data/lib/pry/slop/LICENSE +20 -0
  65. data/lib/pry/slop/commands.rb +196 -0
  66. data/lib/pry/slop/option.rb +208 -0
  67. data/lib/pry/terminal.rb +16 -5
  68. data/lib/pry/test/helper.rb +11 -2
  69. data/lib/pry/version.rb +1 -1
  70. data/lib/pry/wrapped_module.rb +5 -5
  71. data/lib/pry/{module_candidate.rb → wrapped_module/candidate.rb} +2 -4
  72. metadata +14 -20
@@ -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)
@@ -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)
@@ -1,3 +1,3 @@
1
1
  class Pry
2
- VERSION = "0.10.4"
2
+ VERSION = "0.11.0.pre"
3
3
  end
@@ -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
@@ -157,7 +158,6 @@ class Pry
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
@@ -61,16 +61,14 @@ class Pry
61
61
  return nil if file.nil?
62
62
  return @source if @source
63
63
 
64
- @source = strip_leading_whitespace(Pry::Code.from_file(file).expression_at(line, number_of_lines_in_first_chunk))
64
+ @source ||= strip_leading_whitespace(Pry::Code.from_file(file).expression_at(line, number_of_lines_in_first_chunk))
65
65
  end
66
66
 
67
67
  # @raise [Pry::CommandError] If documentation cannot be found.
68
68
  # @return [String] The documentation for the candidate.
69
69
  def doc
70
70
  return nil if file.nil?
71
- return @doc if @doc
72
-
73
- @doc = get_comment_content(Pry::Code.from_file(file).comment_describing(line))
71
+ @doc ||= get_comment_content(Pry::Code.from_file(file).comment_describing(line))
74
72
  end
75
73
 
76
74
  # @return [Array, nil] A `[String, Fixnum]` pair representing the
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.pre
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: 2016-06-29 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,6 +158,7 @@ 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/lazy.rb
172
162
  - lib/pry/core_extensions.rb
173
163
  - lib/pry/editor.rb
174
164
  - lib/pry/exceptions.rb
@@ -191,7 +181,6 @@ files:
191
181
  - lib/pry/method/disowned.rb
192
182
  - lib/pry/method/patcher.rb
193
183
  - lib/pry/method/weird_method_locator.rb
194
- - lib/pry/module_candidate.rb
195
184
  - lib/pry/object_path.rb
196
185
  - lib/pry/output.rb
197
186
  - lib/pry/pager.rb
@@ -203,10 +192,15 @@ files:
203
192
  - lib/pry/repl.rb
204
193
  - lib/pry/repl_file_loader.rb
205
194
  - lib/pry/rubygem.rb
195
+ - lib/pry/slop.rb
196
+ - lib/pry/slop/LICENSE
197
+ - lib/pry/slop/commands.rb
198
+ - lib/pry/slop/option.rb
206
199
  - lib/pry/terminal.rb
207
200
  - lib/pry/test/helper.rb
208
201
  - lib/pry/version.rb
209
202
  - lib/pry/wrapped_module.rb
203
+ - lib/pry/wrapped_module/candidate.rb
210
204
  homepage: http://pryrepl.org
211
205
  licenses:
212
206
  - MIT
@@ -219,12 +213,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
219
213
  requirements:
220
214
  - - ">="
221
215
  - !ruby/object:Gem::Version
222
- version: '0'
216
+ version: 1.9.3
223
217
  required_rubygems_version: !ruby/object:Gem::Requirement
224
218
  requirements:
225
- - - ">="
219
+ - - ">"
226
220
  - !ruby/object:Gem::Version
227
- version: '0'
221
+ version: 1.3.1
228
222
  requirements: []
229
223
  rubyforge_project:
230
224
  rubygems_version: 2.5.1