class EbDeployer::Package
Public Class Methods
new(file, bucket_name, s3_driver)
click to toggle source
# File lib/eb_deployer/package.rb, line 3 def initialize(file, bucket_name, s3_driver) @file, @bucket_name = file, bucket_name @s3 = s3_driver end
Public Instance Methods
source_bundle()
click to toggle source
# File lib/eb_deployer/package.rb, line 13 def source_bundle { :s3_bucket => @bucket_name, :s3_key => s3_path } end
upload()
click to toggle source
# File lib/eb_deployer/package.rb, line 8 def upload ensure_bucket(@bucket_name) upload_if_not_exists(@file, @bucket_name) end
Private Instance Methods
ensure_bucket(bucket_name)
click to toggle source
# File lib/eb_deployer/package.rb, line 23 def ensure_bucket(bucket_name) @s3.create_bucket(@bucket_name) unless @s3.bucket_exists?(@bucket_name) end
log(message)
click to toggle source
# File lib/eb_deployer/package.rb, line 35 def log(message) puts "[#{Time.now.utc}][package:#{File.basename(@file)}] #{message}" end
s3_path()
click to toggle source
# File lib/eb_deployer/package.rb, line 19 def s3_path @_s3_path ||= Digest::MD5.file(@file).hexdigest + "-" + File.basename(@file) end
upload_if_not_exists(file, bucket_name)
click to toggle source
# File lib/eb_deployer/package.rb, line 27 def upload_if_not_exists(file, bucket_name) if @s3.object_length(@bucket_name, s3_path) != File.size(file) log("start uploading to s3 bucket #{@bucket_name}...") @s3.upload_file(@bucket_name, s3_path, file) log("uploading finished") end end