pry 0.10.pre.1-i386-mswin32 → 0.10.0.pre3-i386-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (214) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +702 -0
  3. data/LICENSE +2 -2
  4. data/{README.markdown → README.md} +41 -35
  5. data/lib/pry.rb +82 -139
  6. data/lib/pry/cli.rb +77 -30
  7. data/lib/pry/code.rb +122 -183
  8. data/lib/pry/code/code_file.rb +103 -0
  9. data/lib/pry/code/code_range.rb +71 -0
  10. data/lib/pry/code/loc.rb +92 -0
  11. data/lib/pry/code_object.rb +172 -0
  12. data/lib/pry/color_printer.rb +55 -0
  13. data/lib/pry/command.rb +184 -28
  14. data/lib/pry/command_set.rb +113 -59
  15. data/lib/pry/commands.rb +4 -27
  16. data/lib/pry/commands/amend_line.rb +99 -0
  17. data/lib/pry/commands/bang.rb +20 -0
  18. data/lib/pry/commands/bang_pry.rb +17 -0
  19. data/lib/pry/commands/cat.rb +62 -0
  20. data/lib/pry/commands/cat/abstract_formatter.rb +27 -0
  21. data/lib/pry/commands/cat/exception_formatter.rb +77 -0
  22. data/lib/pry/commands/cat/file_formatter.rb +67 -0
  23. data/lib/pry/commands/cat/input_expression_formatter.rb +43 -0
  24. data/lib/pry/commands/cd.rb +41 -0
  25. data/lib/pry/commands/change_inspector.rb +27 -0
  26. data/lib/pry/commands/change_prompt.rb +26 -0
  27. data/lib/pry/commands/code_collector.rb +165 -0
  28. data/lib/pry/commands/disable_pry.rb +27 -0
  29. data/lib/pry/commands/disabled_commands.rb +2 -0
  30. data/lib/pry/commands/easter_eggs.rb +112 -0
  31. data/lib/pry/commands/edit.rb +195 -0
  32. data/lib/pry/commands/edit/exception_patcher.rb +25 -0
  33. data/lib/pry/commands/edit/file_and_line_locator.rb +36 -0
  34. data/lib/pry/commands/exit.rb +42 -0
  35. data/lib/pry/commands/exit_all.rb +29 -0
  36. data/lib/pry/commands/exit_program.rb +23 -0
  37. data/lib/pry/commands/find_method.rb +193 -0
  38. data/lib/pry/commands/fix_indent.rb +19 -0
  39. data/lib/pry/commands/gem_cd.rb +26 -0
  40. data/lib/pry/commands/gem_install.rb +32 -0
  41. data/lib/pry/commands/gem_list.rb +33 -0
  42. data/lib/pry/commands/gem_open.rb +29 -0
  43. data/lib/pry/commands/gist.rb +101 -0
  44. data/lib/pry/commands/help.rb +164 -0
  45. data/lib/pry/commands/hist.rb +180 -0
  46. data/lib/pry/commands/import_set.rb +22 -0
  47. data/lib/pry/commands/install_command.rb +53 -0
  48. data/lib/pry/commands/jump_to.rb +29 -0
  49. data/lib/pry/commands/list_inspectors.rb +35 -0
  50. data/lib/pry/commands/list_prompts.rb +35 -0
  51. data/lib/pry/commands/ls.rb +114 -0
  52. data/lib/pry/commands/ls/constants.rb +47 -0
  53. data/lib/pry/commands/ls/formatter.rb +49 -0
  54. data/lib/pry/commands/ls/globals.rb +48 -0
  55. data/lib/pry/commands/ls/grep.rb +21 -0
  56. data/lib/pry/commands/ls/instance_vars.rb +39 -0
  57. data/lib/pry/commands/ls/interrogatable.rb +18 -0
  58. data/lib/pry/commands/ls/jruby_hacks.rb +49 -0
  59. data/lib/pry/commands/ls/local_names.rb +35 -0
  60. data/lib/pry/commands/ls/local_vars.rb +39 -0
  61. data/lib/pry/commands/ls/ls_entity.rb +70 -0
  62. data/lib/pry/commands/ls/methods.rb +57 -0
  63. data/lib/pry/commands/ls/methods_helper.rb +46 -0
  64. data/lib/pry/commands/ls/self_methods.rb +32 -0
  65. data/lib/pry/commands/nesting.rb +25 -0
  66. data/lib/pry/commands/play.rb +103 -0
  67. data/lib/pry/commands/pry_backtrace.rb +25 -0
  68. data/lib/pry/commands/pry_version.rb +17 -0
  69. data/lib/pry/commands/raise_up.rb +32 -0
  70. data/lib/pry/commands/reload_code.rb +62 -0
  71. data/lib/pry/commands/reset.rb +18 -0
  72. data/lib/pry/commands/ri.rb +60 -0
  73. data/lib/pry/commands/save_file.rb +61 -0
  74. data/lib/pry/commands/shell_command.rb +48 -0
  75. data/lib/pry/commands/shell_mode.rb +25 -0
  76. data/lib/pry/commands/show_doc.rb +83 -0
  77. data/lib/pry/commands/show_info.rb +195 -0
  78. data/lib/pry/commands/show_input.rb +17 -0
  79. data/lib/pry/commands/show_source.rb +50 -0
  80. data/lib/pry/commands/simple_prompt.rb +22 -0
  81. data/lib/pry/commands/stat.rb +40 -0
  82. data/lib/pry/commands/switch_to.rb +23 -0
  83. data/lib/pry/commands/toggle_color.rb +24 -0
  84. data/lib/pry/commands/watch_expression.rb +105 -0
  85. data/lib/pry/commands/watch_expression/expression.rb +38 -0
  86. data/lib/pry/commands/whereami.rb +190 -0
  87. data/lib/pry/commands/wtf.rb +57 -0
  88. data/lib/pry/config.rb +20 -229
  89. data/lib/pry/config/behavior.rb +139 -0
  90. data/lib/pry/config/convenience.rb +26 -0
  91. data/lib/pry/config/default.rb +165 -0
  92. data/lib/pry/core_extensions.rb +59 -38
  93. data/lib/pry/editor.rb +133 -0
  94. data/lib/pry/exceptions.rb +77 -0
  95. data/lib/pry/helpers.rb +1 -0
  96. data/lib/pry/helpers/base_helpers.rb +40 -154
  97. data/lib/pry/helpers/command_helpers.rb +19 -130
  98. data/lib/pry/helpers/documentation_helpers.rb +21 -11
  99. data/lib/pry/helpers/table.rb +109 -0
  100. data/lib/pry/helpers/text.rb +8 -9
  101. data/lib/pry/history.rb +61 -45
  102. data/lib/pry/history_array.rb +11 -1
  103. data/lib/pry/hooks.rb +10 -32
  104. data/lib/pry/indent.rb +110 -38
  105. data/lib/pry/input_completer.rb +242 -0
  106. data/lib/pry/input_lock.rb +132 -0
  107. data/lib/pry/inspector.rb +27 -0
  108. data/lib/pry/last_exception.rb +61 -0
  109. data/lib/pry/method.rb +199 -200
  110. data/lib/pry/method/disowned.rb +53 -0
  111. data/lib/pry/method/patcher.rb +125 -0
  112. data/lib/pry/method/weird_method_locator.rb +186 -0
  113. data/lib/pry/module_candidate.rb +39 -33
  114. data/lib/pry/object_path.rb +82 -0
  115. data/lib/pry/output.rb +50 -0
  116. data/lib/pry/pager.rb +234 -0
  117. data/lib/pry/plugins.rb +4 -3
  118. data/lib/pry/prompt.rb +26 -0
  119. data/lib/pry/pry_class.rb +199 -227
  120. data/lib/pry/pry_instance.rb +344 -403
  121. data/lib/pry/rbx_path.rb +1 -1
  122. data/lib/pry/repl.rb +202 -0
  123. data/lib/pry/repl_file_loader.rb +20 -26
  124. data/lib/pry/rubygem.rb +82 -0
  125. data/lib/pry/terminal.rb +79 -0
  126. data/lib/pry/test/helper.rb +170 -0
  127. data/lib/pry/version.rb +1 -1
  128. data/lib/pry/wrapped_module.rb +133 -48
  129. metadata +132 -197
  130. data/.document +0 -2
  131. data/.gemtest +0 -0
  132. data/.gitignore +0 -16
  133. data/.travis.yml +0 -17
  134. data/.yardopts +0 -1
  135. data/CHANGELOG +0 -387
  136. data/CONTRIBUTORS +0 -36
  137. data/Gemfile +0 -2
  138. data/Rakefile +0 -137
  139. data/TODO +0 -117
  140. data/examples/example_basic.rb +0 -15
  141. data/examples/example_command_override.rb +0 -32
  142. data/examples/example_commands.rb +0 -36
  143. data/examples/example_hooks.rb +0 -9
  144. data/examples/example_image_edit.rb +0 -67
  145. data/examples/example_input.rb +0 -7
  146. data/examples/example_input2.rb +0 -29
  147. data/examples/example_output.rb +0 -11
  148. data/examples/example_print.rb +0 -6
  149. data/examples/example_prompt.rb +0 -9
  150. data/examples/helper.rb +0 -6
  151. data/lib/pry/completion.rb +0 -221
  152. data/lib/pry/custom_completions.rb +0 -6
  153. data/lib/pry/default_commands/cd.rb +0 -81
  154. data/lib/pry/default_commands/commands.rb +0 -62
  155. data/lib/pry/default_commands/context.rb +0 -98
  156. data/lib/pry/default_commands/easter_eggs.rb +0 -95
  157. data/lib/pry/default_commands/editing.rb +0 -420
  158. data/lib/pry/default_commands/find_method.rb +0 -169
  159. data/lib/pry/default_commands/gems.rb +0 -84
  160. data/lib/pry/default_commands/gist.rb +0 -187
  161. data/lib/pry/default_commands/help.rb +0 -127
  162. data/lib/pry/default_commands/hist.rb +0 -120
  163. data/lib/pry/default_commands/input_and_output.rb +0 -306
  164. data/lib/pry/default_commands/introspection.rb +0 -410
  165. data/lib/pry/default_commands/ls.rb +0 -272
  166. data/lib/pry/default_commands/misc.rb +0 -38
  167. data/lib/pry/default_commands/navigating_pry.rb +0 -110
  168. data/lib/pry/default_commands/whereami.rb +0 -92
  169. data/lib/pry/extended_commands/experimental.rb +0 -7
  170. data/lib/pry/rbx_method.rb +0 -13
  171. data/man/pry.1 +0 -195
  172. data/man/pry.1.html +0 -204
  173. data/man/pry.1.ronn +0 -141
  174. data/pry.gemspec +0 -46
  175. data/test/candidate_helper1.rb +0 -11
  176. data/test/candidate_helper2.rb +0 -8
  177. data/test/helper.rb +0 -223
  178. data/test/test_cli.rb +0 -78
  179. data/test/test_code.rb +0 -201
  180. data/test/test_command.rb +0 -712
  181. data/test/test_command_helpers.rb +0 -9
  182. data/test/test_command_integration.rb +0 -668
  183. data/test/test_command_set.rb +0 -610
  184. data/test/test_completion.rb +0 -62
  185. data/test/test_control_d_handler.rb +0 -45
  186. data/test/test_default_commands/example.erb +0 -5
  187. data/test/test_default_commands/test_cd.rb +0 -318
  188. data/test/test_default_commands/test_context.rb +0 -280
  189. data/test/test_default_commands/test_documentation.rb +0 -314
  190. data/test/test_default_commands/test_find_method.rb +0 -50
  191. data/test/test_default_commands/test_gems.rb +0 -18
  192. data/test/test_default_commands/test_help.rb +0 -57
  193. data/test/test_default_commands/test_input.rb +0 -428
  194. data/test/test_default_commands/test_introspection.rb +0 -511
  195. data/test/test_default_commands/test_ls.rb +0 -151
  196. data/test/test_default_commands/test_shell.rb +0 -343
  197. data/test/test_default_commands/test_show_source.rb +0 -432
  198. data/test/test_exception_whitelist.rb +0 -21
  199. data/test/test_history_array.rb +0 -65
  200. data/test/test_hooks.rb +0 -521
  201. data/test/test_indent.rb +0 -277
  202. data/test/test_input_stack.rb +0 -86
  203. data/test/test_method.rb +0 -401
  204. data/test/test_pry.rb +0 -463
  205. data/test/test_pry_defaults.rb +0 -419
  206. data/test/test_pry_history.rb +0 -84
  207. data/test/test_pry_output.rb +0 -41
  208. data/test/test_sticky_locals.rb +0 -155
  209. data/test/test_syntax_checking.rb +0 -65
  210. data/test/test_wrapped_module.rb +0 -174
  211. data/test/testrc +0 -2
  212. data/test/testrcbad +0 -2
  213. data/wiki/Customizing-pry.md +0 -397
  214. data/wiki/Home.md +0 -4
