pry 0.9.6.1-i386-mingw32 → 0.9.6.2-i386-mingw32

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.
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ 27/9/2011 version 0.9.6.2 HOTFIX release
2
+ * downgrading to CodeRay 0.9.8 due to problems with 1.0 and rails (autoloading problem) see #280 on pry and #6 on CodeRay
3
+ * also added (as a minor feature) cirwin's implementation of edit --in
4
+ * added early break/exit for objectpath errors (the 'cd 34/@hello/bad_path/23')
5
+
1
6
  19/9/2011 version 0.9.6
2
7
  * restored previous behavior of command-line switches (allowing "-rfilename")
3
8
  * removed -p option (--play) from edit command
data/Rakefile CHANGED
@@ -21,11 +21,11 @@ def apply_spec_defaults(s)
21
21
  s.executables = ["pry"]
22
22
  s.files = `git ls-files`.split("\n")
23
23
  s.test_files = `git ls-files -- test/*`.split("\n")
24
- s.add_dependency("ruby_parser",">=2.0.5")
25
- s.add_dependency("coderay",">=0.9.8")
24
+ s.add_dependency("ruby_parser","~>2.0.5")
25
+ s.add_dependency("coderay","~>0.9.8")
26
26
  s.add_dependency("slop","~>2.1.0")
27
- s.add_dependency("method_source",">=0.6.5")
28
- s.add_development_dependency("bacon",">=1.1.0")
27
+ s.add_dependency("method_source","~>0.6.5")
28
+ s.add_development_dependency("bacon","~>1.1.0")
29
29
  s.add_development_dependency("open4", "~>1.0.1")
30
30
  s.add_development_dependency("rake", "~>0.9")
31
31
  end
@@ -70,7 +70,7 @@ end
70
70
  namespace :jruby do
71
71
  spec = Gem::Specification.new do |s|
72
72
  apply_spec_defaults(s)
73
- s.add_dependency("spoon", ">=0.0.1")
73
+ s.add_dependency("spoon", "~>0.0.1")
74
74
  s.platform = "java"
75
75
  end
76
76
 
@@ -85,7 +85,7 @@ end
85
85
  namespace v do
86
86
  spec = Gem::Specification.new do |s|
87
87
  apply_spec_defaults(s)
88
- s.add_dependency("win32console", ">=1.3.0")
88
+ s.add_dependency("win32console", "~>1.3.0")
89
89
  s.platform = "i386-#{v}"
90
90
  end
91
91
 
data/lib/pry.rb CHANGED
@@ -173,9 +173,6 @@ if RUBY_PLATFORM =~ /mswin/ || RUBY_PLATFORM =~ /mingw/
173
173
  end
174
174
 
175
175
  require "pry/version"
176
- require "pry/rbx_method"
177
- require "pry/rbx_path"
178
- require "pry/method"
179
176
  require "pry/history_array"
180
177
  require "pry/helpers"
181
178
  require "pry/history"
@@ -9,7 +9,6 @@ class Pry
9
9
  # give it a nice inspect
10
10
  def VOID_VALUE.inspect() "void" end
11
11
 
12
- attr_accessor :command_name
13
12
  attr_accessor :output
14
13
  attr_accessor :target
15
14
  attr_accessor :target_self
@@ -11,8 +11,6 @@ class Pry
11
11
  class Command < Struct.new(:name, :description, :options, :block)
12
12
 
13
13
  def call(context, *args)
14
- context.command_name = options[:listing]
15
-
16
14
  if stub_block = options[:stub_info]
17
15
  context.instance_eval(&stub_block)
18
16
  else
@@ -28,15 +28,17 @@ class Pry
28
28
  end
29
29
 
30
30
  command "reload-method", "Reload the source file that contains the specified method" do |meth_name|
31
- meth = get_method_or_print_error(meth_name, target, {}, :omit_help)
32
- next unless meth
31
+ if (meth = get_method_object(meth_name, target, {})).nil?
32
+ output.puts "Invalid method name: #{meth_name}."
33
+ next
34
+ end
33
35
 
