simple-tracer 0.2

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.
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in simple-tracer.gemspec
4
+ gemspec
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/st ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+
4
+ if ARGV[0]
5
+ system("ruby -rsimple-tracer #{ARGV.join(' ')}")
6
+ else
7
+ puts "Usage: st [script.rb]"
8
+ end
9
+
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'term/ansicolor'
4
+
5
+ class String
6
+ include Term::ANSIColor
7
+ end
8
+
9
+ module Tracer
10
+ count = 0
11
+ depth = 0
12
+
13
+ space = "| ".magenta
14
+ set_trace_func proc { |event, file, line, id, binding, classname|
15
+
16
+ case event
17
+ when "call"
18
+ # puts "CALL"
19
+ arg_names = eval("method(__method__).parameters.map { |arg| arg[1].to_s }",binding)
20
+ args = eval("#{arg_names}.map { |arg| eval(arg) }",binding).join(', ')
21
+ puts space * (depth * 2) + "====> ".green.bold + classname.to_s + "." + id.to_s.bold + "(#{args})"
22
+ puts space * (depth * 2) + " > " + "#{file.split('/').last}:#{line}".blue + " args: (#{arg_names.join(', ')})".blue
23
+ depth += 1
24
+ when "return"
25
+ # puts "RET"
26
+ depth -= 1 if depth > 0
27
+ puts space * (depth * 2) + "<==== ".red.bold + classname.to_s + "." + id.to_s.bold
28
+ end
29
+ }
30
+ end
@@ -0,0 +1,3 @@
1
+ module Tracer
2
+ VERSION = "0.2"
3
+ end
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "simple-tracer/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "simple-tracer"
7
+ s.version = Tracer::VERSION
8
+ s.authors = ["matugm"]
9
+ s.email = ["matugm@gmail.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{Simple tracer tool}
12
+ s.description = %q{Traces method calls using set_tracer_func,
13
+ and prints them in a nice way}
14
+
15
+ s.rubyforge_project = "simple-tracer"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = ["st"]
20
+ s.require_paths = ["lib"]
21
+
22
+ # specify any dependencies here; for example:
23
+ # s.add_development_dependency "rspec"
24
+ # s.add_runtime_dependency "rest-client"
25
+ end
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'term/ansicolor'
4
+
5
+ class String
6
+ include Term::ANSIColor
7
+ end
8
+
9
+ module Tracer
10
+ count = 0
11
+ depth = 0
12
+
13
+ space = "| ".magenta
14
+ set_trace_func proc { |event, file, line, id, binding, classname|
15
+
16
+ case event
17
+ when "call"
18
+ # puts "CALL"
19
+ arg_names = eval("method(__method__).parameters.map { |arg| arg[1].to_s }",binding)
20
+ args = eval("#{arg_names}.map { |arg| eval(arg) }",binding).join(', ')
21
+ puts space * (depth * 2) + "====> ".green.bold + classname.to_s + "." + id.to_s.bold + "(#{args})"
22
+ puts space * (depth * 2) + " > " + "#{file.split('/').last}:#{line}".blue + " args: (#{arg_names.join(', ')})".blue
23
+ depth += 1
24
+ when "return"
25
+ # puts "RET"
26
+ depth -= 1 if depth > 0
27
+ puts space * (depth * 2) + "<==== ".red.bold + classname.to_s + "." + id.to_s.bold
28
+ end
29
+ }
30
+ end
metadata ADDED
@@ -0,0 +1,56 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simple-tracer
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.2'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - matugm
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-06-01 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: ! "Traces method calls using set_tracer_func,\n\tand prints them in a
15
+ nice way"
16
+ email:
17
+ - matugm@gmail.com
18
+ executables:
19
+ - st
20
+ extensions: []
21
+ extra_rdoc_files: []
22
+ files:
23
+ - .gitignore
24
+ - Gemfile
25
+ - Rakefile
26
+ - lib/simple-tracer.rb
27
+ - lib/simple-tracer/version.rb
28
+ - simple-tracer.gemspec
29
+ - tracer.rb
30
+ - bin/st
31
+ homepage: ''
32
+ licenses: []
33
+ post_install_message:
34
+ rdoc_options: []
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ! '>='
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ requirements: []
50
+ rubyforge_project: simple-tracer
51
+ rubygems_version: 1.8.15
52
+ signing_key:
53
+ specification_version: 3
54
+ summary: Simple tracer tool
55
+ test_files: []
56
+ has_rdoc: