source_route 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/lib/source_route/formats/html_semantic.slim +26 -26
- data/lib/source_route/formats/html_semantic.slim.failtry +257 -0
- data/lib/source_route/generate_result.rb +3 -1
- data/lib/source_route/json_overrides/activerecord_associations_association.rb +12 -1
- data/lib/source_route/rails_plugins/source_track_middleware.rb +16 -9
- data/lib/source_route/tp_filter.rb +5 -1
- data/lib/source_route/tp_result.rb +8 -2
- data/lib/source_route/version.rb +1 -1
- data/source_route.gemspec +0 -1
- data/test/sample_app.rb +23 -0
- metadata +4 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8160b88083287b44b8d70d1a279f9f83cff46d48
|
4
|
+
data.tar.gz: 6df4dfed2f5c79c9e676b86d202099f6b6b44cbb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f62a0b28a1fd1c58c9c6c023ff8841753054e47ab180547e29896cf3331016d6240d31acfd8862b0dcd89222ca6be915c485e1c6d308be87df4539af76e8576
|
7
|
+
data.tar.gz: 9527da75cbe11a77766eaad9415a2b061dcd3c7c93b535d22383f1eb3b35a9de943700942759d117ce30f7d024cd14b26907688871c53508ac416dcb1ea98eb6
|
data/README.md
CHANGED
@@ -94,6 +94,12 @@ Finally, I expect my working style can changes from searching workaround from in
|
|
94
94
|
|
95
95
|
### TODO
|
96
96
|
|
97
|
+
global disable some class from monitor
|
98
|
+
|
99
|
+
does Rails 4.1.8 support failed?
|
100
|
+
|
101
|
+
Add debug log to help debugging (ex: stack level too deep)
|
102
|
+
|
97
103
|
Cleanup Code and remove useless comments.
|
98
104
|
|
99
105
|
Dynamic indent when new child level comes.
|
@@ -3,13 +3,13 @@ html
|
|
3
3
|
head
|
4
4
|
title Source Route Result
|
5
5
|
link rel="stylesheet" href="https://cdn.rawgit.com/Urigo/angular-spinkit/master/build/angular-spinkit.min.css"
|
6
|
-
link rel="stylesheet" href="https://cdn.rawgit.com/
|
7
|
-
link rel="stylesheet" href="http://oss.maxcdn.com/semantic-ui/2.1.
|
6
|
+
link rel="stylesheet" href="https://cdn.rawgit.com/raykin/json-formatter/dist/dist/json-formatter.css"
|
7
|
+
link rel="stylesheet" href="http://oss.maxcdn.com/semantic-ui/2.1.8/semantic.min.css"
|
8
8
|
|
9
9
|
script async=true src="http://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.10.0/lodash.js"
|
10
10
|
script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"
|
11
11
|
script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.6/angular.min.js"
|
12
|
-
script async=true src="http://oss.maxcdn.com/semantic-ui/2.1.
|
12
|
+
script async=true src="http://oss.maxcdn.com/semantic-ui/2.1.8/semantic.min.js"
|
13
13
|
|
14
14
|
css:
|
15
15
|
.call-level-0 {}
|
@@ -20,6 +20,9 @@ html
|
|
20
20
|
.item.trace.call-level-5 { padding-left: 250px }
|
21
21
|
.item.trace.call-level-6 { padding-left: 300px }
|
22
22
|
.item.trace.call-level-7 { padding-left: 300px }
|
23
|
+
.trace .main .ui.label .icon {
|
24
|
+
margin-right: 0;
|
25
|
+
}
|
23
26
|
// level more than 7 seems not reasonable
|
24
27
|
|
25
28
|
body(ng-app="SourceRoute" ng-controller="MainCtrl" ng-cloak)
|
@@ -47,48 +50,45 @@ html
|
|
47
50
|
.ui.container
|
48
51
|
.row
|
49
52
|
.ui.relaxed.items(ng-class="{{traceFilter.event}}")
|
50
|
-
.item.trace(ng-repeat="trace in traces | filter:traceFilter:true | filter:childParentFilterFn" ng-class="callLevelClass(trace)" ng-controller="TpTraceCtrl")
|
51
|
-
.content(ng-init="showMoreDetail = false")
|
52
|
-
.ui.segment.
|
53
|
+
.item.trace(ng-repeat="trace in traces | filter:traceFilter:true | filter:childParentFilterFn track by trace.order_id" ng-class="callLevelClass(trace)" ng-controller="TpTraceCtrl")
|
54
|
+
.content(ng-init="showMoreDetail = false" style="display: flex; justify-content: space-between; align-items: center;")
|
55
|
+
.ui.segment.padded.main
|
56
|
+
a.ui.top.right.attached.label.mini(ng-show="::containsDetail(trace)" ng-click="showMoreDetail = !showMoreDetail")
|
57
|
+
i.sidebar.icon
|
53
58
|
.header
|
59
|
+
span.bold>(ng-bind="::trace.order_id")
|
54
60
|
span(ng-bind="::tpSelfList[trace.tp_self_refer]")
|
55
61
|
i.circle.icon.grey(style="font-size: 0.3em")
|
56
62
|
span.method-value(ng-bind="::trace.method_id")
|
63
|
+
a.ui.bottom.right.attached.label.mini(ng-if="::hasChild()" ng-click="toggleChild()" ng-class="{loading: togglingChild}")
|
64
|
+
i.icon.angle.down(ng-show="trace.childOpened" style="font-size: 10px")
|
65
|
+
i.icon.angle.right(ng-hide="trace.childOpened" style="font-size: 14px")
|
66
|
+
/ pulse-spinner(ng-show="togglingChild")
|
57
67
|
/ workaround for return_value is 'false' and return_value always to be string when existed
|
58
68
|
.meta(ng-if="trace.hasOwnProperty('return_value')")
|
59
69
|
i.icon.pointing.right.small
|
60
|
-
json-formatter(
|
61
|
-
.description
|
62
|
-
.ui.vertical.buttons.basic
|
63
|
-
button.ui.labeled.icon.button(ng-show="::containsDetail(trace)" ng-click="showMoreDetail = !showMoreDetail")
|
64
|
-
i.browser.icon
|
65
|
-
span Details
|
66
|
-
button.ui.labeled.icon.button(ng-if="::hasChild()" ng-click="toggleChild()" ng-class="{loading: togglingChild}")
|
67
|
-
i.icon.angle.down(ng-show="trace.childOpened")
|
68
|
-
i.icon.angle.right(ng-hide="trace.childOpened")
|
69
|
-
span Child
|
70
|
-
pulse-spinner(ng-show="togglingChild")
|
71
|
-
|
70
|
+
json-formatter(json="::trace.return_value" title="{{::trace.return_value_class}}" style="display: inline-block")
|
71
|
+
.description(style="margin-left: 20px")
|
72
72
|
.details.right.floated(ng-if="showMoreDetail")
|
73
73
|
.ui.segments(style="border-color: blue")
|
74
74
|
.ui.segment(ng-if="::trace.params_var")
|
75
75
|
.ui.teal.right.ribbon.label Parameters
|
76
|
-
json-formatter(open="1" json="::trace.params_var")
|
76
|
+
json-formatter(open="1" json="::trace.params_var" title="{{::trace.params_var_class}}")
|
77
77
|
.ui.segment(ng-if="::trace.hasOwnProperty('return_value')")
|
78
78
|
.ui.grey.right.ribbon.label Return Value
|
79
|
-
json-formatter(json="::trace.return_value")
|
80
|
-
.ui.segment(ng-if="::containsOtherAttrs(trace)")
|
81
|
-
.ui.orange.right.ribbon.label Trace Attributes
|
82
|
-
json-formatter(open="1" json="::plusTraceAttrs[trace.order_id]")
|
79
|
+
json-formatter(open="1" json="::trace.return_value" title="{{::trace.return_value_class}}")
|
83
80
|
.ui.segment(ng-if="::trace.local_var")
|
84
81
|
.ui.teal.right.ribbon.label Local Variables
|
85
|
-
json-formatter(open="1" json="::trace.local_var")
|
82
|
+
json-formatter(open="1" json="::trace.local_var" title="{{::trace.local_var_class}}")
|
86
83
|
.ui.segment(ng-if="::trace.instance_var")
|
87
84
|
.ui.blue.right.ribbon.label Instance Variables
|
88
|
-
json-formatter(open="1" json="::trace.instance_var")
|
85
|
+
json-formatter(open="1" json="::trace.instance_var" title="{{::trace.instance_var_class}}")
|
86
|
+
.ui.segment(ng-if="::containsOtherAttrs(trace)")
|
87
|
+
.ui.orange.right.ribbon.label Trace Attributes
|
88
|
+
json-formatter(open="1" json="::plusTraceAttrs[trace.order_id]" title="TracePoint")
|
89
89
|
|
90
90
|
script src="https://cdn.rawgit.com/Urigo/angular-spinkit/master/build/angular-spinkit.min.js"
|
91
|
-
script src="https://cdn.rawgit.com/
|
91
|
+
script src="https://cdn.rawgit.com/raykin/json-formatter/dist/dist/json-formatter.js"
|
92
92
|
// script async src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular-sanitize.js"
|
93
93
|
|
94
94
|
javascript:
|
@@ -0,0 +1,257 @@
|
|
1
|
+
doctype html
|
2
|
+
html
|
3
|
+
head
|
4
|
+
title Source Route Result
|
5
|
+
link rel="stylesheet" href="https://cdn.rawgit.com/Urigo/angular-spinkit/master/build/angular-spinkit.min.css"
|
6
|
+
link rel="stylesheet" href="https://cdn.rawgit.com/mohsen1/json-formatter/master/dist/json-formatter.css"
|
7
|
+
link rel="stylesheet" href="http://oss.maxcdn.com/semantic-ui/2.1.7/semantic.min.css"
|
8
|
+
|
9
|
+
script async=true src="http://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.10.0/lodash.js"
|
10
|
+
script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"
|
11
|
+
script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.6/angular.min.js"
|
12
|
+
script async=true src="http://oss.maxcdn.com/semantic-ui/2.1.7/semantic.min.js"
|
13
|
+
|
14
|
+
css:
|
15
|
+
.call-level-0 {}
|
16
|
+
.item.trace.call-level-1 { padding-left: 50px }
|
17
|
+
.item.trace.call-level-2 { padding-left: 100px }
|
18
|
+
.item.trace.call-level-3 { padding-left: 150px }
|
19
|
+
.item.trace.call-level-4 { padding-left: 200px }
|
20
|
+
.item.trace.call-level-5 { padding-left: 250px }
|
21
|
+
.item.trace.call-level-6 { padding-left: 300px }
|
22
|
+
.item.trace.call-level-7 { padding-left: 300px }
|
23
|
+
.tree-level {
|
24
|
+
display: flex;
|
25
|
+
align-items: center;
|
26
|
+
justify-content: space-around;
|
27
|
+
}
|
28
|
+
// level more than 7 seems not reasonable
|
29
|
+
|
30
|
+
body(ng-app="SourceRoute" ng-controller="MainCtrl" ng-cloak)
|
31
|
+
|
32
|
+
.ui.menu.pointing.stackable.attached
|
33
|
+
.ui.container
|
34
|
+
.item
|
35
|
+
a.navbar-brand(href="#" ng-click="::resetTraceFilter()") ALL
|
36
|
+
.item(ng-repeat="event in tpEvents" ng-class="{active: event == traceFilter.event}")
|
37
|
+
a(href="#" ng-click="traceFilter.event = event" ng-bind="::event")
|
38
|
+
.item
|
39
|
+
.ui.buttons
|
40
|
+
button.ui.labeled.icon.button.olive(ng-click="outlineTrace()" ng-class="{loading: outlineTraceLoading}")
|
41
|
+
i.angle.double.right.icon
|
42
|
+
span OutLine
|
43
|
+
.or
|
44
|
+
button.ui.right.labeled.icon.button.green(ng-click="expandAllTrace()" ng-class="{loading: expandAllTraceLoading}")
|
45
|
+
i.angle.double.down.icon
|
46
|
+
span Expand
|
47
|
+
.right.menu
|
48
|
+
.item
|
49
|
+
span Trace Count
|
50
|
+
.ui.teal.left.pointing.label(ng-bind="currentCounter()")
|
51
|
+
|
52
|
+
.ui.container
|
53
|
+
.row
|
54
|
+
/ .ui.relaxed.items(ng-class="{{traceFilter.event}}")
|
55
|
+
.ui.segment.tree-level(ng-repeat="level in lengthLevel")
|
56
|
+
.item.trace(ng-repeat="trace in traces | filter:{parent_length: level, event: traceFilter.event}" ng-class="callLevelClass(trace)" ng-controller="TpTraceCtrl")
|
57
|
+
.content(ng-init="showMoreDetail = false")
|
58
|
+
.ui.segment.left.floated.padded
|
59
|
+
.header
|
60
|
+
span(ng-bind="::tpSelfList[trace.tp_self_refer]")
|
61
|
+
i.circle.icon.grey(style="font-size: 0.3em")
|
62
|
+
span.method-value(ng-bind="::trace.method_id")
|
63
|
+
/ workaround for return_value is 'false' and return_value always to be string when existed
|
64
|
+
.meta(ng-if="trace.hasOwnProperty('return_value')")
|
65
|
+
i.icon.pointing.right.small
|
66
|
+
json-formatter(open="1" json="::trace.return_value" style="display: inline-block")
|
67
|
+
.description
|
68
|
+
.ui.vertical.buttons.basic
|
69
|
+
button.ui.labeled.icon.button(ng-show="::containsDetail(trace)" ng-click="showMoreDetail = !showMoreDetail")
|
70
|
+
i.browser.icon
|
71
|
+
span Details
|
72
|
+
button.ui.labeled.icon.button(ng-if="::hasChild()" ng-click="toggleChild()" ng-class="{loading: togglingChild}")
|
73
|
+
i.icon.angle.down(ng-show="trace.childOpened")
|
74
|
+
i.icon.angle.right(ng-hide="trace.childOpened")
|
75
|
+
span Child
|
76
|
+
pulse-spinner(ng-show="togglingChild")
|
77
|
+
|
78
|
+
.details.right.floated(ng-if="showMoreDetail")
|
79
|
+
.ui.segments(style="border-color: blue")
|
80
|
+
.ui.segment(ng-if="::trace.params_var")
|
81
|
+
.ui.teal.right.ribbon.label Parameters
|
82
|
+
json-formatter(open="1" json="::trace.params_var")
|
83
|
+
.ui.segment(ng-if="::trace.hasOwnProperty('return_value')")
|
84
|
+
.ui.grey.right.ribbon.label Return Value
|
85
|
+
json-formatter(json="::trace.return_value")
|
86
|
+
.ui.segment(ng-if="::containsOtherAttrs(trace)")
|
87
|
+
.ui.orange.right.ribbon.label Trace Attributes
|
88
|
+
json-formatter(open="1" json="::plusTraceAttrs[trace.order_id]")
|
89
|
+
.ui.segment(ng-if="::trace.local_var")
|
90
|
+
.ui.teal.right.ribbon.label Local Variables
|
91
|
+
json-formatter(open="1" json="::trace.local_var")
|
92
|
+
.ui.segment(ng-if="::trace.instance_var")
|
93
|
+
.ui.blue.right.ribbon.label Instance Variables
|
94
|
+
json-formatter(open="1" json="::trace.instance_var")
|
95
|
+
|
96
|
+
script src="https://cdn.rawgit.com/Urigo/angular-spinkit/master/build/angular-spinkit.min.js"
|
97
|
+
script src="https://cdn.rawgit.com/mohsen1/json-formatter/master/dist/json-formatter.js"
|
98
|
+
// script async src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular-sanitize.js"
|
99
|
+
|
100
|
+
javascript:
|
101
|
+
sourceRoute = angular.module('SourceRoute', ['jsonFormatter', 'angular-spinkit'])
|
102
|
+
sourceRoute.controller('MainCtrl', function($scope, $filter, $timeout) {
|
103
|
+
|
104
|
+
// setup different color on menu item may not be a good solution
|
105
|
+
// $scope.menuColorList = ['yellow', 'olive', 'green', 'teal', 'violet', 'purple', 'brown']
|
106
|
+
$scope.trimString = function(str, length) {
|
107
|
+
return str.length > length ? str.substring(0, length - 3) + '...' : str;
|
108
|
+
}
|
109
|
+
|
110
|
+
$scope.traces = angular.element("#trace-data").data('trace')
|
111
|
+
$scope.tpSelfList = angular.element("#trace-data").data('tp-self-caches')
|
112
|
+
$scope.tpEvents = angular.element("#trace-data").data('tp-events')
|
113
|
+
$scope.childParentFilter = { hide_trace_ids: [] }
|
114
|
+
|
115
|
+
$scope.lengthLevel = $scope.traces.reduce(function(pre, cur) {
|
116
|
+
if (_.includes(pre, cur.parent_length)) {
|
117
|
+
// return pre; // do nothing
|
118
|
+
} else {
|
119
|
+
pre.push(cur.parent_length)
|
120
|
+
}
|
121
|
+
return pre;
|
122
|
+
}, []);
|
123
|
+
|
124
|
+
$scope.childParentFilterFn = function(trace) {
|
125
|
+
if (!trace.hasOwnProperty('parent_ids')) {
|
126
|
+
return true;
|
127
|
+
}
|
128
|
+
if (trace.parent_ids.length == 0) {
|
129
|
+
return true;
|
130
|
+
} else {
|
131
|
+
var shared_hide_parents = _.intersection(trace.parent_ids, $scope.childParentFilter.hide_trace_ids);
|
132
|
+
if (shared_hide_parents.length > 0 ) {
|
133
|
+
return false;
|
134
|
+
}
|
135
|
+
}
|
136
|
+
return true;
|
137
|
+
}
|
138
|
+
|
139
|
+
$scope.expandAllTrace = function() {
|
140
|
+
$scope.expandAllTraceLoading = true
|
141
|
+
$timeout(function() {
|
142
|
+
_.each($scope.traces, function(trace) { trace.childOpened = true; });
|
143
|
+
$scope.childParentFilter.hide_trace_ids = [];
|
144
|
+
$scope.expandAllTraceLoading = false
|
145
|
+
$scope.expandAllTraceLoading = false
|
146
|
+
}, 100)
|
147
|
+
}
|
148
|
+
|
149
|
+
$scope.outlineTrace = function() {
|
150
|
+
$scope.outlineTraceLoading = true
|
151
|
+
$scope.childParentFilter.hide_trace_ids = [];
|
152
|
+
_.chain($scope.traces).filter({parent_length: 0, event: $scope.traceFilter.event})
|
153
|
+
.each(function(trace) {
|
154
|
+
trace.childOpened = false;
|
155
|
+
$scope.childParentFilter.hide_trace_ids.push(trace.order_id) }
|
156
|
+
).value()
|
157
|
+
$scope.outlineTraceLoading = false
|
158
|
+
}
|
159
|
+
|
160
|
+
$scope.traceFilter = {event: $scope.tpEvents[0]}
|
161
|
+
if ($scope.tpEvents.length == 1 && angular.isUndefined($scope.traces[0].event)) {
|
162
|
+
_.each($scope.traces, function(trace) {
|
163
|
+
trace.event = $scope.tpEvents[0]
|
164
|
+
})
|
165
|
+
}
|
166
|
+
|
167
|
+
$scope.definedClasses = _.uniq(_.map($scope.traces, 'defined_class'))
|
168
|
+
|
169
|
+
$scope.callLevelClass = function(trace) {
|
170
|
+
if (trace.parent_length > 7) {
|
171
|
+
return 'call-level-7';
|
172
|
+
} else {
|
173
|
+
return 'call-level-' + trace.parent_length;
|
174
|
+
}
|
175
|
+
}
|
176
|
+
|
177
|
+
$scope.resetTraceFilter = function() {
|
178
|
+
$scope.traceFilter = {};
|
179
|
+
}
|
180
|
+
|
181
|
+
$scope.currentCounter = function() {
|
182
|
+
return $filter('filter')($scope.traces, $scope.traceFilter, true).length;
|
183
|
+
}
|
184
|
+
|
185
|
+
$scope.containsOtherAttrs = function(trace) {
|
186
|
+
return trace.hasOwnProperty('path') || trace.hasOwnProperty('lineno')
|
187
|
+
}
|
188
|
+
|
189
|
+
$scope.containsDetail = function(trace) {
|
190
|
+
return $scope.containsOtherAttrs(trace) || trace.hasOwnProperty('local_var') ||
|
191
|
+
trace.hasOwnProperty('instance_var')
|
192
|
+
}
|
193
|
+
|
194
|
+
combinedAttrs = function(trace) {
|
195
|
+
var attrs = {}
|
196
|
+
if (trace.hasOwnProperty('lineno') && trace.hasOwnProperty('path')) {
|
197
|
+
attrs.method_defined_on = trace.path + ":" + trace.lineno;
|
198
|
+
} else if (trace.hasOwnProperty('path')) {
|
199
|
+
attrs.method_defined_on = trace.path;
|
200
|
+
}
|
201
|
+
if (trace.hasOwnProperty('defined_class')) {
|
202
|
+
attrs.method_defined_in = trace.defined_class;
|
203
|
+
}
|
204
|
+
return attrs;
|
205
|
+
}
|
206
|
+
|
207
|
+
$scope.plusTraceAttrs = _.map($scope.traces, combinedAttrs)
|
208
|
+
|
209
|
+
$scope.outlineTrace();
|
210
|
+
})
|
211
|
+
|
212
|
+
sourceRoute.controller('TpTraceCtrl', function($scope, $timeout) {
|
213
|
+
|
214
|
+
$scope.toggleChild = function() {
|
215
|
+
$scope.togglingChild = true
|
216
|
+
$timeout(function() {
|
217
|
+
if ($scope.trace.childOpened) {
|
218
|
+
$scope.hideChild();
|
219
|
+
$scope.togglingChild = false
|
220
|
+
} else {
|
221
|
+
$scope.showChild();
|
222
|
+
$scope.togglingChild = false
|
223
|
+
}
|
224
|
+
}, 0)
|
225
|
+
}
|
226
|
+
|
227
|
+
$scope.showChild = function() {
|
228
|
+
$scope.trace.childOpened = true;
|
229
|
+
_.pull($scope.childParentFilter.hide_trace_ids, $scope.trace.order_id);
|
230
|
+
if ($scope.trace.direct_child_order_ids.length > 0) {
|
231
|
+
$scope.childParentFilter.hide_trace_ids.push($scope.trace.direct_child_order_ids);
|
232
|
+
$scope.childParentFilter.hide_trace_ids = _.chain($scope.childParentFilter.hide_trace_ids).flatten().uniq().value();
|
233
|
+
}
|
234
|
+
}
|
235
|
+
|
236
|
+
$scope.hideChild = function() {
|
237
|
+
$scope.trace.childOpened = false;
|
238
|
+
$scope.childParentFilter.hide_trace_ids.push($scope.trace.order_id);
|
239
|
+
if ($scope.trace.direct_child_order_ids.length > 0) {
|
240
|
+
_.each($scope.trace.direct_child_order_ids, function(ele) {
|
241
|
+
_.pull($scope.childParentFilter.hide_trace_ids, ele);
|
242
|
+
});
|
243
|
+
}
|
244
|
+
}
|
245
|
+
|
246
|
+
$scope.hasChild = function() {
|
247
|
+
return _.find($scope.traces, function(trace) {
|
248
|
+
return _.contains(trace.parent_ids, $scope.trace.order_id)
|
249
|
+
});
|
250
|
+
}
|
251
|
+
})
|
252
|
+
|
253
|
+
.data-collect
|
254
|
+
/ dont use local_trace_data.to_json, because ActiveSupport override it and can introduce unexpected crash for some data
|
255
|
+
#trace-data(data-trace="#{jsonify_tp_result_chain}"
|
256
|
+
data-tp-events="#{jsonify_events}"
|
257
|
+
data-tp-self-caches="#{jsonify_tp_self_caches}")
|
@@ -92,7 +92,9 @@ module SourceRoute
|
|
92
92
|
end
|
93
93
|
|
94
94
|
def jsonify_tp_result_chain
|
95
|
-
|
95
|
+
value = tp_result_chain.chain.map(&:to_hash)
|
96
|
+
Oj.dump(value, mode: :compat)
|
97
|
+
|
96
98
|
# tp_result_chain.to_json
|
97
99
|
# json_array = tp_result_chain.map { |result| Jsonify.dump(result) }
|
98
100
|
# '[ ' + json_array.join(',') + ' ]'
|
@@ -4,10 +4,21 @@ if defined? ActiveRecord
|
|
4
4
|
# dump association can trigger ActiveSupport::JSON::Encoding::CircularReferenceError when use rails ~> 4.0.1
|
5
5
|
# I try other json gems to fix it, but all failed. That's why I override it here.
|
6
6
|
def to_json(options = nil)
|
7
|
-
|
7
|
+
Oj.dump(to_s)
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
+
class ActiveRecord::Relation
|
12
|
+
|
13
|
+
# Override original method.
|
14
|
+
# becasue it trigger SystemStackError: stack level too deep when use rails ~> 4.1.0
|
15
|
+
# def as_json(options = nil) #:nodoc:
|
16
|
+
# binding.pry
|
17
|
+
# Json.dump(inspect)
|
18
|
+
# end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
11
22
|
class ActiveRecord::Base
|
12
23
|
|
13
24
|
# dump association can trigger ActiveSupport::JSON::Encoding::CircularReferenceError when use rails ~> 4.0.1
|
@@ -1,15 +1,22 @@
|
|
1
|
-
|
1
|
+
module Rack
|
2
|
+
class SourceRoute
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
4
|
+
def initialize(app, opts={})
|
5
|
+
@opts = opts
|
6
|
+
if @opts.present?
|
7
|
+
::SourceRoute.enable do
|
8
|
+
# defined_class 'Cors'
|
9
|
+
# method_id opts[:method_id] # will crashed
|
10
|
+
method_id 'resource_for_path'
|
11
|
+
full_feature
|
12
|
+
end
|
13
|
+
end
|
14
|
+
@app = app
|
6
15
|
end
|
7
16
|
|
8
|
-
|
9
|
-
|
17
|
+
def call(env)
|
18
|
+
@app.call(env)
|
19
|
+
end
|
10
20
|
|
11
|
-
def call(env)
|
12
|
-
SourceRoute.output_html
|
13
|
-
@app.call(env)
|
14
21
|
end
|
15
22
|
end
|
@@ -22,7 +22,11 @@ module SourceRoute
|
|
22
22
|
def positives_check(tp)
|
23
23
|
return true if cond.positives == {}
|
24
24
|
cond.positives.any? do |method_key, value|
|
25
|
-
|
25
|
+
if method_key.to_sym == :defined_class
|
26
|
+
tp.send(method_key).name =~ Regexp.new(value)
|
27
|
+
else
|
28
|
+
tp.send(method_key).to_s =~ Regexp.new(value)
|
29
|
+
end
|
26
30
|
end
|
27
31
|
end
|
28
32
|
|
@@ -41,8 +41,8 @@ module SourceRoute
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def ==(other)
|
44
|
-
tp_self_refer == other.tp_self_refer and
|
45
|
-
defined_class == other.defined_class
|
44
|
+
tp_self_refer == other.tp_self_refer and # path == other.path and lineno == other.lineno
|
45
|
+
method_id == other.method_id and defined_class == other.defined_class
|
46
46
|
end
|
47
47
|
|
48
48
|
def matched?
|
@@ -62,12 +62,18 @@ module SourceRoute
|
|
62
62
|
memo[k.to_s] = send(k)
|
63
63
|
memo
|
64
64
|
end
|
65
|
+
|
65
66
|
if SourceRoute.proxy.config.event.include?(:return)
|
66
67
|
ret_hash['return_value'] = return_value.nil? ? return_value.inspect : return_value
|
67
68
|
end
|
69
|
+
|
68
70
|
(INNER_ATTRS + CUSTOM_ATTRS).each do |k|
|
69
71
|
ret_hash[k.to_s] = send(k) if send(k)
|
70
72
|
end
|
73
|
+
ret_hash['return_value_class'] = ret_hash['return_value'].class.name
|
74
|
+
ret_hash['params_var_class'] = ret_hash['params_var'].class.name if ret_hash['params_var']
|
75
|
+
ret_hash['local_var_class'] = ret_hash['local_var'].class.name if ret_hash['local_var']
|
76
|
+
ret_hash['instance_var_class'] = ret_hash['instance_var'].class.name if ret_hash['instance_var']
|
71
77
|
ret_hash
|
72
78
|
end
|
73
79
|
|
data/lib/source_route/version.rb
CHANGED
data/source_route.gemspec
CHANGED
data/test/sample_app.rb
CHANGED
@@ -4,6 +4,7 @@ class SampleApp
|
|
4
4
|
|
5
5
|
def initialize(sample=nil)
|
6
6
|
@sample = sample if sample
|
7
|
+
@ret_obj = {temp: 'testing'}
|
7
8
|
end
|
8
9
|
|
9
10
|
def nonsense
|
@@ -22,6 +23,18 @@ class SampleApp
|
|
22
23
|
CoolApp.new.foo
|
23
24
|
end
|
24
25
|
|
26
|
+
# todo:
|
27
|
+
# this method should return 25
|
28
|
+
# but the tracer may return nil, need test confirm
|
29
|
+
def method_return_from_loop
|
30
|
+
(1..10).each do |n|
|
31
|
+
if n == 5
|
32
|
+
return 5 * 5
|
33
|
+
end
|
34
|
+
end
|
35
|
+
nil
|
36
|
+
end
|
37
|
+
|
25
38
|
class CoolApp
|
26
39
|
def initialize
|
27
40
|
@cool = ['test', 'data']
|
@@ -36,4 +49,14 @@ class SampleApp
|
|
36
49
|
@cool_ins_after = 'will shown in result?'
|
37
50
|
end
|
38
51
|
end
|
52
|
+
|
53
|
+
class RetObj
|
54
|
+
|
55
|
+
def initialize
|
56
|
+
end
|
57
|
+
|
58
|
+
def source_route_display
|
59
|
+
{temp: 'testing'}
|
60
|
+
end
|
61
|
+
end
|
39
62
|
end
|
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.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- raykin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: awesome_print
|
@@ -38,20 +38,6 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: multi_json
|
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'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: oj
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -201,6 +187,7 @@ files:
|
|
201
187
|
- lib/source_route/core_ext.rb
|
202
188
|
- lib/source_route/formats/html.rb
|
203
189
|
- lib/source_route/formats/html_semantic.slim
|
190
|
+
- lib/source_route/formats/html_semantic.slim.failtry
|
204
191
|
- lib/source_route/generate_result.rb
|
205
192
|
- lib/source_route/json_overrides/activerecord_associations_association.rb
|
206
193
|
- lib/source_route/jsonify.rb
|
@@ -238,7 +225,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
238
225
|
version: '0'
|
239
226
|
requirements: []
|
240
227
|
rubyforge_project:
|
241
|
-
rubygems_version: 2.
|
228
|
+
rubygems_version: 2.2.2
|
242
229
|
signing_key:
|
243
230
|
specification_version: 4
|
244
231
|
summary: Wrapper of TracePoint.
|