Class: ProductionBreakpoints::Breakpoints::Base
- Inherits:
-
Object
- Object
- ProductionBreakpoints::Breakpoints::Base
- Defined in:
- lib/ruby-production-breakpoints/breakpoints/base.rb
Constant Summary collapse
- TRACEPOINT_TYPES =
[].freeze
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#provider_name ⇒ Object
readonly
Returns the value of attribute provider_name.
-
#tracepoint ⇒ Object
readonly
Returns the value of attribute tracepoint.
Instance Method Summary collapse
-
#handle(caller_binding) ⇒ Object
Allows for specific handling of the selected lines.
-
#initialize(source_file, start_line, end_line, trace_id: 1) ⇒ Base
constructor
A new instance of Base.
- #install ⇒ Object
- #load ⇒ Object
- #resume(caller_binding) ⇒ Object
-
#uninstall ⇒ Object
FIXME: saftey if already uninstalled.
- #unload ⇒ Object
Constructor Details
#initialize(source_file, start_line, end_line, trace_id: 1) ⇒ Base
Returns a new instance of Base.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/ruby-production-breakpoints/breakpoints/base.rb', line 13 def initialize(source_file, start_line, end_line, trace_id: 1) @injector_module = nil @source_file = source_file @start_line = start_line @end_line = end_line @trace_id = trace_id @method = self.class.name.split('::').last.downcase @parser = ProductionBreakpoints::Parser.new(@source_file) @node = @parser.find_definition_node(@start_line, @end_line) @method_override = ProductionBreakpoints::MethodOverride.new(@parser, start_line, end_line) @ns = Object.const_get(@parser.find_definition_namespace(@node)) # FIXME: error handling, if not found @provider_name = File.basename(@source_file).gsub('.', '_') @name = "#{@method}_#{@trace_id}" @tracepoint = StaticTracing::Tracepoint.new(@provider_name, @name, *self.class.const_get('TRACEPOINT_TYPES')) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/ruby-production-breakpoints/breakpoints/base.rb', line 11 def name @name end |
#provider_name ⇒ Object (readonly)
Returns the value of attribute provider_name.
11 12 13 |
# File 'lib/ruby-production-breakpoints/breakpoints/base.rb', line 11 def provider_name @provider_name end |
#tracepoint ⇒ Object (readonly)
Returns the value of attribute tracepoint.
11 12 13 |
# File 'lib/ruby-production-breakpoints/breakpoints/base.rb', line 11 def tracepoint @tracepoint end |
Instance Method Details
#handle(caller_binding) ⇒ Object
Allows for specific handling of the selected lines
49 50 51 |
# File 'lib/ruby-production-breakpoints/breakpoints/base.rb', line 49 def handle(caller_binding) eval(@method_override.handler_src.join, caller_binding) end |
#install ⇒ Object
29 30 31 32 |
# File 'lib/ruby-production-breakpoints/breakpoints/base.rb', line 29 def install @injector_module = build_redefined_definition_module(@node) @ns.prepend(@injector_module) end |
#load ⇒ Object
40 41 42 |
# File 'lib/ruby-production-breakpoints/breakpoints/base.rb', line 40 def load @tracepoint.provider.enable end |
#resume(caller_binding) ⇒ Object
53 54 55 |
# File 'lib/ruby-production-breakpoints/breakpoints/base.rb', line 53 def resume(caller_binding) eval(@method_override.resume_src.join, caller_binding) if @method_override.resume_src end |
#uninstall ⇒ Object
FIXME: saftey if already uninstalled
35 36 37 38 |
# File 'lib/ruby-production-breakpoints/breakpoints/base.rb', line 35 def uninstall @ns.instance_eval { unprepend(@injector_module) } @injector_module = nil end |
#unload ⇒ Object
44 45 46 |
# File 'lib/ruby-production-breakpoints/breakpoints/base.rb', line 44 def unload @tracepoint.provider.disable end |