Class: Twin
- Inherits:
-
Object
- Object
- Twin
- Defined in:
- lib/s3twin/twin.rb
Instance Attribute Summary collapse
-
#destination_aws_access_key_id ⇒ Object
these exist for ironworker compatibility.
-
#destination_aws_secret_access_key ⇒ Object
these exist for ironworker compatibility.
-
#destination_s3_bucket ⇒ Object
these exist for ironworker compatibility.
-
#source_aws_access_key_id ⇒ Object
these exist for ironworker compatibility.
-
#source_aws_secret_access_key ⇒ Object
these exist for ironworker compatibility.
-
#source_s3_bucket ⇒ Object
these exist for ironworker compatibility.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#destination_aws_access_key_id ⇒ 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_aws_access_key_id @destination_aws_access_key_id end |
#destination_aws_secret_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_aws_secret_access_key @destination_aws_secret_access_key end |
#destination_s3_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_s3_bucket @destination_s3_bucket end |
#source_aws_access_key_id ⇒ 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_aws_access_key_id @source_aws_access_key_id end |
#source_aws_secret_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_aws_secret_access_key @source_aws_secret_access_key end |
#source_s3_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_s3_bucket @source_s3_bucket 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 |
# File 'lib/s3twin/twin.rb', line 20 def go(params) puts 'Starting S3Twin run' @source = AWS::S3.new( :access_key_id => params['source_aws_access_key_id'], :secret_access_key => params['source_aws_secret_access_key']) @source_bucket = @source.buckets[params['source_s3_bucket']] @destination = AWS::S3.new( :access_key_id => params['destination_aws_access_key_id'], :secret_access_key => params['destination_aws_secret_access_key']) @destination_bucket = @destination.buckets[params['destination_s3_bucket']] @source_bucket.objects.each do |obj| dest_key = @destination_bucket.objects[obj.key] begin 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 rescue AWS::S3::Errors::AccessDenied puts "Access Denied: #{obj.key}" 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_s3_bucket' => source_s3_bucket, 'source_aws_access_key_id' => source_aws_access_key_id, 'source_aws_secret_access_key' => source_aws_secret_access_key, 'destination_s3_bucket' => destination_s3_bucket, 'destination_aws_access_key_id' => destination_aws_access_key_id, 'destination_aws_secret_access_key' => destination_aws_secret_access_key } Twin.go(params) end |