module ActiveSpy
Base
module for the gem
Public Class Methods
configure() { |self| ... }
click to toggle source
@!method self.configure Class method to set the service’s name, host and port.
# File lib/active_spy.rb, line 24 def self.configure Configuration.instance_eval do yield(self) end end
register_service()
click to toggle source
@!method self.register_service Class method to register the service in an event-runner instance.
# File lib/active_spy.rb, line 33 def self.register_service host = ActiveSpy::Configuration.event_host port = ActiveSpy::Configuration.event_port verify_ssl = ActiveSpy::Configuration.event_verify_ssl @base_url = "#{host}:#{port}/services" return if self.service_registered? service = { service: ActiveSpy::Configuration.settings }.to_json params = { headers: { content_type: :json }, method: :post, url: @base_url, payload: service } params[:verify_ssl] = verify_ssl if verify_ssl RestClient::Request.execute(params) end
service_registered?()
click to toggle source
@!method self.service_registered? Check if the service was already registetered in the configured event runner instance.
# File lib/active_spy.rb, line 52 def self.service_registered? name = ActiveSpy::Configuration.name verify_ssl = ActiveSpy::Configuration.event_verify_ssl url = "#{@base_url}/#{name.downcase.gsub(' ', '-').strip}" begin if verify_ssl RestClient::Request.execute(method: :get, url: url, verify_ssl: verify_ssl) else RestClient.get url end rescue RestClient::ResourceNotFound return false else return true end end