@@ -0,0 +1,170 @@
1
+ require 'pry'
2
+
3
+ # in case the tests call reset_defaults, ensure we reset them to
4
+ # amended (test friendly) values
5
+ class << Pry
6
+ alias_method :orig_reset_defaults, :reset_defaults
7
+ def reset_defaults
8
+ orig_reset_defaults
9
+
10
+ Pry.config.color = false
11
+ Pry.config.pager = false
12
+ Pry.config.should_load_rc = false
13
+ Pry.config.should_load_local_rc= false
14
+ Pry.config.should_load_plugins = false
15
+ Pry.config.history.should_load = false
16
+ Pry.config.history.should_save = false
17
+ Pry.config.correct_indent = false
18
+ Pry.config.hooks = Pry::Hooks.new
19
+ Pry.config.collision_warning = false
20
+ end
21
+ end
22
+ Pry.reset_defaults
23
+
24
+ # A global space for storing temporary state during tests.
25
+
26
+ module PryTestHelpers
27
+
28
+ module_function
29
+
30
+ # inject a variable into a binding
31
+ def inject_var(name, value, b)
32
+ Pry.current[:pry_local] = value
33
+ b.eval("#{name} = ::Pry.current[:pry_local]")
34
+ ensure
35
+ Pry.current[:pry_local] = nil
36
+ end
37
+
38
+ def constant_scope(*names)
39
+ names.each do |name|
40
+ Object.remove_const name if Object.const_defined?(name)
41
+ end
42
+
43
+ yield
44
+ ensure
45
+ names.each do |name|
46
+ Object.remove_const name if Object.const_defined?(name)
47
+ end
48
+ end
49
+
50
+ # Open a temp file and yield it to the block, closing it after
51
+ # @return [String] The path of the temp file
52
+ def temp_file(ext='.rb')
53
+ file = Tempfile.new(['pry', ext])
54
+ yield file
55
+ ensure
56
+ file.close(true) if file
57
+ File.unlink("#{file.path}c") if File.exists?("#{file.path}c") # rbx
58
+ end
59
+
60
+ def unindent(*args)
61
+ Pry::Helpers::CommandHelpers.unindent(*args)
62
+ end
63
+
64
+ def mock_command(cmd, args=[], opts={})
65
+ output = StringIO.new
66
+ pry = Pry.new(output: output)
67
+ ret = cmd.new(opts.merge(pry_instance: pry, :output => output)).call_safely(*args)
68
+ Struct.new(:output, :return).new(output.string, ret)
69
+ end
70
+
71
+ def mock_exception(*mock_backtrace)
72
+ StandardError.new.tap do |e|
73
+ e.define_singleton_method(:backtrace) { mock_backtrace }
74
+ end
75
+ end
76
+ end
77
+
78
+ def pry_tester(*args, &block)
79
+ if args.length == 0 || args[0].is_a?(Hash)
80
+ args.unshift(Pry.toplevel_binding)
81
+ end
82
+
83
+ PryTester.new(*args).tap do |t|
84
+ (class << t; self; end).class_eval(&block) if block
85
+ end
86
+ end
87
+
88
+ def pry_eval(*eval_strs)
89
+ if eval_strs.first.is_a? String
90
+ binding = Pry.toplevel_binding
91
+ else
92
+ binding = Pry.binding_for(eval_strs.shift)
93
+ end
94
+
95
+ pry_tester(binding).eval(*eval_strs)
96
+ end
97
+
98
+ class PryTester
99
+ extend Forwardable
100
+
101
+ attr_reader :pry, :out
102
+
103
+ def_delegators :@pry, :eval_string, :eval_string=
104
+
105
+ def initialize(target = TOPLEVEL_BINDING, options = {})
106
+ @pry = Pry.new(options.merge(:target => target))
107
+ @history = options[:history]
108
+
109
+ @pry.inject_sticky_locals!
110
+ reset_output
111
+ end
112
+
113
+ def eval(*strs)
114
+ reset_output
115
+ result = nil
116
+
117
+ strs.flatten.each do |str|
118
+ str = "#{str.strip}\n"
119
+ @history.push str if @history
120
+
121
+ if @pry.process_command(str)
122
+ result = last_command_result_or_output
123
+ else
124
+ result = @pry.evaluate_ruby(str)
125
+ end
126
+ end
127
+
128
+ result
129
+ end
130
+
131
+ def push(*lines)
132
+ Array(lines).flatten.each do |line|
133
+ @pry.eval(line)
134
+ end
135
+ end
136
+
137
+ def push_binding(context)
138
+ @pry.push_binding context
139
+ end
140
+
141
+ def last_output
142
+ @out.string if @out
143
+ end
144
+
145
+ def process_command(command_str)
146
+ @pry.process_command(command_str) or raise "Not a valid command"
147
+ last_command_result_or_output
148
+ end
149
+
150
+ def last_command_result
151
+ result = Pry.current[:pry_cmd_result]
152
+ result.retval if result
153
+ end
154
+
155
+ protected
156
+
157
+ def last_command_result_or_output
158
+ result = last_command_result
159
+ if result != Pry::Command::VOID_VALUE
160
+ result
161
+ else
162
+ last_output
163
+ end
164
+ end
165
+
166
+ def reset_output
167
+ @out = StringIO.new
168
+ @pry.output = @out
169
+ end
170
+ end
@@ -1,3 +1,3 @@
1
1
  class Pry
