Sha256: 9012669255504d4715c544b0c0ebf56d0d785aa3f01c33aa17a386681e00a41f

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

require 'rubygems'
require 'open-uri'
require 'cgi'
require 'yaml'
require 'json'
require 'nokogiri'
require 'mechanize'
require 'highline/import'
require 'logger'
require 'active_support'
require 'active_model'

this = File.dirname(__FILE__)
require "#{this}/ext"
Dir["#{this}/ubiquitously/mixins/*"].each { |c| require c }
require "#{this}/ubiquitously/base"

module Ubiquitously
  class SettingsError < StandardError; end
  class AuthenticationError < StandardError; end
  class DuplicateError < StandardError; end

  class << self
    attr_accessor :config
    
    def configure(value)
      self.config = value.is_a?(String) ? YAML.load_file(value) : value
    end
    
    def key(path)
      result = self.config
      path.to_s.split(".").each { |node| result = result[node.to_s] if result }
      result.to_s
    end
    
    def credentials(service)
      result = key(service)
      unless result && result.has_key?("key") && result.has_key?("secret")
        raise SettingsError.new("Please specify both a key and secret for ':#{service}'")
      end
      result
    end
  end
end

Dir["#{this}/ubiquitously/*"].each { |c| require c unless File.directory?(c) }

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ubiquitously-0.0.1.6 lib/ubiquitously.rb