class DogWatch::Model::Config
Manages API configuration. Currently handles credential only.
Attributes
api_key[RW]
app_key[RW]
timeout[RW]
Public Class Methods
new(api_key = nil, app_key = nil, timeout = 5)
click to toggle source
@param [String] api_key
@param [String] app_key
@param [Integer] timeout
# File lib/dogwatch/model/config.rb, line 17 def initialize(api_key = nil, app_key = nil, timeout = 5) @api_key = api_key unless api_key.nil? @app_key = app_key unless app_key.nil? @timeout = timeout return unless app_key.nil? || api_key.nil? from_file end
Public Instance Methods
from_file()
click to toggle source
# File lib/dogwatch/model/config.rb, line 26 def from_file begin config_file = IO.read("#{Dir.home}/.dogwatch/credentials") rescue raise('No credentials supplied') end credentials = YAML.load(config_file) @api_key = credentials['api_key'] @app_key = credentials['app_key'] end