Sha256: 9f1330cb2d50df1343884859626c1b9ccf6b76b4a1a0533a6a9947ac6d46f97c

Contents?: true

Size: 827 Bytes

Versions: 2

Compression:

Stored size: 827 Bytes

Contents

require 'json'
require 'mixlib/config'
require 'threat_agent/exceptions'
require 'yaml'

module ThreatAgent
  # A class that load's the user's configuration
  #
  # @author Erran Carey <me@errancarey.com>
  class Config
    extend Mixlib::Config
    include ThreatAgent::Exceptions

    # Sets the default configuration options
    configure do |config|
      config[:endpoint] = 'https://www.threatagent.com'
      config[:key] = ENV['THREAT_AGENT_KEY']
      config[:sup] = ENV['THREAT_AGENT_SUP']
      config[:api_version] = 'v1'
    end

    # TODO: Add from_json/from_yaml methods to Mixlib::Config or add them here
=begin
    def self.from_json(file)
      hash = File.exists? ? JSON.parse(file) : {}
    end

    def self.from_yaml(file)
      hash = File.exists? ? YAML.parse(file).to_ruby : {}
    end
=end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
threat_agent-1.0.0.beta.4 lib/threat_agent/config.rb
threat_agent-1.0.0.beta.3 lib/threat_agent/config.rb