Sha256: 63d694dfe4fd6c0aacc5f07f53fe5d0c2ea27bc1da9217d7d5dee2d2104c8d21

Contents?: true

Size: 1.38 KB

Versions: 1

Compression:

Stored size: 1.38 KB

Contents

require 'active_record'
require 'active_support'
require 'fog'

module CropDuster

  class << self
    def db=(url)
      db_url  = URI.parse(url)
      options = (db_url.query || "").split(/\&/).inject({}) { |hash, s| hash[s.split(/=/)[0].to_sym] = s.split(/=/)[1]; hash }

      config_hash = {
        adapter: db_url.scheme,
        host: db_url.host,
        port: db_url.port,
        database: db_url.path.gsub(/^\//, ''),
        username: db_url.user,
        password: db_url.password
      }

      config_hash.delete_if { |k, v| v.nil? }

      ActiveRecord::Base.establish_connection config_hash.merge(options)
    end

    def aws_secret=(string)
      @aws_secret = string
    end

    def aws_key=(string)
      @aws_key = string
    end

    def aws_keys
      {:provider => 'AWS', :aws_access_key_id => @aws_key, :aws_secret_access_key => @aws_secret}
    end

    def aws_billing_bucket=(string)
      @aws_billing_bucket = string
    end

    def aws_billing_bucket
      @aws_billing_bucket
    end

    def configure(&block)
      block.call(self)
    end
  end
end

Dir.new(File.join(File.dirname(__FILE__), "models")).each do |file|
  next if file =~ /^\./
  require File.join(File.dirname(__FILE__), "models", file)
end

Dir.new(File.join(File.dirname(__FILE__), "crop_duster")).each do |file|
  next if file =~ /^\./
  require File.join(File.dirname(__FILE__), "crop_duster", file)
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
crop-duster-0.0.7 lib/crop_duster.rb