Module: ProductionBreakpoints
- Extended by:
- ProductionBreakpoints
- Included in:
- ProductionBreakpoints
- Defined in:
- lib/ruby-production-breakpoints.rb,
lib/ruby-production-breakpoints/parser.rb,
lib/ruby-production-breakpoints/version.rb,
lib/ruby-production-breakpoints/platform.rb,
lib/ruby-production-breakpoints/configuration.rb,
lib/ruby-production-breakpoints/method_override.rb,
lib/ruby-production-breakpoints/breakpoints/base.rb,
lib/ruby-production-breakpoints/breakpoints/locals.rb,
lib/ruby-production-breakpoints/breakpoints/inspect.rb,
lib/ruby-production-breakpoints/breakpoints/latency.rb,
lib/ruby-production-breakpoints/start_end_line_validator.rb
Defined Under Namespace
Modules: Breakpoints, Platform, StartEndLineValidator
Classes: Configuration, MethodOverride, Parser
Constant Summary
collapse
- VERSION =
The current version of this gem
'0.0.10'
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
#installed_breakpoints ⇒ Object
Returns the value of attribute installed_breakpoints.
19
20
21
|
# File 'lib/ruby-production-breakpoints.rb', line 19
def installed_breakpoints
@installed_breakpoints
end
|
Instance Method Details
#config ⇒ Object
29
30
31
32
33
34
35
|
# File 'lib/ruby-production-breakpoints.rb', line 29
def config
unless defined?(@configuration)
raise NotConfiguredError
end
@configuration
end
|
23
24
25
26
27
|
# File 'lib/ruby-production-breakpoints.rb', line 23
def configure
@configuration = Configuration.new
yield @configuration
@configuration.finish!
end
|
#disable! ⇒ Object
63
64
65
66
67
|
# File 'lib/ruby-production-breakpoints.rb', line 63
def disable!
installed_breakpoints.each do |trace_id, _bp|
disable_breakpoint(trace_id)
end
end
|
#disable_breakpoint(trace_id) ⇒ Object
57
58
59
60
61
|
# File 'lib/ruby-production-breakpoints.rb', line 57
def disable_breakpoint(trace_id)
breakpoint = installed_breakpoints.delete(trace_id)
breakpoint.unload
breakpoint.uninstall
end
|
#install_breakpoint(type, source_file, start_line, end_line, trace_id: 1) ⇒ Object
For now add new types here
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/ruby-production-breakpoints.rb', line 38
def install_breakpoint(type, source_file, start_line, end_line, trace_id: 1)
case type.name
when 'ProductionBreakpoints::Breakpoints::Latency'
when 'ProductionBreakpoints::Breakpoints::Inspect'
when 'ProductionBreakpoints::Breakpoints::Locals'
else
config.logger.error("Unsupported breakpoint type #{type}")
end
breakpoint = type.new(source_file, start_line, end_line, trace_id: trace_id)
installed_breakpoints[trace_id] = breakpoint
puts installed_breakpoints.keys
breakpoint.install
breakpoint.load
end
|
#sync! ⇒ Object
69
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
97
98
|
# File 'lib/ruby-production-breakpoints.rb', line 69
def sync!
config.reload!
desired = config.configured_breakpoints['breakpoints']
desired_trace_ids = desired.map { |bp| bp['trace_id'] }
installed_trace_ids = installed_breakpoints.keys
to_install_tids = desired_trace_ids - installed_trace_ids
to_remove_tids = installed_trace_ids - desired_trace_ids
to_install = desired.select { |bp| to_install_tids.include?(bp['trace_id']) }
puts "Will install #{to_install.size} breakpoints"
puts "Will remove #{to_remove_tids.size} breakpoints"
to_install.each do |bp|
handler = breakpoint_constant_for_type(bp)
unless valid_start_line_end_line?(bp['source_file'], bp['start_line'], bp['end_line'])
msg = <<~MSG
Skipping #{handler} for #{bp['source_file']}. start line and end line do not point to any code on the file.
MSG
config.logger.warn(msg)
next
end
install_breakpoint(handler, bp['source_file'], bp['start_line'], bp['end_line'], trace_id: bp['trace_id'])
end
to_remove_tids.each do |trace_id|
disable_breakpoint(trace_id)
end
end
|