traceur 0.0.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.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.md +52 -0
- data/Rakefile +1 -0
- data/lib/traceur/traceur.rb +103 -0
- data/lib/traceur/version.rb +3 -0
- data/lib/traceur.rb +1 -0
- data/traceur.gemspec +24 -0
- metadata +53 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
Traceur
|
2
|
+
==========
|
3
|
+
|
4
|
+
An experiment to have some fun with SVG and learn a little more
|
5
|
+
about Ruby.
|
6
|
+
If you want to get a visual for what is going on in your code you can
|
7
|
+
pass in a regular expression like ".+" or "downthetube".
|
8
|
+
Be specific otherwise you will end up with an SVG file so big
|
9
|
+
that no program can open it.
|
10
|
+
|
11
|
+
Usage:
|
12
|
+
------
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
require 'rubygems'
|
16
|
+
require 'traceur'
|
17
|
+
require 'downthetube'
|
18
|
+
|
19
|
+
Traceur.watch_paths("downthetube", ".")
|
20
|
+
|
21
|
+
playlists = Youtube.playlists_for "stephensam"
|
22
|
+
videos = playlists.last.videos
|
23
|
+
puts videos.last.title
|
24
|
+
|
25
|
+
Traceur.stop
|
26
|
+
```
|
27
|
+
|
28
|
+
|
29
|
+
LICENSE:
|
30
|
+
|
31
|
+
(The MIT License)
|
32
|
+
|
33
|
+
Copyright © 2011 Mike Williamson
|
34
|
+
|
35
|
+
|
36
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
37
|
+
this software and associated documentation files (the ‘Software’), to deal in
|
38
|
+
the Software without restriction, including without limitation the rights to
|
39
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
40
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
41
|
+
so, subject to the following conditions:
|
42
|
+
|
43
|
+
The above copyright notice and this permission notice shall be included in all
|
44
|
+
copies or substantial portions of the Software.
|
45
|
+
|
46
|
+
THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
47
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
48
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
49
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
50
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
51
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
52
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,103 @@
|
|
1
|
+
class Traceur
|
2
|
+
##
|
3
|
+
# The traceur class provides methods to trace the execution
|
4
|
+
# of the Ruby interpreter and writes an SVG file into the
|
5
|
+
# directory you choose.
|
6
|
+
#
|
7
|
+
@start_time = nil
|
8
|
+
@svg_file = nil
|
9
|
+
@trace_points = []
|
10
|
+
@x = 0
|
11
|
+
@y = 0
|
12
|
+
@footer = <<-EOSVG
|
13
|
+
" style="fill:none;stroke:black;stroke-width:3" />
|
14
|
+
</g>
|
15
|
+
</svg>
|
16
|
+
EOSVG
|
17
|
+
@header = <<-EOXML
|
18
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
19
|
+
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
20
|
+
|
21
|
+
<svg
|
22
|
+
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
23
|
+
xmlns:cc="http://creativecommons.org/ns#"
|
24
|
+
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
25
|
+
xmlns:svg="http://www.w3.org/2000/svg"
|
26
|
+
xmlns="http://www.w3.org/2000/svg"
|
27
|
+
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
28
|
+
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
29
|
+
id="svg2"
|
30
|
+
version="1.1"
|
31
|
+
inkscape:version="0.48.2 r9819"
|
32
|
+
sodipodi:docname="drawing.svg">
|
33
|
+
<defs
|
34
|
+
id="defs4" />
|
35
|
+
<sodipodi:namedview
|
36
|
+
id="base"
|
37
|
+
pagecolor="#ffffff"
|
38
|
+
bordercolor="#666666"
|
39
|
+
borderopacity="1.0"
|
40
|
+
inkscape:pageopacity="0.0"
|
41
|
+
inkscape:pageshadow="2"
|
42
|
+
inkscape:zoom="0.35"
|
43
|
+
inkscape:cx="375"
|
44
|
+
inkscape:cy="520"
|
45
|
+
inkscape:document-units="px"
|
46
|
+
inkscape:current-layer="layer1"
|
47
|
+
showgrid="false"
|
48
|
+
inkscape:window-width="1440"
|
49
|
+
inkscape:window-height="876"
|
50
|
+
inkscape:window-x="0"
|
51
|
+
inkscape:window-y="24"
|
52
|
+
inkscape:window-maximized="1" />
|
53
|
+
<metadata
|
54
|
+
id="metadata7">
|
55
|
+
<rdf:RDF>
|
56
|
+
<cc:Work
|
57
|
+
rdf:about="">
|
58
|
+
<dc:format>image/svg+xml</dc:format>
|
59
|
+
<dc:type
|
60
|
+
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
61
|
+
<dc:title></dc:title>
|
62
|
+
</cc:Work>
|
63
|
+
</rdf:RDF>
|
64
|
+
</metadata>
|
65
|
+
<g inkscape:label="Layer 1"
|
66
|
+
inkscape:groupmode="layer"
|
67
|
+
id="layer1"><polyline points="0,0
|
68
|
+
EOXML
|
69
|
+
|
70
|
+
def self.watch_paths(expr, output_dir)
|
71
|
+
|
72
|
+
raise SystemCallError "Directory does not exist" unless Dir.exists?(output_dir)
|
73
|
+
|
74
|
+
@svg_file = File.open(File.join(output_dir, "trace.svg"), 'w+')
|
75
|
+
@svg_file.write(@header)
|
76
|
+
expression = Regexp.new expr
|
77
|
+
proc = Proc.new do |event, file, line, id, binding, classname|
|
78
|
+
if expression.match file
|
79
|
+
@start_time ||= Time.now.strftime("%s.%L").to_f
|
80
|
+
@x += 1 unless ((@start_time - Time.now.strftime("%s.%L").to_f).abs <= 0.1)
|
81
|
+
if event.to_s == "call"
|
82
|
+
@svg_file.write " #{@x},#{@y}"
|
83
|
+
@y += 10
|
84
|
+
@svg_file.write " #{@x},#{@y}"
|
85
|
+
elsif event.to_s == "return"
|
86
|
+
@svg_file.write " #{@x},#{@y}"
|
87
|
+
@y -= 10
|
88
|
+
@svg_file.write " #{@x},#{@y}"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
Object.send(:set_trace_func, proc)
|
93
|
+
end
|
94
|
+
|
95
|
+
def self.stop
|
96
|
+
Object.send(:set_trace_func, nil)
|
97
|
+
|
98
|
+
@svg_file.write(@footer)
|
99
|
+
|
100
|
+
@svg_file.close
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
data/lib/traceur.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'traceur/traceur'
|
data/traceur.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "traceur/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "traceur"
|
7
|
+
s.version = Traceur::VERSION
|
8
|
+
s.authors = ["Mike Williamson"]
|
9
|
+
s.email = ["blessedbyvirtuosity@gmail.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{ Tracing method calls with SVG }
|
12
|
+
s.description = %q{ An experimental library to trace method calls using SVG }
|
13
|
+
|
14
|
+
s.rubyforge_project = "traceur"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# specify any dependencies here; for example:
|
22
|
+
# s.add_development_dependency "rspec"
|
23
|
+
# s.add_runtime_dependency "rest-client"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: traceur
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Mike Williamson
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-12-14 00:00:00.000000000Z
|
13
|
+
dependencies: []
|
14
|
+
description: ! ' An experimental library to trace method calls using SVG '
|
15
|
+
email:
|
16
|
+
- blessedbyvirtuosity@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- .gitignore
|
22
|
+
- Gemfile
|
23
|
+
- README.md
|
24
|
+
- Rakefile
|
25
|
+
- lib/traceur.rb
|
26
|
+
- lib/traceur/traceur.rb
|
27
|
+
- lib/traceur/version.rb
|
28
|
+
- traceur.gemspec
|
29
|
+
homepage: ''
|
30
|
+
licenses: []
|
31
|
+
post_install_message:
|
32
|
+
rdoc_options: []
|
33
|
+
require_paths:
|
34
|
+
- lib
|
35
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
36
|
+
none: false
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
requirements: []
|
48
|
+
rubyforge_project: traceur
|
49
|
+
rubygems_version: 1.8.10
|
50
|
+
signing_key:
|
51
|
+
specification_version: 3
|
52
|
+
summary: Tracing method calls with SVG
|
53
|
+
test_files: []
|