source_route 0.1.8 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,46 +1,164 @@
1
1
  module SourceRoute
2
- # delegate to hash
2
+ # what solution is good for summarize attrs that required to be included
3
3
  class TpResult
4
- attr_accessor :core
4
+ # attrs from TracePoint object
5
+ TP_ATTRS = [:event, :defined_class, :event, :lineno, :method_id,
6
+ :path, :raised_exception, :return_value].freeze
7
+ attr_accessor *TP_ATTRS
5
8
 
6
- extend Forwardable
7
- def_delegators :@core, :[], :merge, :merge!, :reject, :has_key?, :values, :[]=
9
+ # attrs generated from TracePoint.binding
10
+ INNER_ATTRS = [:local_var, :instance_var, :params_var].freeze
11
+ attr_accessor *INNER_ATTRS
8
12
 
9
- def initialize(data)
10
- @core = data
13
+ # customized attrs
14
+ CUSTOM_ATTRS = [:order_id, :parent_ids, :direct_child_order_ids,
15
+ :has_return_value, :parent_length, :tp_self_refer].freeze
16
+ attr_accessor *CUSTOM_ATTRS
17
+
18
+ # extend Forwardable
19
+ # def_delegators :@ret_data, :[], :merge, :merge!, :reject, :has_key?, :values, :[]=
20
+
21
+ # The tricky part is
22
+ # cant call @core after trace block finished
23
+ def initialize(tp_ins)
24
+ @tp_ins = tp_ins # it only workable in TracePoint block
25
+ collect_required_data # so this method can only called once
26
+ end
27
+
28
+ def found_opposite
29
+ @opposite_exist = true
30
+ end
31
+
32
+ def locate_opposite?
33
+ @opposite_exist
11
34
  end
12
35
 
13
36
  def return_event?
14
- @core[:event] == :return
37
+ event == :return
15
38
  end
16
39
 
17
40
  def call_event?
18
- @core[:event] == :call
41
+ event == :call
19
42
  end
20
43
 
21
44
  def ==(other)
22
- @core[:tp_self] == other[:tp_self] and @core[:method_id] == other[:method_id] and
23
- @core[:defined_class] == other[:defined_class]
45
+ tp_self_refer == other.tp_self_refer and method_id == other.method_id and
46
+ defined_class == other.defined_class
24
47
  end
25
48
 
26
49
  def matched?
27
- @core[:matched]
50
+ @matched
28
51
  end
29
52
 
30
- def return_assign_call(tp)
31
- @core[:matched] = true
32
- tp[:return_value] = @core[:return_value]
33
- tp[:local_var] = @core[:local_var] if has_key? :local_var
34
- tp[:instance_var] = @core[:instance_var] if has_key? :instance_var
53
+ def return_tp_assign_call_tp(call_tp)
54
+ @matched = true
55
+ call_tp.return_value = return_value
56
+ call_tp.local_var = local_var unless local_var.nil?
57
+ call_tp.instance_var = instance_var unless instance_var.nil?
35
58
  end
36
59
 
60
+ # to_hash
61
+ # why we need wrapper?
62
+ # it's nonsense
63
+ def to_hash
64
+ stringify
65
+ ret_hash = GenerateResult.wanted_attributes(event).inject({}) do |memo, k|
66
+ memo[k.to_s] = send(k)
67
+ memo
68
+ end
69
+ if SourceRoute.wrapper.condition.events.include?(:return)
70
+ ret_hash['return_value'] = return_value.nil? ? return_value.inspect : return_value
71
+ end
72
+ (INNER_ATTRS + CUSTOM_ATTRS).each do |k|
73
+ ret_hash[k.to_s] = send(k) if send(k)
74
+ end
75
+ ret_hash
76
+ end
77
+
78
+ # def stringify
79
+ # # why dup it?
80
+ # # dup_core = ret_data.dup
81
+ # # to_s is safer than inspect
82
+ # # ex: inspect on ActiveRecord_Relation may crash
83
+ # ret_data[:defined_class] = ret_data[:defined_class].to_s if ret_data.has_key?(:defined_class)
84
+ # ret_data[:return_value] = ret_data[:return_value].source_route_display if ret_data.has_key?(:return_value)
85
+ # end
86
+
87
+ # this is a mutable method
88
+ # not a good solution.
89
+ # we should use it on the return hash of method to_hash
37
90
  def stringify
