Class: Omnibus::S3Publisher

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

Instance Method Summary collapse

Methods included from S3Helpers

included

Methods inherited from Publisher

#initialize, #packages, publish

Methods included from Logging

included

Methods included from Digestable

#digest, #digest_directory, included

Constructor Details

This class inherits a constructor from Omnibus::Publisher

Instance Method Details

#publish(&block) ⇒ Object



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

def publish(&block)
  log.info(log_key) { "Starting S3 publisher" }

  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}'" }

     = store_object(
      key_for(package, package..name),
      FFI_Yajl::Encoder.encode(package..to_hash, pretty: true),
      nil,
      access_policy
    )

    log.debug(log_key) { "Uploading is completed. Download URL (#{access_policy}): #{.public_url}" }

    # Upload the actual package
    log.info(log_key) { "Uploading '#{package.name}'" }

    s3_object = store_object(
      key_for(package, package.name),
      package.content,
      package.[:md5],
      access_policy
    )

    log.info(log_key) { "Uploading is completed. Download URL (#{access_policy}): #{s3_object.public_url}" }

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