Class: Omnibus::S3Publisher

Inherits:
Publisher show all
Defined in:
lib/omnibus/publishers/s3_publisher.rb

Instance Method Summary collapse

Methods inherited from Publisher

#initialize, #packages, publish

Methods included from Logging

included

Constructor Details

This class inherits a constructor from Omnibus::Publisher

Instance Method Details

#publish(&block) ⇒ Object


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
# File 'lib/omnibus/publishers/s3_publisher.rb', line 19

def publish(&block)
  log.info(log_key) { 'Starting S3 publisher' }
  safe_require('uber-s3')

  packages.each do |package|
    # Make sure the package is good to go!
    log.debug(log_key) { "Validating '#{package.name}'" }
    package.validate!

    # Upload the metadata first
    log.debug(log_key) { "Uploading '#{package..name}'" }
    client.store(key_for(package, package..name), package..to_json,
      access: access_policy,
    )

    # Upload the actual package
    log.info(log_key) { "Uploading '#{package.name}'" }
    client.store(key_for(package, package.name), package.content,
      access: access_policy,
      content_md5: package.[:md5],
    )

    # If a block was given, "yield" the package to the caller
    block.call(package) if block
  end
end