source_route 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -4
- data/lib/source_route/formats/html.rb +7 -5
- data/lib/source_route/formats/html_template.slim +17 -15
- data/lib/source_route/tp_result.rb +6 -1
- data/lib/source_route/version.rb +1 -1
- data/lib/source_route/wrapper.rb +24 -3
- data/test/source_route_test.rb +19 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dcacd3bc9218d3672d3cdc0626d2b57206888278
|
4
|
+
data.tar.gz: 5af21722a04b726215d10135926dd8cce886ea11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 09033b7fa8966999764624b2de72eba73a9e2ab4060ddf66546f7667b656e69c521864092008612124e7d1f208dedd5fe7cd6235c42ce969cd85979297fd3cbf
|
7
|
+
data.tar.gz: 5ea766d01dec82d33b88649f4fcfb3d635b82746dfb4933abfd4ccac7e5c84615a6c3c666c6876fa49593882e40e090e7236dc09c29fb13d692b8c59e5558c60
|
data/README.md
CHANGED
@@ -77,8 +77,4 @@ see more usage in examples.
|
|
77
77
|
|
78
78
|
### TODO
|
79
79
|
|
80
|
-
Reorganize the call and return in html template. maybe make some additional work to insert return data of call when return event is open.
|
81
|
-
|
82
80
|
Add debug option to provider more verbose messages of what has happened
|
83
|
-
|
84
|
-
When we record both call end return event, it's better to combine them togother into one, so we can get call order from call event and also get return value from return event
|
@@ -5,14 +5,16 @@ module SourceRoute
|
|
5
5
|
module Formats
|
6
6
|
module Html
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
def self.slim_render(wrapper)
|
9
|
+
result_config = wrapper.condition.result_config
|
10
10
|
template_path = File.expand_path "../html_template.slim", __FILE__
|
11
11
|
slim_template = Slim::Template.new(template_path)
|
12
12
|
|
13
|
-
filename =
|
14
|
-
|
15
|
-
|
13
|
+
filename = result_config[:filename] || "#{Time.now.strftime('%H%M')}-source-route.html"
|
14
|
+
if result_config[:import_return_to_call] and wrapper.condition.has_call_and_return_event
|
15
|
+
wrapper.import_return_value_to_call_results
|
16
|
+
end
|
17
|
+
html_output_str = slim_template.render(wrapper)
|
16
18
|
File.open(filename, 'w') do |f|
|
17
19
|
f << html_output_str
|
18
20
|
end
|
@@ -7,12 +7,11 @@ html
|
|
7
7
|
script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"
|
8
8
|
|
9
9
|
body(ng-app="SourceRoute")
|
10
|
-
/ workaround for following case:
|
11
|
-
/ pry(main)> ActiveRecord::Inheritance::ClassMethods.to_json => {} # Dont know why
|
12
10
|
ruby:
|
13
11
|
local_trace_data = @tp_attrs_results.map do |tp_result|
|
14
|
-
if tp_result.
|
15
|
-
tp_result[:defined_class] = tp_result[:defined_class].
|
12
|
+
if tp_result.key?(:defined_class)
|
13
|
+
tp_result[:defined_class] = tp_result[:defined_class].inspect
|
14
|
+
tp_result[:return_value] = tp_result[:return_value].inspect
|
16
15
|
end
|
17
16
|
tp_result
|
18
17
|
end
|
@@ -22,7 +21,11 @@ html
|
|
22
21
|
#trace-data(data-trace="#{JSON.dump(local_trace_data)}" data-tp-events="#{JSON.dump(@condition.events)}")
|
23
22
|
|
24
23
|
.container(ng-controller="MainCtrl")
|
25
|
-
.top-header(style="margin-bottom: 2em")
|
24
|
+
.top-header(style="margin-bottom: 2em; margin-top: 2em")
|
25
|
+
|
26
|
+
.pull-right
|
27
|
+
span Current Trace Count
|
28
|
+
span.badge<(ng-bind="currentCounter()")
|
26
29
|
|
27
30
|
div(ng-if="tpEvents.length == 1")
|
28
31
|
button.btn.btn-default(ng-click="resetTraceFilter()")
|
@@ -30,20 +33,18 @@ html
|
|
30
33
|
span<(ng-bind="tpEvents[0]")
|
31
34
|
|
32
35
|
.btn-group(ng-if="tpEvents.length > 1")
|
33
|
-
button(ng-click="
|
34
|
-
button.btn-
|
35
|
-
.pull-right
|
36
|
-
span Current Trace Count
|
37
|
-
span<(ng-bind="currentCounter()")
|
36
|
+
button.btn.btn-default(ng-click="resetTraceFilter()") ALL
|
37
|
+
button.btn.btn-primary(ng-bind="event" ng-click="traceFilter.event = event" ng-repeat="event in tpEvents")
|
38
38
|
|
39
39
|
.trace-flow
|
40
40
|
.row
|
41
41
|
.left-info.col-sm-4
|
42
|
-
.
|
43
|
-
button.btn.btn-default(ng-
|
42
|
+
.btn-group-vertical
|
43
|
+
button.btn.btn-default(ng-repeat="klass in definedClasses"
|
44
|
+
ng-click="traceFilter.defined_class = klass" style="height: 60px")
|
44
45
|
span(ng-bind="klass")
|
45
|
-
.center-info.col-sm-6
|
46
|
-
.well.well-lg(ng-repeat="trace in traces | filter:traceFilter")
|
46
|
+
.traces.center-info.col-sm-6(ng-class="{{traceFilter.event}}")
|
47
|
+
.trace.well.well-lg(ng-repeat="trace in traces | filter:traceFilter:true")
|
47
48
|
|
48
49
|
.header(ng-click="showMoreDetail = !showMoreDetail")
|
49
50
|
span(ng-bind="trace.defined_class")
|
@@ -53,6 +54,7 @@ html
|
|
53
54
|
|
54
55
|
span<>(ng-if="trace.return_value")
|
55
56
|
| =>
|
57
|
+
br
|
56
58
|
span<>(ng-if="trace.return_value" ng-bind="trace.return_value")
|
57
59
|
|
58
60
|
.details(ng-if="showMoreDetail")
|
@@ -88,7 +90,7 @@ html
|
|
88
90
|
$scope.traceFilter = {}
|
89
91
|
}
|
90
92
|
$scope.currentCounter = function() {
|
91
|
-
return $filter('filter')($scope.traces, $scope.traceFilter).length
|
93
|
+
return $filter('filter')($scope.traces, $scope.traceFilter, true).length
|
92
94
|
}
|
93
95
|
|
94
96
|
})
|
@@ -3,7 +3,11 @@ module SourceRoute
|
|
3
3
|
class TpResult
|
4
4
|
|
5
5
|
Config = Struct.new(:format, :show_additional_attrs,
|
6
|
-
:include_local_var, :include_instance_var, :filename)
|
6
|
+
:include_local_var, :include_instance_var, :filename, :import_return_to_call) do
|
7
|
+
def initialize(f="silence", s=[], ilr=false, iiv=false)
|
8
|
+
super(f, s, ilr, iiv)
|
9
|
+
end
|
10
|
+
end
|
7
11
|
|
8
12
|
# see event description in TracePoint API Doc
|
9
13
|
DEFAULT_ATTRS = {
|
@@ -116,6 +120,7 @@ module SourceRoute
|
|
116
120
|
def console_stack_overflow
|
117
121
|
ap "#{@collect_data[:defined_class].inspect}##{@collect_data[:method_id]}"
|
118
122
|
end
|
123
|
+
|
119
124
|
end # END TpResult
|
120
125
|
|
121
126
|
end
|
data/lib/source_route/version.rb
CHANGED
data/lib/source_route/wrapper.rb
CHANGED
@@ -7,7 +7,11 @@ module SourceRoute
|
|
7
7
|
|
8
8
|
attr_accessor :condition, :tp, :tp_attrs_results
|
9
9
|
|
10
|
-
Condition = Struct.new(:events, :negatives, :positive, :result_config)
|
10
|
+
Condition = Struct.new(:events, :negatives, :positive, :result_config) do
|
11
|
+
def initialize(e=[:call], n={}, p={}, r=TpResult::Config.new)
|
12
|
+
super(e, n, p, r)
|
13
|
+
end
|
14
|
+
end
|
11
15
|
|
12
16
|
class Condition
|
13
17
|
|
@@ -30,6 +34,9 @@ module SourceRoute
|
|
30
34
|
result_config.format = block_given? ? block : data
|
31
35
|
end
|
32
36
|
|
37
|
+
def has_call_and_return_event
|
38
|
+
events.include? :return and events.include? :call
|
39
|
+
end
|
33
40
|
end
|
34
41
|
|
35
42
|
def initialize
|
@@ -38,8 +45,7 @@ module SourceRoute
|
|
38
45
|
|
39
46
|
def reset
|
40
47
|
@tp.disable if @tp
|
41
|
-
@condition = Condition.new
|
42
|
-
TpResult::Config.new('silence', [], false, false))
|
48
|
+
@condition = Condition.new
|
43
49
|
@tp_attrs_results = []
|
44
50
|
self
|
45
51
|
end
|
@@ -65,6 +71,21 @@ module SourceRoute
|
|
65
71
|
track
|
66
72
|
end
|
67
73
|
|
74
|
+
def import_return_value_to_call_results
|
75
|
+
call_tp_results.each do |ctp|
|
76
|
+
ctp[:return_value] = return_tp_results.detect do |rtp|
|
77
|
+
rtp[:defined_class] == ctp[:defined_class] and rtp[:method_id] == ctp[:method_id]
|
78
|
+
end[:return_value]
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def call_tp_results
|
83
|
+
tp_attrs_results.select { |tpr| tpr[:event] == :call }
|
84
|
+
end
|
85
|
+
|
86
|
+
def return_tp_results
|
87
|
+
tp_attrs_results.select { |tpr| tpr[:event] == :return }
|
88
|
+
end
|
68
89
|
end # Wrapper
|
69
90
|
|
70
91
|
end
|
data/test/source_route_test.rb
CHANGED
@@ -154,20 +154,37 @@ class SourceRouteTest < Minitest::Test
|
|
154
154
|
assert_equal 'ins sure', ret_value[:instance_var][:@sample]
|
155
155
|
end
|
156
156
|
|
157
|
+
def test_import_return_to_call
|
158
|
+
@source_route = SourceRoute.enable 'SampleApp' do
|
159
|
+
event :call, :return
|
160
|
+
result_config.include_instance_var = true
|
161
|
+
result_config.include_local_var = true
|
162
|
+
result_config.import_return_to_call = true
|
163
|
+
end
|
164
|
+
SampleApp.new.init_cool_app
|
165
|
+
@wrapper.import_return_value_to_call_results
|
166
|
+
assert @wrapper.call_tp_results[0].key?(:return_value), 'call results should contain return_value'
|
167
|
+
end
|
168
|
+
|
157
169
|
# Nothing has tested really when run rake cause ENV['ignore_html_generation'] was set to true
|
158
|
-
def
|
170
|
+
def test_html_format_output_with_two_events_and_filename
|
159
171
|
@source_route = SourceRoute.enable do
|
160
172
|
defined_class 'SampleApp'
|
173
|
+
event :call, :return
|
161
174
|
result_config.include_instance_var = true
|
162
175
|
result_config.include_local_var = true
|
176
|
+
result_config.filename = 'call_and_return_in_sample_app.html'
|
177
|
+
result_config.import_return_to_call = true
|
163
178
|
end
|
164
179
|
|
165
180
|
SampleApp.new.init_cool_app
|
166
181
|
|
167
182
|
if ENV['ignore_html_generation'] == 'true'
|
168
|
-
# do nothing. it was set in Rakefile
|
183
|
+
# do nothing. cause it was set to false in Rakefile.
|
184
|
+
# So Run rake test will not generate html file, run ruby -Itest test/source_route.rb will generate output file
|
169
185
|
else
|
170
186
|
SourceRoute.build_html_output
|
187
|
+
puts @wrapper.tp_attrs_results.inspect
|
171
188
|
end
|
172
189
|
end
|
173
190
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- raykin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: awesome_print
|