require 'logger' module SentinelApi class Configuration attr_accessor :uri attr_accessor :level attr_accessor :method attr_accessor :project_name DEFAULT_URI = (ENV['SENTINEL_API_URI'] || 'http://localhost:3000/reports').freeze DEFAULT_METHOD = (ENV['SENTINEL_API_METHOD'] || 'post').freeze DEFAULT_PROJECT_NAME = "Sentinel Project".freeze def initialize @uri = DEFAULT_URI @method = DEFAULT_METHOD @project_name = DEFAULT_PROJECT_NAME end def merge(options) new_configuration = clone new_configuration.merge!(options) new_configuration end def merge!(options) options.each do |name, value| variable_name = "@#{name}" next unless instance_variable_defined?(variable_name) instance_variable_set(variable_name, value) end self end def default_logger @default_logger ||= defined?(::Rails.logger) ? ::Rails.logger : ::Logger.new(STDERR) end def use_ssl? uri.match(/^https:/) ? true : false end end end