34
- if meth.source_type == :c
36
+ if is_a_c_method?(meth)
35
37
  output.puts "Error: Can't reload a C method."
36
- elsif meth.dynamically_defined?
38
+ elsif is_a_dynamically_defined_method?(meth)
37
39
  output.puts "Error: Can't reload an eval method."
38
40
  else
39
- file_name = meth.source_file
41
+ file_name = meth.source_location.first
40
42
  load file_name
41
43
  output.puts "Reloaded #{file_name}."
42
44
  end
@@ -37,6 +37,7 @@ class Pry
37
37
  rescue RescuableException
38
38
  output.puts "Bad object path: #{arg_string}. Failed trying to resolve: #{context}"
39
39
  resolve_failure = true
40
+ break
40
41
  end
41
42
  end
42
43
 
@@ -136,11 +137,8 @@ class Pry
136
137
  i_num = 5
137
138
  end
138
139
 
139
- if (meth = Pry::Method.from_binding(target))
140
- meth_name = meth.name
141
- else
142
- meth_name = "N/A"
143
- end
140
+ meth_name = meth_name_from_binding(target)
141
+ meth_name = "N/A" if !meth_name
144
142
 
145
143
  if file =~ /(\(.*\))|<.*>/ || file == "" || file == "-e"
146
144
  output.puts "Cannot find local context. Did you use `binding.pry` ?"
@@ -32,15 +32,20 @@ class Pry
32
32
 
33
33
  args = [nil] if args.empty?
34
34
  args.each do |method_name|
35
- meth = get_method_or_print_error(method_name, target, opts.to_hash(true))
36
- next unless meth
35
+ meth_name = method_name
36
+ if (meth = get_method_object(meth_name, target, opts.to_hash(true))).nil?
37
+ output.puts "Invalid method name: #{meth_name}. Type `show-doc --help` for help"
38
+ next
39
+ end
37
40
 
38
- next output.puts("No documentation found.") if meth.doc.nil? || meth.doc.empty?
41
+ doc, code_type = doc_and_code_type_for(meth)
42
+ next if !doc
39
43
 
40
- doc = process_comment_markup(meth.doc, meth.source_type)
41
- output.puts make_header(meth, doc)
42
- output.puts "#{text.bold("visibility: ")} #{meth.visibility}"
43
- output.puts "#{text.bold("signature: ")} #{meth.signature}"
44
+ next output.puts("No documentation found.") if doc.empty?
45
+ doc = process_comment_markup(doc, code_type)
46
+ output.puts make_header(meth, code_type, doc)
47
+ output.puts "#{text.bold("visibility: ")} #{method_visibility(meth).to_s}"
48
+ output.puts "#{text.bold("signature: ")} #{signature_for(meth)}"
44
49
  output.puts
45
50
  render_output(opts.flood?, false, doc)
46
51
  doc
@@ -71,20 +76,26 @@ class Pry
71
76
 
72
77
  next if opts.help?
73
78
 
