Class: SourceRoute::Wrapper
- Inherits:
-
Object
- Object
- SourceRoute::Wrapper
- Includes:
- Singleton
- Defined in:
- lib/source_route/wrapper.rb
Defined Under Namespace
Classes: Condition
Constant Summary collapse
- TRACE_POINT_METHODS =
[:defined_class, :method_id, :path, :lineno]
Instance Attribute Summary collapse
-
#condition ⇒ Object
Returns the value of attribute condition.
-
#output_include_instance_variables ⇒ Object
Returns the value of attribute output_include_instance_variables.
-
#output_include_local_variables ⇒ Object
Returns the value of attribute output_include_local_variables.
-
#tp ⇒ Object
Returns the value of attribute tp.
-
#tp_attrs_results ⇒ Object
Returns the value of attribute tp_attrs_results.
Instance Method Summary collapse
-
#initialize ⇒ Wrapper
constructor
A new instance of Wrapper.
-
#reset ⇒ Object
output_format can be console, html.
- #trace ⇒ Object
Constructor Details
#initialize ⇒ Wrapper
Returns a new instance of Wrapper.
52 53 54 |
# File 'lib/source_route/wrapper.rb', line 52 def initialize reset end |
Instance Attribute Details
#condition ⇒ Object
Returns the value of attribute condition.
8 9 10 |
# File 'lib/source_route/wrapper.rb', line 8 def condition @condition end |
#output_include_instance_variables ⇒ Object
Returns the value of attribute output_include_instance_variables.
9 10 11 |
# File 'lib/source_route/wrapper.rb', line 9 def output_include_instance_variables @output_include_instance_variables end |
#output_include_local_variables ⇒ Object
Returns the value of attribute output_include_local_variables.
9 10 11 |
# File 'lib/source_route/wrapper.rb', line 9 def output_include_local_variables @output_include_local_variables end |
#tp ⇒ Object
Returns the value of attribute tp.
8 9 10 |
# File 'lib/source_route/wrapper.rb', line 8 def tp @tp end |
#tp_attrs_results ⇒ Object
Returns the value of attribute tp_attrs_results.
8 9 10 |
# File 'lib/source_route/wrapper.rb', line 8 def tp_attrs_results @tp_attrs_results end |
Instance Method Details
#reset ⇒ Object
output_format can be console, html
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/source_route/wrapper.rb', line 57 def reset @tp.disable if @tp @condition = Condition.new([:call], {}, {}, { output_format: 'none', selected_attrs: nil, include_local_var: false, include_instance_var: false }) @tp_attrs_results = [] self end |
#trace ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/source_route/wrapper.rb', line 70 def trace # dont wanna init it in tp block, cause tp block could run thousands of times in one cycle trace tp_result = TpResult.new(self) track = TracePoint.new *condition.events do |tp| # todo: it's better to change the break check to condition methods to make more flexible negative_break = condition.negative.any? do |method_key, value| tp.send(method_key).to_s =~ Regexp.new(value) end next if negative_break positive_break = condition.positive.any? do |method_key, value| tp.send(method_key).to_s !~ Regexp.new(value) end next if positive_break unless condition[:result_config][:output_format].is_a? Proc ret_data = tp_result.build(tp) tp_attrs_results.push(ret_data) end tp_result.output(tp) end track.enable self.tp = track track end |