s3_asset_sync 0.1.1 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e8791d286affb173eb4d5e3940e2d31104a134fd
4
- data.tar.gz: 047cc71a9f62d00bdfdffc978b2369a1d35a7331
3
+ metadata.gz: b93f26e50b37759d351f8f0ad7742216c728b35f
4
+ data.tar.gz: 4835790cdc73895fc82fecc4421b44c4cbe93bd4
5
5
  SHA512:
6
- metadata.gz: fad6979d7fd385cc2114471ece7719e935e95a69b1cdc7e9010bfb72fcc11dfbd26523c0dccaa1fa7bade61d3eee086964223d48929e274f44db23e45cf00628
7
- data.tar.gz: 0b71d72e6c543ae1d37c3b426d3259bc5b3b86797a65e78cfb34dffca3b36229b82fd083ce9de3193768296b1a9e2ccb6ba7f6908aca0156e37b2a41078987d7
6
+ metadata.gz: 23203ba04fc4e0b1d693b5ec07bc4d27c536345332d740882ebf782d3fffcf5c1054cdab17abc71be60c35e38aa9cf1c2a7920a506b3a24bbecf26786177136e
7
+ data.tar.gz: 719b5c6ee52fffc8b6e8dd556889e156ccc2ccb148a40b490c0cd0bcd918b99260db33662b12d20ba5a51e73e7627a495278230b23e1b06d7861547f27297742
data/lib/s3_asset_sync.rb CHANGED
@@ -21,15 +21,29 @@ module S3AssetSync
21
21
 
22
22
  s3 = Aws::S3::Client.new
23
23
 
24
- Dir.foreach(Rails.root.join('public','assets')) do |file|
25
- next if file == '.' || file == '..'
26
- puts "SYNC: #{file}"
27
- self.s3_upload_object(s3, file) unless self.s3_object_exists?(s3, file)
28
- end
24
+ self.sync_directory(s3, '')
29
25
 
30
26
  puts "Asset sync successfully completed...".green
31
27
  end
32
28
 
29
+ def self.sync_directory(s3, path)
30
+ assets_dir = Rails.root.join('public','assets')
31
+ current_dir = "#{assets_dir}#{path}"
32
+ Dir.foreach(current_dir) do |file|
33
+ next if file == '.' || file == '..'
34
+ file_path = "#{path}/#{file}"
35
+ file_key = file_path[1..-1]
36
+ full_file_path = "#{assets_dir}#{path}/#{file}"
37
+
38
+ if File.file?(full_file_path)
39
+ puts "SYNC: #{file_path}"
40
+ self.s3_upload_object(s3, file_key) unless self.s3_object_exists?(s3, file_key)
41
+ elsif File.directory?(full_file_path)
42
+ self.sync_directory(s3, file_path)
43
+ end
44
+ end
45
+ end
46
+
33
47
  ##
34
48
  # Loops through specified S3 Bucket and checks to see if the object
35
49
  # exists in our /public/assets folder. Deletes it from the
@@ -89,6 +103,7 @@ module S3AssetSync
89
103
  body: File.open(Rails.root.join('public','assets', key)),
90
104
  key: key
91
105
  )
106
+ puts resp
92
107
  end
93
108
 
94
109
  ##
@@ -1,3 +1,3 @@
1
1
  module S3AssetSync
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -0,0 +1,8 @@
1
+ # Automatically sync assets with S3 after precompilation.
2
+ Rails.application.config.s3_asset_sync.run_after_precompile = true
3
+
4
+ # Configure connection to S3.
5
+ Rails.application.config.s3_asset_sync.s3_bucket = "YOUR_BUCKET_NAME"
6
+ Rails.application.config.s3_asset_sync.s3_region = "YOUR_REGION"
7
+ Rails.application.config.s3_asset_sync.s3_access_key = "YOUR_ACCESS_KEY"
8
+ Rails.application.config.s3_asset_sync.s3_secret_access_key = "YOUR_SECRET_ACCESS_KEY"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: s3_asset_sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neil Turner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-16 00:00:00.000000000 Z
11
+ date: 2015-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -66,6 +66,7 @@ files:
66
66
  - lib/s3_asset_sync/railtie.rb
67
67
  - lib/s3_asset_sync/version.rb
68
68
  - lib/tasks/s3_asset_sync.rake
69
+ - templates/s3_asset_sync.rb
69
70
  homepage: https://github.com/neilturner77/s3_asset_sync
70
71
  licenses:
71
72
  - MIT