Sha256: 12c5c613d8b78f6c781b5bc85175e35645b80630de6a19ba150478970032663d
Contents?: true
Size: 934 Bytes
Versions: 3
Compression:
Stored size: 934 Bytes
Contents
require 'yaml' module DogWatch module Model ## # Manages API configuration. Currently handles # credential only. ## class Config attr_accessor :api_key attr_accessor :app_key attr_accessor :timeout # @param [String] api_key # @param [String] app_key # @param [Integer] timeout 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 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 end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
dogwatch-1.2.0 | lib/dogwatch/model/config.rb |
dogwatch-1.1.1 | lib/dogwatch/model/config.rb |
dogwatch-1.1.0 | lib/dogwatch/model/config.rb |