Class: Tracekit::LocalUI::Detector
- Inherits:
-
Object
- Object
- Tracekit::LocalUI::Detector
- Defined in:
- lib/tracekit/local_ui/detector.rb
Overview
Detects if TraceKit Local UI is running and provides the endpoint
Instance Method Summary collapse
-
#endpoint ⇒ String?
Gets the Local UI endpoint if it’s running, otherwise nil.
-
#initialize(port = 9999) ⇒ Detector
constructor
A new instance of Detector.
-
#running? ⇒ Boolean
Checks if Local UI is running by attempting a health check.
Constructor Details
#initialize(port = 9999) ⇒ Detector
Returns a new instance of Detector.
9 10 11 |
# File 'lib/tracekit/local_ui/detector.rb', line 9 def initialize(port = 9999) @port = port end |
Instance Method Details
#endpoint ⇒ String?
Gets the Local UI endpoint if it’s running, otherwise nil
25 26 27 |
# File 'lib/tracekit/local_ui/detector.rb', line 25 def endpoint running? ? "http://localhost:#{@port}" : nil end |
#running? ⇒ Boolean
Checks if Local UI is running by attempting a health check
15 16 17 18 19 20 21 |
# File 'lib/tracekit/local_ui/detector.rb', line 15 def running? uri = URI("http://localhost:#{@port}/api/health") response = Net::HTTP.get_response(uri) response.is_a?(Net::HTTPSuccess) rescue StandardError false end |