Class: Zine::UploaderAWS

Inherits:
Object
  • Object
show all
Defined in:
lib/zine/uploader_aws.rb

Overview

Deploy changes to an AWS S3 bucket and invalidate the Cloudfront cache

Instance Method Summary collapse

Constructor Details

#initialize(build_dir, options, credentials, delete_file_array, upload_file_array) ⇒ UploaderAWS

Returns a new instance of UploaderAWS.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/zine/uploader_aws.rb', line 12

def initialize(build_dir, options, credentials, delete_file_array,
               upload_file_array)
  return unless options['method'] == 'aws'

  @build_dir = build_dir
  ENV['AWS_REGION'], @bucket_name = options['host'].split(':')
  @path = options['path_or_repo']
  @cf_distribution_id = options['cloudfront_distrib']

  @verbose = options['verbose']
  store_credentials credentials
  @delete_file_array = Set.new(delete_file_array).to_a
  @upload_file_array = Set.new(upload_file_array).to_a

  @s3 = Aws::S3::Client.new
  @cf = Aws::CloudFront::Client.new
end

Instance Method Details

#uploadObject



30
31
32
33
34
35
36
# File 'lib/zine/uploader_aws.rb', line 30

def upload
  delete
  deploy
  invalidate
rescue Aws::S3::Errors::ServiceError => e
  puts Rainbow("S3 error: #{e}").red
end