38
- dup_core = @core.dup
39
- # to_s is safer than inspect
40
- # ex: inspect on ActiveRecord_Relation may crash
41
- dup_core[:defined_class] = dup_core[:defined_class].to_s if dup_core.has_key?(:defined_class)
42
- dup_core[:return_value] = dup_core[:return_value].source_route_display if dup_core.has_key?(:return_value)
43
- dup_core
44
- end
45
- end
91
+ if GenerateResult.wanted_attributes(event).include?(:defined_class)
92
+ self.defined_class = defined_class.to_s
93
+ end
94
+ if GenerateResult.wanted_attributes(event).include?(:return_value)
95
+ if return_value.nil? or return_value.is_a? Symbol or
96
+ # ActiveRecord::ConnectionAdapters::Column override method ==
97
+ (return_value.is_a? String and return_value == '')
98
+ self.return_value = return_value.inspect
99
+ else
100
+ self.return_value = return_value.to_s
101
+ end
102
+ end
103
+ self.event = event.to_s
104
+ self.method_id = method_id.to_s
105
+ self
106
+ end
107
+
108
+ def collect_required_data
109
+ get_attrs
110
+ get_self_refer
111
+
112
+ get_local_or_params_var if SourceRoute.wrapper.condition.result_config[:include_local_var]
113
+ get_instance_var if SourceRoute.wrapper.condition.result_config[:include_instance_var] and return_event?
114
+ self
115
+ end
116
+
117
+ # Becare. we cal @tp_ins.event here
118
+ # but in stringify method we jsut call event
119
+ def get_attrs
120
+ attrs_data = GenerateResult.wanted_attributes(
121
+ @tp_ins.event).each do |key|
122
+ if @tp_ins.respond_to?(key)
123
+ send("#{key}=", @tp_ins.send(key))
124
+ end
125
+ end
126
+ end
127
+
128
+ # def get_additional_attributes
129
+ # [:order_id, :parent_ids, :direct_child_order_ids, :parent_length].each do |k|
130
+ # @ret_data[k] = send(k) unless send(k).nil?
131
+ # end
132
+ # end
133
+
134
+ def get_self_refer
135
+ self.tp_self_refer = SourceRoute.wrapper.result_builder.tp_self_caches
136
+ .map(&:__id__).index(@tp_ins.self.__id__)
137
+ end
138
+
139
+ def get_local_or_params_var
140
+ local_var_hash = {}
141
+ # Warn: @tp_ins.binding.eval('local_variables') =! @tp_ins.binding.send('local_variables')
142
+ @tp_ins.binding.eval('local_variables').each do |v|
143
+ # I need comment out why i need source_route_display
144
+ # must be some strange variables require it
145
+ local_var_hash[v] = @tp_ins.binding.local_variable_get(v).source_route_display
146
+ end
147
+ if local_var_hash != {}
148
+ if call_event?
149
+ self.params_var = local_var_hash
150
+ elsif return_event? # what about other event?
151
+ self.local_var = local_var_hash
152
+ end
153
+ end
154
+ end
155
+
156
+ def get_instance_var
157
+ instance_var_hash = {}
158
+ @tp_ins.self.instance_variables.each do |key|
159
+ instance_var_hash[key] = @tp_ins.self.instance_variable_get(key).source_route_display
160
+ end
161
+ self.instance_var = instance_var_hash if instance_var_hash != {}
162
+ end
163
+ end # END TpResult
46
164
  end
@@ -23,9 +23,8 @@ module SourceRoute
23
23
  def import_return_value_to_call_chain
24
24
  call_chain.each do |ctp|
25
25
  matched_return_tp = return_chain.reject(&:matched?).detect {|rtp| rtp == ctp}
