pry 0.5.7 → 0.5.8

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ 22/2/2010 version 0.5.8
2
+ * Added -c (context) option to show-doc, show-methods and eval-file
3
+ * Fixed up ordering issue of -c and -r parameters to command line pry
4
+
1
5
  21/2/2010 version 0.5.7
2
6
  * Added pry executable, auto-loads .pryrc in user's home directory, if it
3
7
  exists.
data/bin/pry CHANGED
@@ -9,11 +9,11 @@ rescue LoadError
9
9
  require 'rubygems'
10
10
  require 'pry'
11
11
  end
12
- require "optparse"
12
+ require 'optparse'
13
13
 
14
14
  # defaults
15
15
  options = {
16
- :context => TOPLEVEL_BINDING,
16
+ :context_string => "TOPLEVEL_BINDING",
17
17
  :loadrc => true
18
18
  }
19
19
 
@@ -42,22 +42,30 @@ See: `https://github.com/banister` for more information.
42
42
 
43
43
  opts.on("-c", "--context CONTEXT",
44
44
  "Start the session in the specified context. Equivalent to `context.pry` in a session.") do |context|
45
- options[:context] = Pry.binding_for(eval(context))
45
+
46
+ # save the context name
47
+ options[:context_string] = context
46
48
  end
47
49
 
48
50
  opts.on_tail("-h", "--help", "This message.") do
49
51
  puts opts
50
52
  exit
51
53
  end
52
- end.parse!
54
+ end.permute!
53
55
 
54
56
  rcpath = File.expand_path("~/.pryrc")
55
57
 
56
58
  # load ~/.pryrc, if not suppressed with -f option
57
59
  load rcpath if File.exists?(rcpath) && options[:loadrc]
58
60
 
61
+ # create the actual context
62
+ context = Pry.binding_for(eval(options[:context_string]))
63
+
59
64
  # execute line of code, if provided with -e option
60
- options[:context].eval(options[:code]) if options[:code]
65
+ if options[:code]
66
+ result = context.eval(options[:code])
67
+ puts "=> #{Pry.view(result)}"
68
+ end
61
69
 
62
70
  # start the session
63
- options[:context].pry
71
+ context.pry
@@ -237,16 +237,18 @@ Shows local and instance variables by default.
237
237
 
238
238
  command "eval-file", "Eval a Ruby script. Type `eval-file --help` for more info." do |*args|
239
239
  options = {}
240
+ target = target()
240
241
  file_name = nil
241
242
 
242
243
  OptionParser.new do |opts|
243
244
  opts.banner = %{Usage: eval-file [OPTIONS] FILE
244
- Eval a Ruby script at top-level or in the current context. Defaults to top-level.
245
- e.g: eval-file -c "hello.rb"
245
+ Eval a Ruby script at top-level or in the specified context. Defaults to top-level.
246
+ e.g: eval-file -c self "hello.rb"
246
247
  --
247
248
  }
248
- opts.on("-c", "--context", "Eval the script in the current context.") do
249
+ opts.on("-c", "--context CONTEXT", "Eval the script in the specified context.") do |context|
249
250
  options[:c] = true
251
+ target = Pry.binding_for(target.eval(context))
250
252
  end
251
253
 
252
254
  opts.on_tail("-h", "--help", "This message.") do
@@ -266,8 +268,9 @@ e.g: eval-file -c "hello.rb"
266
268
 
267
269
  old_constants = Object.constants
268
270
  if options[:c]
271
+ target_self = target.eval('self')
269
272
  target.eval(File.read(file_name))
270
- output.puts "--\nEval'd '#{file_name}' in the current context."
273
+ output.puts "--\nEval'd '#{file_name}' in the `#{target_self}` context."
271
274
  else
272
275
  TOPLEVEL_BINDING.eval(File.read(file_name))
273
276
  output.puts "--\nEval'd '#{file_name}' at top-level."
@@ -299,6 +302,7 @@ e.g: eval-file -c "hello.rb"
299
302
 
300
303
  command "show-doc", "Show the comments above METH. Type `show-doc --help` for more info." do |*args|
301
304
  options = {}
305
+ target = target()
302
306
  meth_name = nil
303
307
 
304
308
  OptionParser.new do |opts|
@@ -311,6 +315,10 @@ e.g show-doc hello_method
311
315
  options[:M] = true
312
316
  end
313
317
 
318
+ opts.on("-c", "--context CONTEXT", "Select object context to run under.") do |context|
319
+ target = Pry.binding_for(target.eval(context))
320
+ end
321
+
314
322
  opts.on_tail("-h", "--help", "This message.") do
315
323
  output.puts opts
316
324
  options[:h] = true
@@ -348,6 +356,7 @@ e.g show-doc hello_method
348
356
 
349
357
  command "show-method", "Show the source for METH. Type `show-method --help` for more info." do |*args|
350
358
  options = {}
359
+ target = target()
351
360
  meth_name = nil
352
361
 
353
362
  OptionParser.new do |opts|
@@ -360,6 +369,10 @@ e.g: show-method hello_method
360
369
  options[:M] = true
361
370
  end
362
371
 
372
+ opts.on("-c", "--context CONTEXT", "Select object context to run under.") do |context|
373
+ target = Pry.binding_for(target.eval(context))
374
+ end
375
+
363
376
  opts.on_tail("-h", "--help", "This message.") do
364
377
  output.puts opts
365
378
  options[:h] = true
@@ -1,3 +1,3 @@
1
1
  class Pry
2
- VERSION = "0.5.7"
2
+ VERSION = "0.5.8"
3
3
  end
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.5.7
4
+ version: 0.5.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: ruby_parser
17
- requirement: &17058996 !ruby/object:Gem::Requirement
17
+ requirement: &16960692 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 2.0.5
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *17058996
25
+ version_requirements: *16960692
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: method_source
28
- requirement: &17003496 !ruby/object:Gem::Requirement
28
+ requirement: &16905192 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 0.2.0
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *17003496
36
+ version_requirements: *16905192
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: bacon
39
- requirement: &17003220 !ruby/object:Gem::Requirement
39
+ requirement: &16904916 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,7 +44,7 @@ dependencies:
44
44
  version: 1.1.0
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *17003220
47
+ version_requirements: *16904916
48
48
  description: attach an irb-like session to any object at runtime
49
49
  email: jrmair@gmail.com
50
50
  executables: