Class: S3MetaSync::Syncer

Inherits:
Object
  • Object
show all
Defined in:
lib/s3_meta_sync/syncer.rb

Constant Summary collapse

DEFAULT_REGION =
"us-east-1"
STAGING_AREA_PREFIX =
"s3ms_"
AWS_PUBLIC_ACCESS =
"public-read"
AWS_PRIVATE_ACCESS =
"private"

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Syncer

Returns a new instance of Syncer.



23
24
25
26
27
28
# File 'lib/s3_meta_sync/syncer.rb', line 23

def initialize(config)
  @config = {
    acl: AWS_PUBLIC_ACCESS,
    region: DEFAULT_REGION
  }.merge(config)
end

Instance Method Details

#sync(source, destination) ⇒ Object

Raises:

  • (ArgumentError)


30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/s3_meta_sync/syncer.rb', line 30

def sync(source, destination)
  raise ArgumentError if source.end_with?("/") or destination.end_with?("/")

  if destination.include?(":")
    @bucket, destination = destination.split(":")
    upload(source, destination)
  else
    if url?(source)
      @bucket = nil
      source = source
    else
      @bucket, source = source.split(":")
    end
    download(source, destination)
  end
end