Class: Twin
- Inherits:
-
Object
- Object
- Twin
- Defined in:
- lib/s3twin/twin.rb
Instance Attribute Summary collapse
-
#destination_access_key ⇒ Object
these exist for ironworker compatibility.
-
#destination_bucket ⇒ Object
these exist for ironworker compatibility.
-
#destination_secret_key ⇒ Object
these exist for ironworker compatibility.
-
#source_access_key ⇒ Object
these exist for ironworker compatibility.
-
#source_bucket ⇒ Object
these exist for ironworker compatibility.
-
#source_secret_key ⇒ Object
these exist for ironworker compatibility.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#destination_access_key ⇒ Object
these exist for ironworker compatibility. It should probaby be seperated out to a wrapper.
5 6 7 |
# File 'lib/s3twin/twin.rb', line 5 def destination_access_key @destination_access_key end |
#destination_bucket ⇒ Object
these exist for ironworker compatibility. It should probaby be seperated out to a wrapper.
5 6 7 |
# File 'lib/s3twin/twin.rb', line 5 def destination_bucket @destination_bucket end |
#destination_secret_key ⇒ Object
these exist for ironworker compatibility. It should probaby be seperated out to a wrapper.
5 6 7 |
# File 'lib/s3twin/twin.rb', line 5 def destination_secret_key @destination_secret_key end |
#source_access_key ⇒ Object
these exist for ironworker compatibility. It should probaby be seperated out to a wrapper.
5 6 7 |
# File 'lib/s3twin/twin.rb', line 5 def source_access_key @source_access_key end |
#source_bucket ⇒ Object
these exist for ironworker compatibility. It should probaby be seperated out to a wrapper.
5 6 7 |
# File 'lib/s3twin/twin.rb', line 5 def source_bucket @source_bucket end |
#source_secret_key ⇒ Object
these exist for ironworker compatibility. It should probaby be seperated out to a wrapper.
5 6 7 |
# File 'lib/s3twin/twin.rb', line 5 def source_secret_key @source_secret_key end |
Class Method Details
.go(params) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/s3twin/twin.rb', line 20 def go(params) source_bucket = params['source_bucket'] source_access_key = params['source_access_key'] source_secret_key = params['source_secret_key'] destination_bucket = params['destination_bucket'] destination_access_key = params['destination_access_key'] destination_secret_key = params['destination_secret_key'] puts 'Starting S3Twin run' @source = AWS::S3.new( :access_key_id => source_access_key, :secret_access_key => source_secret_key) @source_bucket = @source.buckets[source_bucket] @destination = AWS::S3.new( :access_key_id => destination_access_key, :secret_access_key => destination_secret_key) @destination_bucket = @destination.buckets[destination_bucket] @source_bucket.objects.each do |obj| dest_key = @destination_bucket.objects[obj.key] unless dest_key.exists? puts "Creating: #{obj.key}" obj.copy_to(dest_key, :acl => public_acl(obj)) else unless etag_match(obj.key,obj.etag) puts "Updating: #{obj.key}" obj.copy_to(dest_key, :acl => public_acl(obj)) else puts "Skipping: #{obj.key}" end end end puts 'Completed S3Twin run' end |
Instance Method Details
#run ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/s3twin/twin.rb', line 6 def run params = { 'source_bucket' => source_bucket, 'source_access_key' => source_access_key, 'source_secret_key' => source_secret_key, 'destination_bucket' => destination_bucket, 'destination_access_key' => destination_access_key, 'destination_secret_key' => destination_secret_key } Twin.go(params) end |