class DucksboardReporter::JsonRemote
Attributes
exception[R]
response[R]
Public Class Methods
get(url, options = {})
click to toggle source
# File lib/ducksboard_reporter/json_remote.rb, line 9 def get(url, options = {}) request = Thread.current[:_json_remote_request] = new(url, options) request.get end
new(url, options = {})
click to toggle source
# File lib/ducksboard_reporter/json_remote.rb, line 19 def initialize(url, options = {}) @url = url @connection_timeout = options[:connection_timeout] || options[:timeout] @read_timeout = options[:read_timeout] || options[:timeout] end
request()
click to toggle source
# File lib/ducksboard_reporter/json_remote.rb, line 14 def request Thread.current[:_json_remote_request] end
Public Instance Methods
get()
click to toggle source
# File lib/ducksboard_reporter/json_remote.rb, line 25 def get @exception = nil conn = Faraday.new( url: host_with_scheme_and_port, headers: {accept: "application/json"} ) @response = conn.get(uri.request_uri, request_options) Hashie::Mash.new(JSON.parse(@response.body)) rescue => e @exception = e nil end
Private Instance Methods
host_with_scheme_and_port()
click to toggle source
# File lib/ducksboard_reporter/json_remote.rb, line 40 def host_with_scheme_and_port host = "#{uri.scheme}://#{uri.host}" host << ":#{uri.port}" if uri.port != 80 host end
request_options()
click to toggle source
# File lib/ducksboard_reporter/json_remote.rb, line 50 def request_options options = {} options[:connection_timeout] = @connection_timeout if @connection_timeout options[:read_timeout] = @read_timeout if @read_timeout options end
uri()
click to toggle source
# File lib/ducksboard_reporter/json_remote.rb, line 46 def uri @uri ||= URI.parse(@url) end