74
- meth = get_method_or_print_error(args.shift, target, opts.to_hash(true))
75
- next unless meth
76
-
77
- output.puts unindent <<-EOS
78
- Method Information:
79
- --
80
- Name: #{meth.name}
81
- Owner: #{meth.owner ? meth.owner : "Unknown"}
82
- Visibility: #{meth.visibility}
83
- Type: #{meth.is_a?(Method) ? "Bound" : "Unbound"}
84
- Arity: #{meth.arity}
85
- Method Signature: #{meth.signature}
86
- Source Location: #{meth.source_location ? meth.source_location.join(":") : "Not found."}
87
- EOS
79
+ meth_name = args.shift
80
+ if (meth = get_method_object(meth_name, target, opts.to_hash(true))).nil?
81
+ output.puts "Invalid method name: #{meth_name}. Type `stat --help` for help"
82
+ next
83
+ end
84
+
85
+ if !is_a_c_method?(meth) && !is_a_dynamically_defined_method?(meth)
86
+ set_file_and_dir_locals(path_line_for(meth).first)
87
+ end
88
+
89
+ output.puts "Method Information:"
90
+ output.puts "--"
91
+ output.puts "Name: " + meth_name
92
+ output.puts "Owner: " + (meth.owner.to_s ? meth.owner.to_s : "Unknown")
93
+ output.puts "Visibility: " + method_visibility(meth).to_s
94
+ output.puts "Type: " + (meth.is_a?(Method) ? "Bound" : "Unbound")
95
+ output.puts "Arity: " + meth.arity.to_s
96
+ output.puts "Method Signature: " + signature_for(meth)
97
+
98
+ output.puts "Source location: " + (meth.source_location ? meth.source_location.join(":") : "Not found.")
88
99
  end
89
100
 
90
101
  command "gist-method", "Gist a method to github. Type `gist-method --help` for more info.", :requires_gem => "gist" do |*args|
@@ -111,17 +122,19 @@ class Pry
111
122
 
112
123
  next if opts.help?
113
124
 
114
- meth = get_method_or_print_error(args.shift, target, opts.to_hash(true))
115
- next unless meth
125
+ # This needs to be extracted into its own method as it's shared
126
+ # by show-method and show-doc and stat commands
127
+ meth_name = args.shift
128
+ if (meth = get_method_object(meth_name, target, opts.to_hash(true))).nil?
129
+ output.puts "Invalid method name: #{meth_name}. Type `gist-method --help` for help"
130
+ next
131
+ end
116
132
 
117
133
  type_map = { :ruby => "rb", :c => "c", :plain => "plain" }
118
134
  if !opts.doc?
119
- content = meth.source
120
- code_type = meth.source_type
135
+ content, code_type = code_and_code_type_for(meth)
121
136
  else
122
- content = meth.doc
123
- code_type = meth.source_type
124
-
137
+ content, code_type = doc_and_code_type_for(meth)
125
138
  text.no_color do
126
139
  content = process_comment_markup(content, code_type)
127
140
  end
@@ -134,6 +147,44 @@ class Pry
134
147
 
135
148
  output.puts "Gist created at #{link}"
136
149
  end
150
+
151
+ helpers do
152
+
153
+ # paraphrased from awesome_print gem
154
+ def signature_for(method)
155
+ if method.respond_to?(:parameters)
156
+
157
+ args = method.parameters.inject([]) do |arr, (type, name)|
158
+ name ||= (type == :block ? 'block' : "arg#{arr.size + 1}")
159
+ arr << case type
160
+ when :req then name.to_s
161
+ when :opt, :rest then "*#{name}"
162
+ when :block then "&#{name}"
163
+ else '?'
164
+ end
165
+ end
166
+ else
167
+ args = (1..method.arity.abs).map { |i| "arg#{i}" }
168
+ args[-1] = "*#{args[-1]}" if method.arity < 0
169
+ end
170
+
171
+ "#{method.name}(#{args.join(', ')})"
172
+ end
173
+
174
+ def method_visibility(meth)
175
+ if meth.owner.public_instance_methods.include? meth.name
176
+ :public
177
+ elsif meth.owner.protected_instance_methods.include? meth.name
178
+ :protected
179
+ elsif meth.owner.private_instance_methods.include? meth.name
180
+ :private
181
+ else
182
+ :none
183
+ end
184
+ end
185
+ end
186
+
137
187
  end
188
+
138
189
  end
139
190
  end
@@ -77,13 +77,17 @@ class Pry
77
77
 
78
78
  if opts.m?
79
79
  meth_name = opts[:m]
80
- meth = get_method_or_print_error(meth_name, target, {}, :omit_help)
81
- next unless meth and meth.source
80
+ if (meth = get_method_object(meth_name, target, {})).nil?
81
+ output.puts "Invalid method name: #{meth_name}."
82
+ next
83
+ end
84
+ code, _ = code_and_code_type_for(meth)
85
+ next if !code
82
86
 
83
87
  range = opts.l? ? one_index_range_or_number(opts[:l]) : (0..-1)
84
88
  range = (0..-2) if opts.o?
85
89
 
86
- eval_string << Array(meth.source.each_line.to_a[range]).join
90
+ eval_string << Array(code.each_line.to_a[range]).join
87
91
  elsif opts.f?
88
92
  file_name = File.expand_path(opts[:f])
89
93
  next output.puts "No such file: #{opts[:f]}" if !File.exists?(file_name)
@@ -28,28 +28,33 @@ class Pry
28
28
  output.puts opt
29
29
  end
30
30
  end
31
+
31
32
  next if opts.help?
32
- opts[:instance] = opts['instance-methods'] if opts.m?
33
33
 
34
34
  args = [nil] if args.empty?
35
35
  args.each do |method_name|
36
- meth = get_method_or_print_error(method_name, target, opts.to_hash(true))
37
- next unless meth and meth.source
36
+ meth_name = method_name
37
+ if (meth = get_method_object(meth_name, target, opts.to_hash(true))).nil?
38
+ output.puts "Invalid method name: #{meth_name}. Type `show-method --help` for help"
39
+ next
40
+ end
41
+
42
+ code, code_type = code_and_code_type_for(meth)
43
+ next if !code
38
44
 
39
- output.puts make_header(meth)
45
+ output.puts make_header(meth, code_type, code)
40
46
  if Pry.color
41
- code = CodeRay.scan(meth.source, meth.source_type).term
42
- else
43
- code = meth.source
47
+ code = CodeRay.scan(code, code_type).term
44
48
  end
45
49
 
46
50
  start_line = false
47
- if opts.b?
48
- start_line = 1
49
- elsif opts.l?
50
- start_line = meth.source_line || 1
51
+ if opts.l?
52
+ start_line = meth.source_location ? meth.source_location.last : 1
51
53
  end
52
54
 
55
+ start_line = opts.b? ? 1 : start_line
56
+
57
+
53
58
  render_output(opts.flood?, start_line, code)
54
59
  code
55
60
  end
@@ -84,25 +89,23 @@ class Pry
84
89
  end
85
90
 
86
91
  if find_command(command_name)
87
- block = Pry::Method.new(find_command(command_name).block)
92
+ block = find_command(command_name).block
88
93
 
89
- next unless block.source
90
- set_file_and_dir_locals(block.source_file)
94
+ code, _ = code_and_code_type_for(block)
95
+ next if !code
91
96
 
92
- output.puts make_header(block)
97
+ output.puts make_header(block, :ruby, code)
93
98
 
94
99
  if Pry.color
95
- code = CodeRay.scan(block.source, :ruby).term
96
- else
97
- code = block.source
100
+ code = CodeRay.scan(code, :ruby).term
98
101
  end
99
102
 
100
103
  start_line = false
101
104
  if opts.l?
102
- start_line = block.source_line || 1
105
+ start_line = block.source_location ? block.source_location.last : 1
103
106
  end
104
107
 
105
- render_output(opts.flood?, opts.l? ? block.source_line : false, code)
108
+ render_output(opts.flood?, opts.l? ? block.source_location.last : false, code)
106
109
  code
107
110
  else
108
111
  output.puts "No such command: #{command_name}."
@@ -119,7 +122,7 @@ class Pry
119
122
  USAGE
120
123
 
121
124
  opt.on :e, :ex, "Open the file that raised the most recent exception (_ex_.file)", :optional => true, :as => Integer
122
- opt.on :i, :in, "Open a temporary file containing the specified line of _in_.", :optional => true, :as => Integer
125
+ opt.on :i, :in, "Open a temporary file containing the Nth line of _in_. N may be a range.", :optional => true, :as => Range, :default => -1..-1
123
126
  opt.on :t, :temp, "Open an empty temporary file"
