Module: Ungulate

Defined in:
lib/ungulate.rb,
lib/ungulate/job.rb,
lib/ungulate/server.rb,
lib/ungulate/curl_http.rb,
lib/ungulate/s3_storage.rb,
lib/ungulate/blob_processor.rb,
lib/ungulate/sqs_message_queue.rb,
lib/ungulate/rmagick_version_creator.rb

Defined Under Namespace

Classes: BlobProcessor, Configuration, CurlHttp, FileUpload, Job, MissingConfiguration, RmagickVersionCreator, S3Bucket, S3Storage, Server, SqsMessageQueue

Class Method Summary collapse

Class Method Details

.configurationObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/ungulate.rb', line 17

def self.configuration
  @config ||=
    begin
      config = Configuration.new

      amazon_credentials = lambda {
        {
          :access_key_id => config.access_key_id || ENV['AMAZON_ACCESS_KEY_ID'],
          :secret_access_key => config.secret_access_key || ENV['AMAZON_SECRET_ACCESS_KEY']
        }
      }

      config.queue = lambda {
        SqsMessageQueue.new(
          config.queue_name,
          amazon_credentials.call.merge(:server => config.queue_server)
        )
      }

      config.http = lambda {
        CurlHttp.new
      }

      config.version_creator = lambda {
        RmagickVersionCreator.new(:http => config.http.call)
      }

      config.storage = lambda {
        S3Storage.new(amazon_credentials.call)
      }

      config.blob_processor = lambda {
        BlobProcessor.new(
          :version_creator => config.version_creator.call
        )
      }

      config.job_processor = lambda {
        Job.new(
          :blob_processor => config.blob_processor.call,
          :storage => config.storage.call,
          :http => config.http.call
        )
      }

      config
    end
end

.configure {|configuration| ... } ⇒ Object

Yields:



66
67
68
# File 'lib/ungulate.rb', line 66

def self.configure(&block)
  yield configuration
end