display 0.2.0 → 0.2.1

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 (4) hide show
  1. data/VERSION +1 -1
  2. data/lib/display.rb +17 -10
  3. data/spec/spec.display.rb +15 -0
  4. metadata +1 -1
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -14,18 +14,25 @@ class Object
14
14
  file, line, *rest = last_caller.split(":")
15
15
  end
16
16
 
17
- exact_line = File.readlines(file)[line.to_i - 1].strip
18
- parser = RedParse.new(exact_line)
19
- tree = parser.parse
20
- out = nil
21
- # the trick is to break out with the first method call...
22
- right_call_node = give_me_first_call_node tree
23
- out = "[#{File.basename(file)},#{line}] "
24
- args2 = right_call_node.params.map{ |p|
25
- "#{p.unparse}=#{args.shift}"
17
+ if(file.include?('eval'))
18
+ out = '[eval] '
19
+ names = args.map{|a| '?'}
20
+ else
21
+ exact_line = File.readlines(file)[line.to_i - 1].strip
22
+ parser = RedParse.new(exact_line)
23
+ tree = parser.parse
24
+ # the trick is to break out with the first method call...
25
+ right_call_node = give_me_first_call_node tree
26
+ names = right_call_node.params.map{|p| p.unparse}
27
+ out = "[#{File.basename(file)},#{line}] "
28
+ end
29
+
30
+
31
+ args2 = names.map{ |n|
32
+ "#{n}=#{args.shift.inspect}"
26
33
  }.join(', ')
27
- out += args2
28
34
 
35
+ out += args2
29
36
  puts out
30
37
  out
31
38
  end
@@ -47,5 +47,20 @@ describe "display" do
47
47
  end
48
48
 
49
49
  it "should cache lines instead of rereading the file each time"
50
+
51
+ it "should use inspect" do
52
+ a = [1,2,3]
53
+ out = display a
54
+ assert out.contain? "[1, 2, 3]"
55
+ out = display [1,2,3]
56
+ assert out.contain? "[1, 2, 3]"
57
+ end
58
+
59
+ it "should pretend to work in eval" do
60
+ out = eval("display 1,2,3")
61
+ assert(out.contain?('?='))
62
+ assert(out.contain?('eval'))
63
+ assert(out.contain?('1'))
64
+ end
50
65
 
51
66
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: display
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roger Pack