show 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README ADDED
File without changes
@@ -0,0 +1,11 @@
1
+ require 'jeweler'
2
+ Jeweler::Tasks.new do |s|
3
+ s.name = "show"
4
+ s.summary = "ruby tool for quick debug print statements, like: show(a, b) (prints out '[spec.analyze.rb,9]: a=3, b=3')"
5
+ s.email = "rogerdpack@gmail.com"
6
+ s.homepage = "http://github.com/rdp/show"
7
+ s.authors = ["Roger Pack"]
8
+ s.add_development_dependency 'rspec'
9
+ s.add_development_dependency 'sane'
10
+ s.add_dependency 'redparse'
11
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.2.1
@@ -0,0 +1,51 @@
1
+ require 'stringio' # fix sequence bug, I think
2
+ require 'redparse' # takes forever on doze [ltodo]
3
+
4
+ class Object
5
+ def display *args
6
+ a = caller
7
+ last_caller = a[0]
8
+ if last_caller[1..1] == ":"
9
+ # could be like E:/dev/ruby/sane/spec/../lib/sane/require_relative.rb:9:in `require_relative'
10
+ drive, file, line, *rest = last_caller.split(":")
11
+ else
12
+ # or like
13
+ # "spec.analyze:9"
14
+ file, line, *rest = last_caller.split(":")
15
+ end
16
+
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}"
33
+ }.join(', ')
34
+
35
+ out += args2
36
+ puts out
37
+ out
38
+ end
39
+
40
+ def give_me_first_call_node tree
41
+ tree.walk{|parent,i,subi,node|
42
+ if node.class == RedParse::CallNode
43
+ # eureka
44
+ return tree
45
+ else
46
+ return give_me_first_call_node(node.right)
47
+ end
48
+ }
49
+ end
50
+
51
+ end
@@ -0,0 +1 @@
1
+ display 3
@@ -0,0 +1,66 @@
1
+ require 'rubygems'
2
+ require 'sane'
3
+ require_relative '../lib/analyze'
4
+ require 'spec/autorun'
5
+
6
+ describe "analyze" do
7
+
8
+ before do
9
+ a = 3
10
+ b=4
11
+ @output = analyze a, b
12
+ end
13
+
14
+ it "should analyze the args" do
15
+ assert @output.contain?( "a=")
16
+ assert @output.contain?( "b=")
17
+ end
18
+
19
+ it "should have an [] style output" do
20
+ assert @output =~ /\[.*\]/
21
+ end
22
+
23
+ it "should add spacing appropriately with commas" do
24
+ assert @output.contain?(", ")
25
+ end
26
+
27
+ it "should show linenumber too" do
28
+ assert @output.contain?(",11")
29
+ end
30
+
31
+ it "should retrieve call nodes for ya" do
32
+ for string in ["c = analyze a, b", "analyze a, b"] do
33
+ parser=RedParse.new(string)
34
+ tree = parser.parse
35
+ node = give_me_first_call_node tree
36
+ assert node.class == RedParse::CallNode
37
+ assert node.params.length == 2
38
+ end
39
+ end
40
+
41
+ it "shouldn't barf with more complex things" do
42
+ output = analyze 3, 4+5
43
+ end
44
+
45
+ it "should work with longer dir names in 1.8" do
46
+ require 'sub/go2'
47
+ end
48
+
49
+ it "should cache lines instead of rereading the file every time"
50
+
51
+ it "should use inspect" do
52
+ a = [1,2,3]
53
+ out = analyze a
54
+ assert out.contain? "[1, 2, 3]"
55
+ out = analyze [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("analyze 1,2,3")
61
+ assert(out.contain?('?='))
62
+ assert(out.contain?('eval'))
63
+ assert(out.contain?('1'))
64
+ end
65
+
66
+ end
@@ -0,0 +1 @@
1
+ require 'go.rb'
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: show
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.1
5
+ platform: ruby
6
+ authors:
7
+ - Roger Pack
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-01-19 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rspec
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: sane
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: redparse
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ description:
46
+ email: rogerdpack@gmail.com
47
+ executables: []
48
+
49
+ extensions: []
50
+
51
+ extra_rdoc_files:
52
+ - README
53
+ files:
54
+ - README
55
+ - Rakefile
56
+ - VERSION
57
+ - lib/analyze.rb
58
+ - spec/go.rb
59
+ - spec/spec.analyze.rb
60
+ - spec/sub/go2.rb
61
+ has_rdoc: true
62
+ homepage: http://github.com/rdp/show
63
+ licenses: []
64
+
65
+ post_install_message:
66
+ rdoc_options:
67
+ - --charset=UTF-8
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: "0"
75
+ version:
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: "0"
81
+ version:
82
+ requirements: []
83
+
84
+ rubyforge_project:
85
+ rubygems_version: 1.3.5
86
+ signing_key:
87
+ specification_version: 3
88
+ summary: "ruby tool for quick debug print statements, like: show(a, b) (prints out '[spec.analyze.rb,9]: a=3, b=3')"
89
+ test_files:
90
+ - spec/go.rb
91
+ - spec/spec.analyze.rb
92
+ - spec/sub/go2.rb