26
-
27
26
  unless matched_return_tp.nil?
28
- matched_return_tp.return_assign_call(ctp)
27
+ matched_return_tp.return_tp_assign_call_tp(ctp)
29
28
  end
30
29
  end
31
30
  end
@@ -33,15 +32,17 @@ module SourceRoute
33
32
  def treeize_call_chain
34
33
  init_order_id_and_parent_ids
35
34
  call_chain.each do |tpr|
36
- return_tpr = return_chain.reject { |c| c[:record_parent] }.find do |rtpr|
37
- rtpr[:tp_self] == tpr[:tp_self] and rtpr[:defined_class] == tpr[:defined_class] and rtpr[:method_id] == tpr[:method_id]
38
- end
35
+ # find the return trace point for the call trace point
36
+ return_tpr = return_chain.reject(&:locate_opposite?).find { |rtpr| rtpr == tpr }
37
+ # so trace points between the call trace point and its return trace point
38
+ # are all children of it
39
39
  unless return_tpr.nil?
40
- return_tpr[:record_parent] = true
41
- start_index, end_index = tpr[:order_id], return_tpr[:order_id]
40
+ return_tpr.found_opposite
41
+ start_index, end_index = tpr.order_id, return_tpr.order_id
42
42
  unless end_index == start_index + 1
43
- values_at(start_index+1 ... end_index).select { |tpr| tpr[:event] == :call }.each do |tpr|
44
- tpr[:parent_ids].push start_index
43
+ values_at(start_index+1 ... end_index).select(&:call_event?).each do |ct|
44
+ ct.parent_ids.push start_index
45
+ tpr.direct_child_order_ids.push ct.order_id
45
46
  end
46
47
  end
47
48
  end
@@ -50,42 +51,35 @@ module SourceRoute
50
51
  cal_parent_length
51
52
  end
52
53
 
54
+ # seems not used in html template now 2015.9.17
53
55
  def parent_length_list
54
- call_chain.map { |tp| tp[:parent_length] }.uniq.sort
56
+ call_chain.map { |tp| tp.parent_length }.uniq.sort
55
57
  end
56
58
 
57
- def deep_cloned
58
- chain.map { |r| r.clone }
59
- end
59
+ # def deep_cloned
60
+ # chain.map { |r| r.clone }
61
+ # end
60
62
 
61
- def stringify
62
- deep_cloned.map do |tr|
63
- # to_s is safer than inspect
64
- # ex: inspect on ActiveRecord_Relation may crash
65
- tr[:defined_class] = tr[:defined_class].to_s if tr.has_key?(:defined_class)
66
- if tr.has_key?(:return_value)
67
- if tr[:return_value].nil? or tr[:return_value].is_a? Symbol or
68
- # ActiveRecord::ConnectionAdapters::Column override method ==
69
- (tr[:return_value].is_a? String and tr[:return_value] == '')
70
- tr[:return_value] = tr[:return_value].inspect
71
- else
72
- tr[:return_value] = tr[:return_value].to_s
73
- end
74
- end
75
- tr
76
- end
77
- end
63
+ # def stringify
64
+ # deep_cloned.map do |tr|
65
+ # # to_s is safer than inspect
66
+ # # ex: inspect on ActiveRecord_Relation may crash
67
+ # # should moved to tr object
68
+ # tr.stringify
69
+ # tr
70
+ # end
71
+ # end
78
72
 
79
73
  private
80
74
  def init_order_id_and_parent_ids
81
75
  each_with_index do |tpr, index|
82
- tpr[:order_id], tpr[:parent_ids] = index, []
76
+ tpr.order_id, tpr.parent_ids, tpr.direct_child_order_ids = index, [], []
83
77
  end
84
78
  end
85
79
 
86
80
  def cal_parent_length
87
81
  each do |tpr|
88
- tpr[:parent_length] = tpr[:parent_ids].length
82
+ tpr.parent_length = tpr.parent_ids.length
89
83
  end
90
84
  end
91
85
 