2
- VERSION = "0.10.pre.1"
2
+ VERSION = "0.10.0.pre3"
3
3
  end
@@ -14,10 +14,10 @@ class Pry
14
14
  end
15
15
 
16
16
  class WrappedModule
17
- include Pry::Helpers::DocumentationHelpers
17
+ include Helpers::BaseHelpers
18
+ include CodeObject::Helpers
18
19
 
19
20
  attr_reader :wrapped
20
- private :wrapped
21
21
 
22
22
  # Convert a string to a module.
23
23
  #
@@ -27,11 +27,7 @@ class Pry
27
27
  # @example
28
28
  # Pry::WrappedModule.from_str("Pry::Code")
29
29
  def self.from_str(mod_name, target=TOPLEVEL_BINDING)
30
- kind = target.eval("defined?(#{mod_name})")
31
-
32
- # if we dont limit it to constants then from_str could end up
33
- # executing methods which is not good, i.e `show-source pry`
34
- if (kind == "constant" && target.eval(mod_name).is_a?(Module))
30
+ if safe_to_evaluate?(mod_name, target)
35
31
  Pry::WrappedModule.new(target.eval(mod_name))
36
32
  else
37
33
  nil
@@ -40,6 +36,23 @@ class Pry
40
36
  nil
41
37
  end
