s3simplesync 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 19cd4a8ab623496d2f4c12d0d47919d28e1c819a
4
- data.tar.gz: dbc4251d6a9db92ff8a634518a3a392bdc7f8a18
3
+ metadata.gz: 7b23a20a9f8bca002659951079050bc474f90730
4
+ data.tar.gz: 1168905a958f25feaea4830c886c9f1cd39df78c
5
5
  SHA512:
6
- metadata.gz: d9ceb418c1e1886396268b77fcabbcd537a381ab166025a0f480947aa26f04042f71100823c49785bb2a0dfb9d3898efb89e656b9086d79c7a921a5213a07a3a
7
- data.tar.gz: eed32456c025abfaed244f662e42821d1aad153c18dead83d69c43483af8120f439f89afc8f3a470ece884c8d6a938289be28ade832b09bcc46876619a9ada4a
6
+ metadata.gz: bcd2dd6d50139f009d106e13f5d7be8134d8c31e2a9b716da5ccba41f061b74123a8e70c3db6696c850d3b4b6f7f17415ff5a8df400af83a081506052c30e929
7
+ data.tar.gz: dbcc3fd4b4687fdefb2552b9712c428f2c034239d4c1997304bc5b2f2746624146fd6f09127e01e6f79ff72516832aa2b077648817613884979086d6d7ebe6aa
data/bin/s3sync-download CHANGED
@@ -1,5 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 's3sync'
3
3
 
4
+ s3_path = ARGV[0]
5
+ local_path = ARGV[1]
6
+
4
7
  sync = S3sync::Syncer.new
5
- sync.download(ARGV[0], ARGV[1])
8
+ sync.download(s3_path, local_path)
data/bin/s3sync-full ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ require 's3sync'
3
+
4
+ local_path = ARGV[0]
5
+ s3_path = ARGV[1]
6
+
7
+ sync = S3sync::Syncer.new
8
+ sync.upload(local_path, s3_path)
9
+ sync.download(s3_path, local_path)
data/bin/s3sync-upload CHANGED
@@ -1,5 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 's3sync'
3
3
 
4
+ local_path = ARGV[0]
5
+ s3_path = ARGV[1]
6
+
4
7
  sync = S3sync::Syncer.new
5
- sync.upload(ARGV[0], ARGV[1])
8
+ sync.upload(local_path, s3_path)
data/lib/s3sync/syncer.rb CHANGED
@@ -17,9 +17,9 @@ module S3sync
17
17
  # Yielding the remote s3 files and doing a 2 pass filter
18
18
  # as better performance than computing a diff of 2 complete directory listings
19
19
  local_files = local_files(local_path)
20
- remote_files(bucket_name, folders) do |key,dest|
21
- source = local_files[key]
22
- local_files.delete key if FileDiff::same_file? source, dest
20
+ remote_files(bucket_name, folders) do |s3|
21
+ source = local_files[s3[:key]]
22
+ local_files.delete s3[:key] if FileDiff::same_file? source, dest
23
23
  end
24
24
 
25
25
  local_files.each do |key,item|
@@ -39,11 +39,11 @@ module S3sync
39
39
  # Yielding the remote s3 files and doing a 2 pass filter
40
40
  # as better performance than computing a diff of 2 complete directory listings
41
41
  local_files = local_files(local_path)
42
- remote_files(bucket_name, folders) do |key,source|
43
- next if FileDiff::same_file? source, local_files[key]
44
- destination_file = File.join destination_folder, key
45
- log "#{source[:file].public_url} => #{destination_file}"
46
- s3_download source, destination_file
42
+ remote_files(bucket_name, folders) do |s3|
43
+ next if FileDiff::same_file? s3, local_files[s3[:key]]
44
+ destination_file = File.join destination_folder, s3[:key]
45
+ log "#{s3[:file].public_url} => #{destination_file}"
46
+ s3_download s3, destination_file
47
47
  end
48
48
  log "done"
49
49
  end
@@ -107,14 +107,21 @@ module S3sync
107
107
  results
108
108
  end
109
109
 
110
+ def remote_item(object, relative_path)
111
+ last_modified = Time.parse object.metadata['last_modified'] rescue 0
112
+
113
+ { key:File.join(relative_path),
114
+ last_modified:last_modified,
115
+ content_length:object.content_length,
116
+ file:object }
117
+ end
118
+
110
119
  def remote_files(bucket, folders)
111
120
  objects = @s3.buckets[bucket].objects.with_prefix(File.join(folders))
112
121
  objects.each do |object|
113
- relative_file_name = File.join(object.key.split(/\//).drop folders.length)
114
- last_modified = Time.parse object.metadata['last_modified'] rescue 0
115
- content_length = object.content_length rescue 0
116
- item = { key:relative_file_name, last_modified:last_modified, content_length:content_length, file:object }
117
- yield relative_file_name,item
122
+ relative_path = object.key.split(/\//).drop folders.length
123
+ next if object.content_length.nil? or object.content_length == 0 or relative_path.empty?
124
+ yield remote_item(object, relative_path)
118
125
  end
119
126
  end
120
127
 
@@ -1,3 +1,3 @@
1
1
  module S3sync
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: s3simplesync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Blunden
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-22 00:00:00.000000000 Z
11
+ date: 2014-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -57,6 +57,7 @@ email:
57
57
  - christian.blunden@gmail.com
58
58
  executables:
59
59
  - s3sync-download
60
+ - s3sync-full
60
61
  - s3sync-upload
61
62
  extensions: []
62
63
  extra_rdoc_files: []
@@ -67,6 +68,7 @@ files:
67
68
  - README.md
68
69
  - Rakefile
69
70
  - bin/s3sync-download
71
+ - bin/s3sync-full
70
72
  - bin/s3sync-upload
71
73
  - lib/s3sync.rb
72
74
  - lib/s3sync/file_diff.rb