@@ -1,3 +1,3 @@
1
1
  module SourceRoute
2
- VERSION = "0.1.8"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -5,14 +5,11 @@ module SourceRoute
5
5
 
6
6
  TRACE_POINT_METHODS = [:defined_class, :method_id, :path, :lineno]
7
7
 
8
- attr_accessor :condition, :tp
9
- attr_reader :tp_result_chain, :tp_self_caches
10
-
11
- extend Forwardable
12
- def_delegators :@tp_result_chain, :import_return_value_to_call_chain, :treeize_call_chain, :call_chain, :return_chain, :parent_length_list
8
+ attr_accessor :condition, :tp, :result_builder
13
9
 
14
10
  Condition = Struct.new(:events, :negatives, :positive, :result_config) do
15
11
  def initialize(e=[:call], n={}, p={}, r=GenerateResult::Config.new)
12
+ @debug = false
16
13
  super(e, n, p, r)
17
14
  end
18
15
  end
@@ -73,43 +70,42 @@ module SourceRoute
73
70
  def reset
74
71
  @tp.disable if defined? @tp
75
72
  @condition = Condition.new
76
- @tp_result_chain = TpResultChain.new
77
- @tp_self_caches = []
73
+ @result_builder = GenerateResult.new(self)
74
+ GenerateResult.clear_wanted_attributes
78
75
  self
79
76
  end
80
77
 
81
78
  def trace
82
79
  # dont wanna init it in tp block, cause tp block could run thousands of times in one cycle trace
83
- build_result = GenerateResult.new(self)
80
+
84
81
  tp_filter = TpFilter.new(condition)
85
82
 
86
83
  track = TracePoint.new *condition.events do |tp|
87
84
 
88
85
  next if tp_filter.block_it?(tp)
89
86
 
90
- unless condition.result_config.format.is_a? Proc
91
- ret_data = build_result.build(tp)
92
- @tp_result_chain.push(ret_data)
93
- end
94
-
95
- build_result.output(tp)
87
+ # immediate output trace point result
88
+ # here is confused. todo
89
+ # should move tp_result_chain to result generator
90
+ @result_builder.output(tp)
91
+ # if condition.result_config.format == :console
92
+ # ret_data = build_result.build(tp)
93
+ # @tp_result_chain.push(ret_data)
94
+ # build_result.output(tp)
95
+ # elsif condition.result_config.format.is_a? Proc
96
+ # build_result.output(tp)
97
+ # else
98
+ # # why not push the tp to result chain
99
+ # ret_data = build_result.build(tp)
100
+ # @tp_result_chain.push(ret_data)
101
+ # end
96
102
  end
97
103
  track.enable
98
104
  self.tp = track
99
105
  end
100
106
 
101
- def jsonify_events
102
- Oj.dump(@condition.events.map(&:to_s))
103
- end
104
-
105
- def jsonify_tp_result_chain
106
- # puts tp_result_chain.stringify
107
- json_array = tp_result_chain.map { |result| Jsonify.dump(result) }
108
- '[ ' + json_array.join(',') + ' ]'
109
- end
110
-
111
- def jsonify_tp_self_caches
112
- Oj.dump(tp_self_caches.clone.map(&:to_s))
107
+ def tp_result_chain
108
+ result_builder.tp_result_chain
113
109
  end
114
110
  end # END Wrapper
115
111
 
data/lib/source_route.rb CHANGED
@@ -15,6 +15,23 @@ require "source_route/tp_result_chain"
15
15
  require "source_route/tp_filter"
16
16
  require 'source_route/json_overrides/activerecord_associations_association'
17
17
 
18
+ begin
19
+ if Rails
20
+ ActiveSupport.on_load(:after_initialize, yield: true) do
21
+ # make it respond to to_s. IN rails source, almost all of its methods are removed, including to_s.
22
+ module ActiveSupport
23
+ class OptionMerger
24
+ def to_s
25
+ "<#ActiveSupport #{__id__}>"
26
+ end
27
+ end
28
+ end # END ActiveSupport
29
+ end
30
+ end
31
+ rescue NameError
32
+ nil
33
+ end
34
+
18
35
  module SourceRoute