42
38
 
39
+ class << self
40
+ private
41
+
42
+ # We use this method to decide whether code is safe to eval. Method's are
43
+ # generally not, but everything else is.
44
+ # TODO: is just checking != "method" enough??
45
+ # TODO: see duplication of this method in Pry::CodeObject
46
+ # @param [String] str The string to lookup.
47
+ # @param [Binding] target Where the lookup takes place.
48
+ # @return [Boolean]
49
+ def safe_to_evaluate?(str, target)
50
+ return true if str.strip == "self"
51
+ kind = target.eval("defined?(#{str})")
52
+ kind =~ /variable|constant/
53
+ end
54
+ end
55
+
43
56
  # @raise [ArgumentError] if the argument is not a `Module`
44
57
  # @param [Module] mod
45
58
  def initialize(mod)
@@ -52,6 +65,15 @@ class Pry
52
65
  @doc = nil
53
66
  end
54
67
 
68
+ # Returns an array of the names of the constants accessible in the wrapped
69
+ # module. This avoids the problem of accidentally calling the singleton
70
+ # method `Module.constants`.
71
+ # @param [Boolean] inherit Include the names of constants from included
72
+ # modules?
73
+ def constants(inherit = true)
74
+ Module.instance_method(:constants).bind(@wrapped).call(inherit)
75
+ end
76
+
55
77
  # The prefix that would appear before methods defined on this class.
56
78
  #
57
79
  # i.e. the "String." or "String#" in String.new and String#initialize.
@@ -83,7 +105,23 @@ class Pry
83
105
  # Is this a singleton class?
84
106
  # @return [Boolean]
85
107
  def singleton_class?
86
- wrapped != wrapped.ancestors.first
108
+ if Pry::Method.safe_send(wrapped, :respond_to?, :singleton_class?)
109
+ Pry::Method.safe_send(wrapped, :singleton_class?)
110
+ else
111
+ wrapped != Pry::Method.safe_send(wrapped, :ancestors).first
112
+ end
113
+ end
114
+
115
+ # Is this strictly a module? (does not match classes)
116
+ # @return [Boolean]
117
+ def module?
118
+ wrapped.instance_of?(Module)
119
+ end
120
+
121
+ # Is this strictly a class?
122
+ # @return [Boolean]
123
+ def class?
124
+ wrapped.instance_of?(Class)
87
125
  end
88
126
 
89
127
  # Get the instance associated with this singleton class.
@@ -192,26 +230,63 @@ class Pry
192
230
  @memoized_candidates[rank] ||= Candidate.new(self, rank)
193
231
  end
194
232
 
195
-
196
233
  # @return [Fixnum] The number of candidate definitions for the
197
234
  # current module.
198
235
  def number_of_candidates
199
236
  method_candidates.count
200
237
  end
201
238
 
239
+ # @note On JRuby 1.9 and higher, in certain conditions, this method chucks
240
+ # away its ability to be quick (when there are lots of monkey patches,
241
+ # like in Rails). However, it should be efficient enough on other rubies.
242
+ # @see https://github.com/jruby/jruby/issues/525
243
+ # @return [Enumerator, Array] on JRuby 1.9 and higher returns Array, on
244
+ # other rubies returns Enumerator
245
+ def candidates
246
+ enum = Enumerator.new do |y|
247
+ (0...number_of_candidates).each do |num|
248
+ y.yield candidate(num)
249
+ end
250
+ end
251
+ Pry::Helpers::BaseHelpers.jruby_19? ? enum.to_a : enum
252
+ end
253
+
202
254
  # @return [Boolean] Whether YARD docs are available for this module.
203
255
  def yard_docs?
204
256
  !!(defined?(YARD) && YARD::Registry.at(name))
205
257
  end
206
258
 
