source_route 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +45 -1
- data/lib/source_route.rb +1 -0
- data/lib/source_route/formats/html_template.slim +4 -3
- data/lib/source_route/tp_result.rb +14 -2
- data/lib/source_route/version.rb +1 -1
- data/lib/source_route/wrapper.rb +2 -2
- data/source_route.gemspec +4 -1
- data/test/wrapper_test.rb +8 -1
- metadata +31 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53b09f104ea2720d70ee2312d8233aeefbc5ea6c
|
4
|
+
data.tar.gz: 33f9ec189a6d23df94cd85bd27da378561ebda00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64e04570f8a30d20631c86003bc3d311ac15f69a0e31d1b6e080220a553c1e8ad51699745fe4be6bf4f6c82f53266248ca78117e3f0f79da60effa506afdecaf
|
7
|
+
data.tar.gz: f1ba59748e527c875f5f4ac2b9a46cb3287f845f43ee62b38db9ad3cbf8f57ba89c08921c25e21ae53349fadaacd168ba0ec7d255431ac61f327483edfa1bbed
|
data/README.md
CHANGED
@@ -22,7 +22,49 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
|
25
|
+
#### In irb or pry terminal
|
26
|
+
|
27
|
+
SourceRoute.trace output_format: :console, event: :c_call do
|
28
|
+
'abc'.upcase
|
29
|
+
end
|
30
|
+
|
31
|
+
#### In rails console
|
32
|
+
|
33
|
+
SourceRoute.trace defined_class: 'ActiveRecord', output_format: html do
|
34
|
+
User.new
|
35
|
+
end
|
36
|
+
|
37
|
+
It will generate a html file, open it and you can get the trace of User.new
|
38
|
+
|
39
|
+
The intereting part is when you run the above command again(in same console),
|
40
|
+
you will get a different trace file.
|
41
|
+
|
42
|
+
#### In your ruby application
|
43
|
+
|
44
|
+
SourceRoute.enable :wanted_method_name
|
45
|
+
.... # here is your code
|
46
|
+
....
|
47
|
+
# may be code this in another file
|
48
|
+
SourceRoute.build_html_output
|
49
|
+
|
50
|
+
Same as the previous example, you will get a html file showing the code trace.
|
51
|
+
|
52
|
+
#### In a small application, you may try this
|
53
|
+
|
54
|
+
SourceRoute.enable do
|
55
|
+
defined_class :wanted_class_name
|
56
|
+
output_format :console
|
57
|
+
end
|
58
|
+
.... # here is your code
|
59
|
+
|
60
|
+
It will output the trace when you run the application.
|
61
|
+
|
62
|
+
see more usage in examples.
|
63
|
+
|
64
|
+
## Test
|
65
|
+
|
66
|
+
$ bundle install
|
67
|
+
$ rake
|
26
68
|
|
27
69
|
## Contributing
|
28
70
|
|
@@ -36,3 +78,5 @@ Or install it yourself as:
|
|
36
78
|
### TODO
|
37
79
|
|
38
80
|
Add debug option to provider more verbose messages of what has happened
|
81
|
+
|
82
|
+
Support SourceRoute.enable :wanted_method_or_class, at now only SourceRoute.enable :wanted_method works
|
data/lib/source_route.rb
CHANGED
@@ -24,7 +24,7 @@ html
|
|
24
24
|
.top-header
|
25
25
|
h4
|
26
26
|
| Event:
|
27
|
-
=< @conditions.
|
27
|
+
=< @conditions.events
|
28
28
|
.trace-flow
|
29
29
|
.row
|
30
30
|
.left-info.col-sm-4
|
@@ -63,10 +63,11 @@ html
|
|
63
63
|
$scope.traces = angular.element("#trace-data").data('trace')
|
64
64
|
// it is possible to prevent dirty check on definedClasses after it was generated
|
65
65
|
$scope.definedClasses = _.uniq(_.map($scope.traces, 'defined_class'))
|
66
|
-
$scope.
|
66
|
+
var all_counter = 'ALL ' + $scope.traces.length
|
67
|
+
$scope.definedClasses.unshift(all_counter)
|
67
68
|
|
68
69
|
$scope.selectKlass = function(klass) {
|
69
|
-
if (klass ==
|
70
|
+
if (klass == all_counter) {
|
70
71
|
$scope.selectedKlass = undefined
|
71
72
|
} else {
|
72
73
|
$scope.selectedKlass = klass
|
@@ -2,9 +2,21 @@ module SourceRoute
|
|
2
2
|
|
3
3
|
class TpResult
|
4
4
|
|
5
|
+
# see event description in TracePoint API Doc
|
5
6
|
DEFAULT_ATTRS = {
|
6
7
|
call: [:defined_class, :method_id],
|
7
|
-
return: [:defined_class, :method_id, :return_value]
|
8
|
+
return: [:defined_class, :method_id, :return_value],
|
9
|
+
c_call: [:defined_class, :method_id],
|
10
|
+
line: [:path, :lineno],
|
11
|
+
# following are not tested yet
|
12
|
+
class: [:defined_class],
|
13
|
+
end: [:defined_class],
|
14
|
+
c_return: [:defined_class, :method_id, :return_value],
|
15
|
+
raise: [:raised_exception],
|
16
|
+
b_call: [:binding, :defined_class, :method_id],
|
17
|
+
b_return: [:binding, :defined_class, :method_id],
|
18
|
+
thread_begin: [:defined_class, :method_id],
|
19
|
+
thread_end: [:defined_class, :method_id]
|
8
20
|
}
|
9
21
|
|
10
22
|
def initialize(wrapper)
|
@@ -42,7 +54,7 @@ module SourceRoute
|
|
42
54
|
when :html
|
43
55
|
# I cant solve the problem: to generate html at the end,
|
44
56
|
# I have to know when the application is end
|
45
|
-
when :test
|
57
|
+
when :test, :silence
|
46
58
|
# do nothing at now
|
47
59
|
when Proc
|
48
60
|
format.call(tp_ins)
|
data/lib/source_route/version.rb
CHANGED
data/lib/source_route/wrapper.rb
CHANGED
@@ -58,11 +58,11 @@ module SourceRoute
|
|
58
58
|
|
59
59
|
TRACE_POINT_METHODS.each do |m|
|
60
60
|
define_method m do |v|
|
61
|
-
@conditions.positive[m] = v
|
61
|
+
@conditions.positive[m] = v.to_s
|
62
62
|
end
|
63
63
|
|
64
64
|
define_method "#{m}_not" do |v|
|
65
|
-
@conditions.negative[m] = v
|
65
|
+
@conditions.negative[m] = v.to_s
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
data/source_route.gemspec
CHANGED
@@ -21,8 +21,11 @@ Gem::Specification.new do |spec|
|
|
21
21
|
|
22
22
|
spec.add_dependency 'awesome_print'
|
23
23
|
spec.add_dependency 'colorize'
|
24
|
+
spec.add_dependency 'slim'
|
25
|
+
|
24
26
|
spec.add_development_dependency "bundler", "~> 1.6"
|
25
27
|
spec.add_development_dependency "rake"
|
26
|
-
spec.add_development_dependency 'slim'
|
27
28
|
spec.add_development_dependency 'minitest'
|
29
|
+
spec.add_development_dependency 'pry'
|
30
|
+
spec.add_development_dependency 'pry-byebug'
|
28
31
|
end
|
data/test/wrapper_test.rb
CHANGED
@@ -41,7 +41,7 @@ module SourceRoute
|
|
41
41
|
|
42
42
|
def test_match_class_name
|
43
43
|
@source_route = SourceRoute.enable do
|
44
|
-
defined_class
|
44
|
+
defined_class :SampleApp
|
45
45
|
end
|
46
46
|
|
47
47
|
SampleApp.new.nonsense
|
@@ -82,6 +82,13 @@ module SourceRoute
|
|
82
82
|
assert_includes paths.first, 'sample_app'
|
83
83
|
end
|
84
84
|
|
85
|
+
def test_trace_with_c_call
|
86
|
+
SourceRoute.trace event: :c_call do
|
87
|
+
'abc'.upcase
|
88
|
+
end
|
89
|
+
assert_equal 2, @wrapper.tp_attrs_results.size
|
90
|
+
end
|
91
|
+
|
85
92
|
def test_trace_without_first_hash_option
|
86
93
|
SourceRoute.trace output_format: :test do
|
87
94
|
SampleApp.new.nonsense
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: source_route
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- raykin
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: slim
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: bundler
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,7 +81,7 @@ dependencies:
|
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
84
|
+
name: minitest
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
87
|
- - ">="
|
@@ -81,7 +95,21 @@ dependencies:
|
|
81
95
|
- !ruby/object:Gem::Version
|
82
96
|
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
98
|
+
name: pry
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pry-byebug
|
85
113
|
requirement: !ruby/object:Gem::Requirement
|
86
114
|
requirements:
|
87
115
|
- - ">="
|