19
36
  extend self
20
37
 
@@ -43,9 +60,8 @@ module SourceRoute
43
60
  wrapper.trace
44
61
  end
45
62
 
46
- # Not implemented. used in irb or pry.
47
63
  def trace(opt, &block)
48
- opt[:output_format] ||= :silence
64
+ opt[:output_format] ||= :test
49
65
  wrapper.reset
50
66
  opt.each do |k, v|
51
67
  wrapper.condition.send(k, v)
@@ -54,24 +70,18 @@ module SourceRoute
54
70
  wrapper.trace
55
71
  yield
56
72
  wrapper.tp.disable
57
- SourceRoute.build_html_output if opt[:output_format].to_sym == :html
73
+ SourceRoute.output_html if opt[:output_format].to_sym == :html
58
74
  end
59
75
 
60
- def build_html_output
76
+ def output_html
61
77
  SourceRoute.disable
62
78
  SourceRoute::Formats::Html.slim_render(wrapper)
63
79
  end
64
80
 
65
- def output_html
66
- build_html_output
67
- end
68
-
69
81
  # Not implement yet
70
82
  class Logger < Logger
71
83
  end
72
- end
73
84
 
74
- module SourceRoute
75
85
  module Formats
76
86
  autoload :Html, 'source_route/formats/html'
77
87
  end
data/source_route.gemspec CHANGED
@@ -23,9 +23,12 @@ Gem::Specification.new do |spec|
23
23
  spec.add_dependency 'multi_json'
24
24
  spec.add_dependency 'oj'
25
25
 
26
- spec.add_development_dependency "bundler", "~> 1.6"
26
+ spec.add_development_dependency "bundler"
27
27
  spec.add_development_dependency "rake"
28
28
  spec.add_development_dependency 'minitest'
29
29
  spec.add_development_dependency 'pry'
30
30
  spec.add_development_dependency 'pry-byebug'
31
+ spec.add_development_dependency 'guard'
32
+ spec.add_development_dependency 'guard-shell'
33
+ spec.add_development_dependency 'guard-livereload'
31
34
  end
@@ -32,10 +32,11 @@ class SourceRouteTest < Minitest::Test
32
32
  def test_show_addtional_attrs
33
33
  SourceRoute.enable 'nonsense' do
34
34
  result_config.show_additional_attrs = :path
35
+ full_feature
35
36
  end
36
37
  SampleApp.new.nonsense
37
38
 
38
- assert_includes @wrapper.tp_result_chain.first[:path], 'test'
39
+ assert_includes @wrapper.tp_result_chain.first.path, 'test'
39
40
  end
40
41
 
41
42
  def test_match_class_name_by_first_parameter
@@ -51,7 +52,7 @@ class SourceRouteTest < Minitest::Test
51
52
  method_id_not 'nonsense'
52
53
  end
53
54
  SampleApp.new.nonsense
54
- refute_includes @wrapper.tp_result_chain.map(&:values).flatten, 'nonsense'
55
+ refute_includes @wrapper.tp_result_chain.map(&:method_id).flatten, 'nonsense'
55
56
  end
56
57
 
57
58
  def test_match_multiple_class_name
@@ -61,15 +62,17 @@ class SourceRouteTest < Minitest::Test
61
62
 
62
63
  SampleApp.new.nonsense
63
64
  assert @wrapper.tp_result_chain.size > 0
64
- assert_equal SampleApp, @wrapper.tp_result_chain.last.core[:defined_class]
65
+ assert_equal SampleApp, @wrapper.tp_result_chain.last.defined_class
65
66
  end
66
67
 
67
68
  def test_source_route_with_one_parameter
68
- @source_route = SourceRoute.enable 'nonsense'
69
+ SourceRoute.enable 'nonsense' do
70
+ output_format :test
71
+ end
69
72
  SampleApp.new.nonsense
70
73
 
71
- ret_value = @wrapper.tp_result_chain.last
72
- assert_equal SampleApp, ret_value[:defined_class]
74
+ ret_tp = @wrapper.tp_result_chain.last
75
+ assert_equal SampleApp, ret_tp.defined_class
73
76
  end
74
77
 
75
78
  def test_wrapper_reset
@@ -83,7 +86,7 @@ class SourceRouteTest < Minitest::Test
83
86
  assert_equal 0, @wrapper.tp_result_chain.size
84
87
  end
85
88
 
86
- def test_source_route_with_block_only
89
+ def test_source_route_with_block
87
90
  paths = []
88
91
  SourceRoute.enable 'nonsense' do
89
92
  SampleApp.new.nonsense
@@ -105,11 +108,11 @@ class SourceRouteTest < Minitest::Test
105
108
  end
106
109
 
107
110
  def test_trace_with_full_feature
108
- SourceRoute.trace method_id: 'nonsense', full_feature: true do
111
+ SourceRoute.trace method_id: 'nonsense', full_feature: 10 do
109
112
  SampleApp.new.nonsense
110
113
  end
111
114
  first_result = @wrapper.tp_result_chain.first
112
- assert_equal first_result[:tp_self], 0
115
+ assert_equal first_result.tp_self_refer, 0
113
116
  end
114
117
 
115
118
  # def test_trace_include_tp_self
@@ -120,12 +123,12 @@ class SourceRouteTest < Minitest::Test
120
123
  # assert @wrapper.tp_self_caches.first.is_a? SampleApp
121
124
  # end
122
125
 
123
- def test_stringify_tp_result_chain
126
+ def test_stringify_tp_result_chain_only
124
127
  SourceRoute.trace method_id: 'nonsense', full_feature: true do
125
128
  SampleApp.new.nonsense
126
129
  end
127
130
  origin_tp_result_chain = @wrapper.tp_result_chain
128
- assert @wrapper.tp_result_chain.stringify.first[:defined_class].is_a? String
131
+ assert @wrapper.tp_result_chain.first.stringify.defined_class.is_a? String
129
132
  assert_equal origin_tp_result_chain, @wrapper.tp_result_chain
130
133
  end
131
134
 
@@ -145,6 +148,7 @@ class SourceRouteTest < Minitest::Test
145
148
  assert_equal 2, @wrapper.tp_result_chain.size
146
149
  end
147
150
 
151
+ # but local var didnt displayed
148
152
  def test_show_local_variables
149
153
  SourceRoute.enable 'nonsense_with_params' do
150
154
  result_config.include_local_var = true
@@ -152,12 +156,8 @@ class SourceRouteTest < Minitest::Test
152
156
  end
153
157
 
154
158
  SampleApp.new.nonsense_with_params(88)
155
- assert_equal 1, @wrapper.tp_result_chain.size
156
159
 
157
160
  ret_value = @wrapper.tp_result_chain.last
158
-
159
- assert_equal 88, ret_value[:local_var][:param1]
160
- assert_equal 'nil', ret_value[:local_var][:param2]
161
161
  end
162
162
 
163
163
  def test_track_local_var_when_event_is_return
@@ -170,33 +170,30 @@ class SourceRouteTest < Minitest::Test
170
170
  assert_equal 1, @wrapper.tp_result_chain.size
171
171
 
172
172
  ret_value_for_return_event = @wrapper.tp_result_chain.last
173
- assert_equal 88, ret_value_for_return_event[:local_var][:param1]
174
- assert_equal 5, ret_value_for_return_event[:local_var][:param2]
173
+ assert_equal 88, ret_value_for_return_event.local_var[:param1]
174
+ assert_equal 5, ret_value_for_return_event.local_var[:param2]
175
175
  end
176
176
 
177
- def test_show_instance_vars
178
- @source_route = SourceRoute.enable 'nonsense' do
177
+ def test_show_instance_vars_only
178
+ SourceRoute.enable 'nonsense' do
179
179
  result_config.include_instance_var = true
180
+ event :call, :return
180
181
  end
181
-
182
182
  SampleApp.new('ins sure').nonsense_with_instance_var
183
183
 
184
- assert_equal 2, @wrapper.tp_result_chain.size
184
+ assert_equal 4, @wrapper.tp_result_chain.size
185
185
  ret_value = @wrapper.tp_result_chain.pop
186
186
 
187
- assert_equal 'ins sure', ret_value[:instance_var][:@sample]
187
+ assert_equal 'ins sure', ret_value.instance_var[:@sample]
188
188
  end
189
189
 
190
- def test_import_return_to_call
190
+ def test_import_return_to_call_only
191
191
  SourceRoute.enable 'SampleApp' do
192
- event :call, :return
193
- result_config.include_instance_var = true
194
- result_config.include_local_var = true
195
- result_config.import_return_to_call = true
192
+ full_feature 10
196
193
  end
197
- SampleApp.new.init_cool_app
198
- @wrapper.import_return_value_to_call_chain
199
- assert @wrapper.call_chain[0].has_key?(:return_value), 'call results should contain return_value'
194
+ SampleApp.new('cool stuff').init_cool_app
195
+ @wrapper.tp_result_chain.import_return_value_to_call_chain
196
+ assert @wrapper.tp_result_chain.call_chain[0].return_value, 'call results should contain return_value'
200
197
  end
201
198
 
202
199
  def test_order_call_sequence
@@ -204,15 +201,18 @@ class SourceRouteTest < Minitest::Test
204
201
  event :call, :return
205
202
  end
206
203
  SampleApp.new.nonsense_with_instance_var
207
- @wrapper.treeize_call_chain
208
- call_results = @wrapper.call_chain
209
204
 
210
- nonsense_call_tp = call_results.find { |tp| tp[:method_id] == :nonsense }
211
- nonsense_with_instance_var_call_tp = call_results.find { |tp| tp[:method_id] == :nonsense_with_instance_var }
205
+ @wrapper.tp_result_chain.treeize_call_chain
206
+ call_results = @wrapper.result_builder.call_chain
212
207
 
213
- assert_equal [nonsense_with_instance_var_call_tp[:order_id]], nonsense_call_tp[:parent_ids]
214
- assert_equal 1, nonsense_call_tp[:parent_length]
215
- assert_equal [0, 1], @wrapper.parent_length_list
208
+ nonsense_call_tp = call_results.find { |tp| tp.method_id == :nonsense }
209
+ nonsense_with_instance_var_call_tp = call_results.find do |tp|
210
+ tp.method_id == :nonsense_with_instance_var
211
+ end
212
+ assert_equal [nonsense_with_instance_var_call_tp.order_id], nonsense_call_tp.parent_ids
213
+ assert_equal 1, nonsense_call_tp.parent_length
214
+ assert_equal [0, 1], @wrapper.result_builder.parent_length_list
215
+ assert_equal [nonsense_call_tp.order_id], nonsense_with_instance_var_call_tp.direct_child_order_ids
216
216
  end
217
217
 
218
218
  # Nothing has tested really when run rake cause ENV['ignore_html_generation'] was set to true
@@ -220,12 +220,8 @@ class SourceRouteTest < Minitest::Test
220
220
  @source_route = SourceRoute.enable do
221
221
  defined_class 'SampleApp'
222
222
  event :call, :return
223
- result_config.include_instance_var = true
224
- result_config.include_local_var = true
225
- result_config.show_additional_attrs = [:path, :lineno]
226
-
223
+ full_feature 10
227
224
  result_config.filename = 'call_and_return_in_sample_app.html'
228
- result_config.import_return_to_call = true
229
225
  end
230
226
 
231
227
  SampleApp.new.init_cool_app
@@ -234,7 +230,7 @@ class SourceRouteTest < Minitest::Test
234
230
  # do nothing. cause it was set to false in Rakefile.
235
231
  # So Run rake test will not generate html file, run ruby -Itest test/source_route.rb will generate output file
236
232
  else
237
- SourceRoute.build_html_output
233
+ SourceRoute.output_html
238
234
  end
239
235
  end
240
236