Module: Omniship

Defined in:
lib/omniship/address.rb,
lib/omniship/base.rb,
lib/omniship/carrier.rb,
lib/omniship/contact.rb,
lib/omniship/package.rb,
lib/omniship/version.rb,
lib/omniship/carriers.rb,
lib/omniship/response.rb,
lib/omniship/carriers/ups.rb,
lib/omniship/notification.rb,
lib/omniship/carriers/usps.rb,
lib/omniship/rate_estimate.rb,
lib/omniship/rate_response.rb,
lib/omniship/ship_response.rb,
lib/omniship/carriers/fedex.rb,
lib/omniship/shipment_event.rb,
lib/omniship/tracking_response.rb,
lib/rails/generators/omniship/setup/setup_generator.rb

Overview

:nodoc:

Defined Under Namespace

Modules: Base, Carriers, Generators Classes: Address, Carrier, Contact, Error, FedEx, Notification, Package, RateEstimate, RateResponse, Response, ResponseError, ShipResponse, ShipmentEvent, TrackingResponse, UPS, USPS

Constant Summary collapse

VERSION =
"0.4.7"

Class Method Summary collapse

Class Method Details

.setupObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# 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