Module: Straycall::Target
- Defined in:
- lib/straycall/target.rb
Class Method Summary collapse
- .reporter ⇒ Object
- .start(socket = nil) ⇒ Object
- .start_from_environment ⇒ Object
- .stop ⇒ Object
- .violation? ⇒ Boolean
Class Method Details
.reporter ⇒ Object
16 17 18 |
# File 'lib/straycall/target.rb', line 16 def reporter @reporter end |
.start(socket = nil) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/straycall/target.rb', line 9 def start(socket = nil) socket ||= IO.for_fd(Integer(ENV.fetch("STRAYCALL_REPORT_FD")), autoclose: true) @reporter = Reporter::ThreadReporter.new(socket).start rescue KeyError, ArgumentError nil end |
.start_from_environment ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/straycall/target.rb', line 29 def start_from_environment return unless ENV["STRAYCALL_REPORT_FD"] if ENV["STRAYCALL_REPORT_PID"] && Integer(ENV["STRAYCALL_REPORT_PID"]) != Process.pid IO.for_fd(Integer(ENV["STRAYCALL_REPORT_FD"]), autoclose: true).close return end start rescue ArgumentError, SystemCallError nil end |
.stop ⇒ Object
24 25 26 27 |
# File 'lib/straycall/target.rb', line 24 def stop @reporter&.stop @reporter = nil end |
.violation? ⇒ Boolean
20 21 22 |
# File 'lib/straycall/target.rb', line 20 def violation? @reporter&.violation? || false end |