259
+ # @param [Fixnum] times How far to travel up the ancestor chain.
260
+ # @return [Pry::WrappedModule, nil] The wrapped module that is the
261
+ # superclass.
262
+ # When `self` is a `Module` then return the
263
+ # nth ancestor, otherwise (in the case of classes) return the
264
+ # nth ancestor that is a class.
265
+ def super(times=1)
266
+ return self if times.zero?
267
+
268
+ if wrapped.is_a?(Class)
269
+ sup = ancestors.select { |v| v.is_a?(Class) }[times]
270
+ else
271
+ sup = ancestors[times]
272
+ end
273
+
274
+ Pry::WrappedModule(sup) if sup
275
+ end
276
+
207
277
  private
208
278
 
209
- # @return [Pry::WrappedModule::Candidate] The candidate of rank 0,
210
- # that is the 'monkey patch' of this module with the highest
211
- # number of methods. It is considered the 'canonical' definition
212
- # for the module.
279
+ # @return [Pry::WrappedModule::Candidate] The candidate with the
280
+ # highest rank, that is the 'monkey patch' of this module with the
281
+ # highest number of methods, which contains a source code line that
282
+ # defines the module. It is considered the 'canonical' definition
283
+ # for the module. In the absense of a suitable candidate, the
284
+ # candidate of rank 0 will be returned, or a CommandError raised if
285
+ # there are no candidates at all.
213
286
  def primary_candidate
214
- @primary_candidate ||= candidate(0)
287
+ @primary_candidate ||= candidates.find { |c| c.file } ||
288
+ # This will raise an exception if there is no candidate at all.
289
+ candidate(0)
215
290
  end
216
291
 
217
292
  # @return [Array<Array<Pry::Method>>] The array of `Pry::Method` objects,
@@ -231,34 +306,57 @@ class Pry
231
306
  def all_source_locations_by_popularity
232
307
  return @all_source_locations_by_popularity if @all_source_locations_by_popularity
233
308
 
234
- ims = all_methods_for(wrapped)
309
+ ims = all_relevant_methods_for(wrapped)
310
+ @all_source_locations_by_popularity = ims.group_by { |v| Array(v.source_location).first }.
311
+ sort_by do |path, methods|
312
+ expanded = File.expand_path(path)
313
+ load_order = $LOADED_FEATURES.index{ |file| expanded.end_with?(file) }
314
+
315
+ [-methods.size, load_order || (1.0 / 0.0)]
316
+ end
317
+ end
235
318
 
236
- # reject __class_init__ because it's an odd rbx specific thing that causes tests to fail
237
- ims = ims.select(&:source_location).reject{ |x| x.name == '__class_init__' }
319
+ # We only want methods that have a non-nil `source_location`. We also
320
+ # skip some spooky internal methods.
321
+ # (i.e we skip `__class_init__` because it's an odd rbx specific thing that causes tests to fail.)
322
+ # @return [Array<Pry::Method>]
323
+ def all_relevant_methods_for(mod)
324
+ methods = all_methods_for(mod).select(&:source_location).
325
+ reject{ |x| x.name == '__class_init__' || method_defined_by_forwardable_module?(x) }
238
326
 
239
- @all_source_locations_by_popularity = ims.group_by { |v| Array(v.source_location).first }.
240
- sort_by { |k, v| -v.size }
327
+ return methods unless methods.empty?
328
+
329
+ safe_send(mod, :constants).map do |const_name|
330
+ if const = nested_module?(mod, const_name)
331
+ all_relevant_methods_for(const)
332
+ else
333
+ []
334
+ end
335
+ end.flatten
241
336
  end
242
337
 
243
338
  # Return all methods (instance methods and class methods) for a
244
339
  # given module.
340
+ # @return [Array<Pry::Method>]
245
341
  def all_methods_for(mod)
246
- all_from_common(mod, :instance_method) + all_from_common(mod, :method)
247
- end
248
-
249
- # FIXME: a variant of this method is also found in Pry::Method
250
- def all_from_common(mod, method_type)
251
- %w(public protected private).map do |visibility|
252
- safe_send(mod, :"#{visibility}_#{method_type}s", false).select do |method_name|
253
- if method_type == :method
254
- safe_send(mod, method_type, method_name).owner == class << mod; self; end
255
- else
256
- safe_send(mod, method_type, method_name).owner == mod
257
- end
258
- end.map do |method_name|
259
- Pry::Method.new(safe_send(mod, method_type, method_name), :visibility => visibility.to_sym)
260
- end
261
- end.flatten
342
+ Pry::Method.all_from_obj(mod, false) + Pry::Method.all_from_class(mod, false)
343
+ end
344
+
345
+ def nested_module?(parent, name)
346
+ return if safe_send(parent, :autoload?, name)
347
+ child = safe_send(parent, :const_get, name)
348
+ return unless Module === child
349
+ return unless safe_send(child, :name) == "#{safe_send(parent, :name)}::#{name}"
350
+ child
351
+ end
352
+
353
+ # Detect methods that are defined with `def_delegator` from the Forwardable
354
+ # module. We want to reject these methods as they screw up module
355
+ # extraction since the `source_location` for such methods points at forwardable.rb
356
+ # TODO: make this more robust as valid user-defined files called
357
+ # forwardable.rb are also skipped.
358
+ def method_defined_by_forwardable_module?(method)
359
+ method.source_location.first =~ /forwardable\.rb/
262
360
  end
263
361
 
264
362
  # memoized lines for file
@@ -271,18 +369,5 @@ class Pry
271
369
  @lines_for_file[file] ||= File.readlines(file)
272
370
  end
273
371
  end
274
-
275
- # FIXME: this method is also found in Pry::Method
276
- def safe_send(obj, method, *args, &block)
277
- (Module === obj ? Module : Object).instance_method(method).bind(obj).call(*args, &block)
278
- end
279
-
280
- # @param [String] doc The raw docstring to process.
281
- # @return [String] Process docstring markup and strip leading white space.
282
- def process_doc(doc)
283
- process_comment_markup(strip_leading_hash_and_whitespace_from_ruby_comments(doc),
284
- :ruby)
285
- end
286
-
287
372
  end
