Sha256: 49dc97553ab7c15d2e506a8ab3a933c48f1b377b69e8fa1ba3747dd674a0e212

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents

require "date"
require "logger"
require "digest"
require "ostruct"
require "multi_mime"
require "rest_client"
require "nightcrawler_swift/version"
require "nightcrawler_swift/exceptions"
require "nightcrawler_swift/command"
require "nightcrawler_swift/connection"
require "nightcrawler_swift/commands/upload"
require "nightcrawler_swift/commands/download"
require "nightcrawler_swift/commands/list"
require "nightcrawler_swift/commands/delete"
require "nightcrawler_swift/commands/sync"
require "nightcrawler_swift/railtie" if defined?(Rails)

module NightcrawlerSwift
  class << self

    attr_accessor :logger
    attr_reader :options, :connection

    def logger
      @logger ||= Logger.new(STDOUT).tap {|l| l.level = Logger::INFO}
    end

    # Hash with:
    # - bucket
    # - tenant_name
    # - username
    # - password
    # - auth_url
    #
    # - max_age (optional, default: nil)
    # - verify_ssl (optional, default: false)
    # - timeout (in seconds. Optional, default: nil)
    #
    def configure opts = {}
      @options = OpenStruct.new({verify_ssl: false}.merge(opts))

      if @options.max_age and not @options.max_age.is_a?(Numeric)
        raise Exceptions::ConfigurationError.new "max_age should be an Integer"
      end

      @connection = Connection.new
    end

    def sync dir_path
      Sync.new.execute(dir_path)
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nightcrawler_swift-0.4.0 lib/nightcrawler_swift.rb