lib/s3.rb in gridium-1.0.0 vs lib/s3.rb in gridium-1.0.1
- old
+ new
@@ -1,16 +1,15 @@
require 'aws-sdk'
module Gridium
-
class GridiumS3
DELIMITER = "/"
def initialize(project_name, subdirectory_name='screenshots')
Log.debug("initializing GridiumS3 with #{project_name} and #{subdirectory_name}")
- Aws.config.update({ credentials: Aws::Credentials.new(ENV['S3_ACCESS_KEY_ID'], ENV['S3_SECRET_ACCESS_KEY']) ,region: ENV['S3_DEFAULT_REGION']})
+ Aws.config.update({ credentials: Aws::Credentials.new(ENV['S3_ACCESS_KEY_ID'], ENV['S3_SECRET_ACCESS_KEY']) , region: ENV['S3_DEFAULT_REGION']})
_validate_string(project_name)
_validate_string(subdirectory_name)
@project_name = _sanitize_string(project_name)
@subdirectory_name = _sanitize_string(subdirectory_name)
@bucket = Aws::S3::Resource.new().bucket(ENV['S3_ROOT_BUCKET'])
@@ -35,16 +34,16 @@
joined_name
end
def _sanitize_string(input_string)
#remove left/right whitespace, split and join to collapse contiguous white space, replace whitespace and non-period special chars with underscore
- input_string = input_string.strip().split.join(" ").gsub(/[^\w.]/i, '_')
+ input_string = input_string.strip().split.join(" ").gsub(/[^\w.]/i, '_')
input_string
end
def _validate_string(input_string)
- Log.debug("attempting to validate #{input_string} for use as a name")
+ Log.debug("attempting to validate #{input_string} for use as a name")
if input_string.empty? or input_string.strip().empty? then
raise(ArgumentError, "empty and/or whitespace file names are not wanted here.")
end
end
@@ -57,9 +56,9 @@
def _verify_upload(s3_name, local_absolute_path)
upload_size = @bucket.object(s3_name).content_length
local_size = File.size local_absolute_path
Log.debug("file upload verified: #{upload_size == local_size}. upload size is #{upload_size} and local size is #{local_size}")
- upload_size == local_size
+ upload_size == local_size
end
end
end