Class: Automan::S3::Downloader

Inherits:
Base
  • Object
show all
Includes:
Mixins::Utils
Defined in:
lib/automan/s3/downloader.rb

Constant Summary

Constants included from Mixins::AwsCaller

Mixins::AwsCaller::S3_PROTO

Instance Attribute Summary

Attributes inherited from Base

#logger, #wait

Attributes included from Mixins::AwsCaller

#as, #cfn, #eb, #ec, #ec2, #elb, #r53, #rds, #s3

Instance Method Summary collapse

Methods included from Mixins::Utils

#region_from_az

Methods inherited from Base

add_option, #initialize, #log_options, #wait_until

Methods included from Mixins::AwsCaller

#account, #configure_aws, #looks_like_s3_path?, #parse_s3_path, #s3_object_exists?, #s3_read

Constructor Details

This class inherits a constructor from Automan::Base

Instance Method Details

#downloadObject



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/automan/s3/downloader.rb', line 9

def download
  log_options

  logger.info "downloading #{s3file} to #{localfile}"

  bucket, key = parse_s3_path s3file

  File.open(localfile, 'wb') do |file|
    s3.buckets[bucket].objects[key].read do |chunk|
      file.write(chunk)
    end
  end
end

#readObject



23
24
25
26
27
28
29
30
31
# File 'lib/automan/s3/downloader.rb', line 23

def read
  log_options

  logger.info "returning contents of #{s3file} as string"

  bucket, key = parse_s3_path s3file

  s3.buckets[bucket].objects[key].read
end