module Omniship

FedEx module by Donavan White

Constants

VERSION

Public Class Methods

setup() click to toggle source
# File lib/omniship.rb, line 28
def Omniship.setup
  @root   = Rails.root
  if @root
    @boot   = File.join(@root, "config", "boot.rb").freeze
    @config = File.join(@root, "config", "omniship.yml").freeze
    @keys   = %w{ username password key account meter }.map { |v| v.freeze }.freeze
    require boot unless defined? Rails.env
    if File.exists? @config
      @config = YAML.load_file(@config)
      raise "Invalid omniship configuration file: #{@config}" unless @config.is_a?(Hash)
      if (@config.keys & @keys).sort == @keys.sort and !@config.has_key?(Rails.env)
        @config[Rails.env] = {
          "ups"   => @config["ups"],
          "fedex" => @config["fedex"],
          "usps"  => @config["usps"]
        }
      end
      @config[Rails.env].freeze
    end
  end
end