288
373
  end
metadata CHANGED
@@ -1,313 +1,248 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.pre.1
5
- prerelease: 5
4
+ version: 0.10.0.pre3
6
5
  platform: i386-mswin32
7
6
  authors:
8
7
  - John Mair (banisterfiend)
9
8
  - Conrad Irwin
9
+ - Ryan Fitzgerald
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-07-05 00:00:00.000000000 Z
13
+ date: 2014-05-15 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: coderay
17
17
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
18
  requirements:
20
- - - ~>
19
+ - - "~>"
21
20
  - !ruby/object:Gem::Version
22
- version: 1.0.5
21
+ version: 1.1.0
23
22
  type: :runtime
24
23
  prerelease: false
25
24
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
25
  requirements:
28
- - - ~>
26
+ - - "~>"
29
27
  - !ruby/object:Gem::Version
30
- version: 1.0.5
28
+ version: 1.1.0
31
29
  - !ruby/object:Gem::Dependency
32
30
  name: slop
33
31
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
32
  requirements:
36
- - - ~>
33
+ - - "~>"
37
34
  - !ruby/object:Gem::Version
38
- version: 3.3.1
35
+ version: '3.4'
39
36
  type: :runtime
40
37
  prerelease: false
41
38
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
39
  requirements:
44
- - - ~>
40
+ - - "~>"
45
41
  - !ruby/object:Gem::Version
46
- version: 3.3.1
42
+ version: '3.4'
47
43
  - !ruby/object:Gem::Dependency
48
44
  name: method_source
49
45
  requirement: !ruby/object:Gem::Requirement
50
- none: false
51
46
  requirements:
52
- - - ~>
47
+ - - "~>"
53
48
  - !ruby/object:Gem::Version
54
- version: '0.8'
49
+ version: 0.8.1
55
50
  type: :runtime
56
51
  prerelease: false
57
52
  version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
53
  requirements:
60
- - - ~>
54
+ - - "~>"
61
55
  - !ruby/object:Gem::Version
62
- version: '0.8'
56
+ version: 0.8.1
63
57
  - !ruby/object:Gem::Dependency
64
- name: bacon
58
+ name: bundler
65
59
  requirement: !ruby/object:Gem::Requirement
66
- none: false
67
60
  requirements:
68
- - - ~>
61
+ - - "~>"
69
62
  - !ruby/object:Gem::Version
70
- version: '1.1'
63
+ version: '1.0'
71
64
  type: :development
72
65
  prerelease: false
73
66
  version_requirements: !ruby/object:Gem::Requirement
74
- none: false
75
67
  requirements:
76
- - - ~>
68
+ - - "~>"
77
69
  - !ruby/object:Gem::Version
78
- version: '1.1'
79
- - !ruby/object:Gem::Dependency
80
- name: open4
81
- requirement: !ruby/object:Gem::Requirement
82
- none: false
83
- requirements:
84
- - - ~>
85
- - !ruby/object:Gem::Version
86
- version: '1.3'
87
- type: :development
88
- prerelease: false
89
- version_requirements: !ruby/object:Gem::Requirement
90
- none: false
91
- requirements:
92
- - - ~>
93
- - !ruby/object:Gem::Version
94
- version: '1.3'
95
- - !ruby/object:Gem::Dependency
96
- name: rake
97
- requirement: !ruby/object:Gem::Requirement
98
- none: false
99
- requirements:
100
- - - ~>
101
- - !ruby/object:Gem::Version
102
- version: '0.9'
103
- type: :development
104
- prerelease: false
105
- version_requirements: !ruby/object:Gem::Requirement
106
- none: false
107
- requirements:
108
- - - ~>
109
- - !ruby/object:Gem::Version
110
- version: '0.9'
70
+ version: '1.0'
111
71
  - !ruby/object:Gem::Dependency
112
72
  name: win32console
113
73
  requirement: !ruby/object:Gem::Requirement
114
- none: false
115
74
  requirements:
116
- - - ~>
75
+ - - "~>"
117
76
  - !ruby/object:Gem::Version
118
77
  version: '1.3'
119
78
  type: :runtime
120
79
  prerelease: false
121
80
  version_requirements: !ruby/object:Gem::Requirement
122
- none: false
123
81
  requirements:
124
- - - ~>
82
+ - - "~>"
125
83
  - !ruby/object:Gem::Version
126
84
  version: '1.3'
127
85
  description: An IRB alternative and runtime developer console
128
86
  email:
129
87
  - jrmair@gmail.com
130
88
  - conrad.irwin@gmail.com
89
+ - rwfitzge@gmail.com
131
90
  executables:
132
91
  - pry
133
92
  extensions: []
134
93
  extra_rdoc_files: []
135
94
  files:
136
- - .document
137
- - .gemtest
138
- - .gitignore
139
- - .travis.yml
140
- - .yardopts
141
- - CHANGELOG
142
- - CONTRIBUTORS
143
- - Gemfile
95
+ - CHANGELOG.md
144
96
  - LICENSE
145
- - README.markdown
146
- - Rakefile
147
- - TODO
97
+ - README.md
148
98
  - bin/pry
149
- - examples/example_basic.rb
150
- - examples/example_command_override.rb
151
- - examples/example_commands.rb
152
- - examples/example_hooks.rb
153
- - examples/example_image_edit.rb
154
- - examples/example_input.rb
155
- - examples/example_input2.rb
156
- - examples/example_output.rb
157
- - examples/example_print.rb
158
- - examples/example_prompt.rb
159
- - examples/helper.rb
160
99
  - lib/pry.rb
161
100
  - lib/pry/cli.rb
162
101
  - lib/pry/code.rb
102
+ - lib/pry/code/code_file.rb
103
+ - lib/pry/code/code_range.rb
104
+ - lib/pry/code/loc.rb
105
+ - lib/pry/code_object.rb
106
+ - lib/pry/color_printer.rb
163
107
  - lib/pry/command.rb