124
127
  opt.on :l, :line, "Jump to this line in the opened file", true, :as => Integer
125
128
  opt.on :n, :"no-reload", "Don't automatically reload the edited code"
@@ -130,8 +133,8 @@ class Pry
130
133
  end
131
134
  next if opts.h?
132
135
 
133
- if [opts.ex? || nil, opts.t? || nil, !args.empty? || nil].compact.size > 1
134
- next output.puts "Only one of --ex, --temp, and FILE may be specified"
136
+ if [opts.ex?, opts.t?, opts.in?, !args.empty?].count(true) > 1
137
+ next output.puts "Only one of --ex, --temp, --in and FILE may be specified"
135
138
  end
136
139
 
137
140
  # edit of local code, eval'd within pry.
@@ -140,7 +143,14 @@ class Pry
140
143
  content = if opts.t?
141
144
  ""
142
145
  elsif opts.i?
143
- _pry_.input_array[opts[:i] || -1] || ""
146
+ case opts[:i]
147
+ when Range
148
+ (_pry_.input_array[opts[:i]] || []).join
149
+ when Fixnum
150
+ _pry_.input_array[opts[:i]] || ""
151
+ else
152
+ next output.puts "Not a valid range: #{opts[:i]}"
153
+ end
144
154
  elsif eval_string.strip != ""
145
155
  eval_string
146
156
  else
@@ -168,8 +178,8 @@ class Pry
168
178
  bt_index = opts[:ex].to_i
169
179
 
170
180
  ex_file, ex_line = ex.bt_source_location_for(bt_index)
171
- if ex_file && RbxPath.is_core_path?(ex_file)
172
- file_name = RbxPath.convert_path_to_full(ex_file)
181
+ if ex_file && is_core_rbx_path?(ex_file)
182
+ file_name = rbx_convert_path_to_full(ex_file)
173
183
  else
174
184
  file_name = ex_file
175
185
  end
@@ -221,6 +231,7 @@ class Pry
221
231
  output.puts opt
222
232
  end
223
233
  end
234
+
224
235
  next if opts.help?
225
236
 
226
237
  if !Pry.config.editor
@@ -229,14 +240,21 @@ class Pry
229
240
  next
230
241
  end
231
242
 
232
- meth = get_method_or_print_error(args.shift, target, opts.to_hash(true))
233
- next unless meth
243
+ meth_name = args.shift
244
+ meth_name, target, type = get_method_attributes(meth_name, target, opts.to_hash(true))
245
+ meth = get_method_object_from_target(meth_name, target, type)
246
+
247
+ if meth.nil?
248
+ output.puts "Invalid method name: #{meth_name}."
249
+ next
250
+ end
234
251
 
235
- if opts.p? || meth.dynamically_defined?
236
- lines = meth.source.lines.to_a
252
+ if opts.p? || is_a_dynamically_defined_method?(meth)
253
+ code, _ = code_and_code_type_for(meth)
237
254
 
255
+ lines = code.lines.to_a
238
256
  if lines[0] =~ /^def [^( \n]+/
239
- lines[0] = "def #{meth.name}#{$'}"
257
+ lines[0] = "def #{meth_name}#{$'}"
240
258
  else
241
259
  next output.puts "Error: Pry can only patch methods created with the `def` keyword."
242
260
  end
@@ -250,10 +268,11 @@ class Pry
250
268
  next
251
269
  end
252
270
 
253
- if meth.source_type == :c
271
+ if is_a_c_method?(meth)
254
272
  output.puts "Error: Can't edit a C method."
255
273
  else
256
- file, line = meth.source_file, meth.source_line
274
+ file, line = path_line_for(meth)
275
+ set_file_and_dir_locals(file)
257
276
 
258
277
  invoke_editor(file, opts["no-jump"] ? 0 : line)
259
278
  silence_warnings do