164
108
  - lib/pry/command_set.rb
165
109
  - lib/pry/commands.rb
166
- - lib/pry/completion.rb
110
+ - lib/pry/commands/amend_line.rb
111
+ - lib/pry/commands/bang.rb
112
+ - lib/pry/commands/bang_pry.rb
113
+ - lib/pry/commands/cat.rb
114
+ - lib/pry/commands/cat/abstract_formatter.rb
115
+ - lib/pry/commands/cat/exception_formatter.rb
116
+ - lib/pry/commands/cat/file_formatter.rb
117
+ - lib/pry/commands/cat/input_expression_formatter.rb
118
+ - lib/pry/commands/cd.rb
119
+ - lib/pry/commands/change_inspector.rb
120
+ - lib/pry/commands/change_prompt.rb
121
+ - lib/pry/commands/code_collector.rb
122
+ - lib/pry/commands/disable_pry.rb
123
+ - lib/pry/commands/disabled_commands.rb
124
+ - lib/pry/commands/easter_eggs.rb
125
+ - lib/pry/commands/edit.rb
126
+ - lib/pry/commands/edit/exception_patcher.rb
127
+ - lib/pry/commands/edit/file_and_line_locator.rb
128
+ - lib/pry/commands/exit.rb
129
+ - lib/pry/commands/exit_all.rb
130
+ - lib/pry/commands/exit_program.rb
131
+ - lib/pry/commands/find_method.rb
132
+ - lib/pry/commands/fix_indent.rb
133
+ - lib/pry/commands/gem_cd.rb
134
+ - lib/pry/commands/gem_install.rb
135
+ - lib/pry/commands/gem_list.rb
136
+ - lib/pry/commands/gem_open.rb
137
+ - lib/pry/commands/gist.rb
138
+ - lib/pry/commands/help.rb
139
+ - lib/pry/commands/hist.rb
140
+ - lib/pry/commands/import_set.rb
141
+ - lib/pry/commands/install_command.rb
142
+ - lib/pry/commands/jump_to.rb
143
+ - lib/pry/commands/list_inspectors.rb
144
+ - lib/pry/commands/list_prompts.rb
145
+ - lib/pry/commands/ls.rb
146
+ - lib/pry/commands/ls/constants.rb
147
+ - lib/pry/commands/ls/formatter.rb
148
+ - lib/pry/commands/ls/globals.rb
149
+ - lib/pry/commands/ls/grep.rb
150
+ - lib/pry/commands/ls/instance_vars.rb
151
+ - lib/pry/commands/ls/interrogatable.rb
152
+ - lib/pry/commands/ls/jruby_hacks.rb
153
+ - lib/pry/commands/ls/local_names.rb
154
+ - lib/pry/commands/ls/local_vars.rb
155
+ - lib/pry/commands/ls/ls_entity.rb
156
+ - lib/pry/commands/ls/methods.rb
157
+ - lib/pry/commands/ls/methods_helper.rb
158
+ - lib/pry/commands/ls/self_methods.rb
159
+ - lib/pry/commands/nesting.rb
160
+ - lib/pry/commands/play.rb
161
+ - lib/pry/commands/pry_backtrace.rb
162
+ - lib/pry/commands/pry_version.rb
163
+ - lib/pry/commands/raise_up.rb
164
+ - lib/pry/commands/reload_code.rb
165
+ - lib/pry/commands/reset.rb
166
+ - lib/pry/commands/ri.rb
167
+ - lib/pry/commands/save_file.rb
168
+ - lib/pry/commands/shell_command.rb
169
+ - lib/pry/commands/shell_mode.rb
170
+ - lib/pry/commands/show_doc.rb
171
+ - lib/pry/commands/show_info.rb
172
+ - lib/pry/commands/show_input.rb
173
+ - lib/pry/commands/show_source.rb
174
+ - lib/pry/commands/simple_prompt.rb
175
+ - lib/pry/commands/stat.rb
176
+ - lib/pry/commands/switch_to.rb
177
+ - lib/pry/commands/toggle_color.rb
178
+ - lib/pry/commands/watch_expression.rb
179
+ - lib/pry/commands/watch_expression/expression.rb
180
+ - lib/pry/commands/whereami.rb
181
+ - lib/pry/commands/wtf.rb
167
182
  - lib/pry/config.rb
183
+ - lib/pry/config/behavior.rb
184
+ - lib/pry/config/convenience.rb
185
+ - lib/pry/config/default.rb
168
186
  - lib/pry/core_extensions.rb
169
- - lib/pry/custom_completions.rb
170
- - lib/pry/default_commands/cd.rb
171
- - lib/pry/default_commands/commands.rb
172
- - lib/pry/default_commands/context.rb
173
- - lib/pry/default_commands/easter_eggs.rb
174
- - lib/pry/default_commands/editing.rb
175
- - lib/pry/default_commands/find_method.rb
176
- - lib/pry/default_commands/gems.rb
177
- - lib/pry/default_commands/gist.rb
178
- - lib/pry/default_commands/help.rb
179
- - lib/pry/default_commands/hist.rb
180
- - lib/pry/default_commands/input_and_output.rb
181
- - lib/pry/default_commands/introspection.rb
182
- - lib/pry/default_commands/ls.rb
183
- - lib/pry/default_commands/misc.rb
184
- - lib/pry/default_commands/navigating_pry.rb
185
- - lib/pry/default_commands/whereami.rb
186
- - lib/pry/extended_commands/experimental.rb
187
+ - lib/pry/editor.rb
188
+ - lib/pry/exceptions.rb
187
189
  - lib/pry/helpers.rb
188
190
  - lib/pry/helpers/base_helpers.rb
189
191
  - lib/pry/helpers/command_helpers.rb
190
192
  - lib/pry/helpers/documentation_helpers.rb
191
193
  - lib/pry/helpers/options_helpers.rb
194
+ - lib/pry/helpers/table.rb
192
195
  - lib/pry/helpers/text.rb
193
196
  - lib/pry/history.rb
194
197
  - lib/pry/history_array.rb
195
198
  - lib/pry/hooks.rb
196
199
  - lib/pry/indent.rb
200
+ - lib/pry/input_completer.rb
201
+ - lib/pry/input_lock.rb
202
+ - lib/pry/inspector.rb
203
+ - lib/pry/last_exception.rb
197
204
  - lib/pry/method.rb
205
+ - lib/pry/method/disowned.rb
206
+ - lib/pry/method/patcher.rb
207
+ - lib/pry/method/weird_method_locator.rb
198
208
  - lib/pry/module_candidate.rb
209
+ - lib/pry/object_path.rb
210
+ - lib/pry/output.rb
211
+ - lib/pry/pager.rb
199
212
  - lib/pry/plugins.rb
213
+ - lib/pry/prompt.rb
200
214
  - lib/pry/pry_class.rb
201
215
  - lib/pry/pry_instance.rb
202
- - lib/pry/rbx_method.rb
203
216
  - lib/pry/rbx_path.rb
217
+ - lib/pry/repl.rb
204
218
  - lib/pry/repl_file_loader.rb
219
+ - lib/pry/rubygem.rb
220
+ - lib/pry/terminal.rb
221
+ - lib/pry/test/helper.rb
205
222
  - lib/pry/version.rb
206
223
  - lib/pry/wrapped_module.rb
207
- - man/pry.1
208
- - man/pry.1.html
209
- - man/pry.1.ronn
210
- - pry.gemspec
211
- - test/candidate_helper1.rb
212
- - test/candidate_helper2.rb
213
- - test/helper.rb
214
- - test/test_cli.rb
215
- - test/test_code.rb
216
- - test/test_command.rb
217
- - test/test_command_helpers.rb
218
- - test/test_command_integration.rb
219
- - test/test_command_set.rb
220
- - test/test_completion.rb
221
- - test/test_control_d_handler.rb
222
- - test/test_default_commands/example.erb
223
- - test/test_default_commands/test_cd.rb
224
- - test/test_default_commands/test_context.rb
225
- - test/test_default_commands/test_documentation.rb
226
- - test/test_default_commands/test_find_method.rb
227
- - test/test_default_commands/test_gems.rb
228
- - test/test_default_commands/test_help.rb
229
- - test/test_default_commands/test_input.rb
230
- - test/test_default_commands/test_introspection.rb
231
- - test/test_default_commands/test_ls.rb
232
- - test/test_default_commands/test_shell.rb
233
- - test/test_default_commands/test_show_source.rb
234
- - test/test_exception_whitelist.rb
235
- - test/test_history_array.rb
236
- - test/test_hooks.rb
237
- - test/test_indent.rb
238
- - test/test_input_stack.rb
239
- - test/test_method.rb
240
- - test/test_pry.rb
241
- - test/test_pry_defaults.rb
242
- - test/test_pry_history.rb
243
- - test/test_pry_output.rb
244
- - test/test_sticky_locals.rb
245
- - test/test_syntax_checking.rb
246
- - test/test_wrapped_module.rb
247
- - test/testrc
248
- - test/testrcbad
249
- - wiki/Customizing-pry.md
250
- - wiki/Home.md
251
- homepage: http://pry.github.com
252
- licenses: []
224
+ homepage: http://pryrepl.org
225
+ licenses:
226
+ - MIT
227
+ metadata: {}
253
228
  post_install_message:
254
229
  rdoc_options: []
255
230
  require_paths:
256
231
  - lib
257
232
  required_ruby_version: !ruby/object:Gem::Requirement
258
- none: false
259
233
  requirements:
260
- - - ! '>='
234
+ - - ">="
261
235
  - !ruby/object:Gem::Version
262
236
  version: '0'
263
237
  required_rubygems_version: !ruby/object:Gem::Requirement
264
- none: false
265
238
  requirements:
266
- - - ! '>'
239
+ - - ">"
267
240
  - !ruby/object:Gem::Version
268
241
  version: 1.3.1
269
242
  requirements: []
270
243
  rubyforge_project:
271
- rubygems_version: 1.8.24
244
+ rubygems_version: 2.2.2
272
245
  signing_key:
273
- specification_version: 3
246
+ specification_version: 4
274
247
  summary: An IRB alternative and runtime developer console
275
- test_files:
276
- - test/candidate_helper1.rb
277
- - test/candidate_helper2.rb
278
- - test/helper.rb
279
- - test/test_cli.rb
280
- - test/test_code.rb
281
- - test/test_command.rb
282
- - test/test_command_helpers.rb
283
- - test/test_command_integration.rb
284
- - test/test_command_set.rb
285
- - test/test_completion.rb
286
- - test/test_control_d_handler.rb
287
- - test/test_default_commands/example.erb
288
- - test/test_default_commands/test_cd.rb
289
- - test/test_default_commands/test_context.rb
290
- - test/test_default_commands/test_documentation.rb
291
- - test/test_default_commands/test_find_method.rb
292
- - test/test_default_commands/test_gems.rb
293
- - test/test_default_commands/test_help.rb
294
- - test/test_default_commands/test_input.rb
295
- - test/test_default_commands/test_introspection.rb
296
- - test/test_default_commands/test_ls.rb
297
- - test/test_default_commands/test_shell.rb
298
- - test/test_default_commands/test_show_source.rb
299
- - test/test_exception_whitelist.rb
300
- - test/test_history_array.rb
301
- - test/test_hooks.rb
302
- - test/test_indent.rb
303
- - test/test_input_stack.rb
304
- - test/test_method.rb
305
- - test/test_pry.rb
306
- - test/test_pry_defaults.rb
307
- - test/test_pry_history.rb
308
- - test/test_pry_output.rb
309
- - test/test_sticky_locals.rb
310
- - test/test_syntax_checking.rb
311
- - test/test_wrapped_module.rb
312
- - test/testrc
313
- - test/testrcbad
248
+ test_files: []