asset_sync 2.8.2 → 2.9.0

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
  SHA256:
3
- metadata.gz: 5897684db35a90b21d8b5e24a262a3d5e38685e0e38df3cbc0f1ba745bff118c
4
- data.tar.gz: 5f82d80aa6ca05cd26cc7f8548c8bd1306ee2686a959565879ce2a731e80b0a3
3
+ metadata.gz: 76d23b058e01eb57bee9ae81d0a64eb9c36a9f46b00d33909ba41f0f19bb1665
4
+ data.tar.gz: d3693e883569e95091090c80a8d0d071e90c7d59f2763d690adf837ab14a5388
5
5
  SHA512:
6
- metadata.gz: 73ac0a4ab2a64cd398783cb3b2b3dd67581e1e09b825453a9284472364161b4035dc98bba8b94bd114fe14ab513e9b73bd306482f1a5c4a73d1281b41e791fd7
7
- data.tar.gz: 05a0c3b718aabf16aa1b355fc249cfbcedc60736a69a80270e2a80546f3cda2ccb1417cc35789bd1af8e6faef9d9aaf622ac89b106341ad11718add86207cdcd
6
+ metadata.gz: 77a8932affc52ed2f4bdedd6e3328ed84ad5442e109959f952cb09aa0414354ab263b8f0a381f678b87c29545668a052767d78ce0b26bd2443f8d80e919e18b3
7
+ data.tar.gz: 52d878bc1cc42e22d171884cb794a6c4479625a7f4184de982b3956e4d614d7d365091ee0273b406f2b81b619a093d747c1464b7b81beab1f96791536e817836
@@ -14,7 +14,6 @@ rvm:
14
14
  - jruby
15
15
  - jruby-head
16
16
  gemfile:
17
- - gemfiles/rails_4_2.gemfile
18
17
  - gemfiles/rails_5_0.gemfile
19
18
  - gemfiles/rails_5_1.gemfile
20
19
  - gemfiles/rails_5_2.gemfile
@@ -33,16 +32,6 @@ env:
33
32
  matrix:
34
33
  fast_finish: true
35
34
  allow_failures:
36
- # bundler version conflict
37
- - rvm: 2.3
38
- gemfile: gemfiles/rails_4_2.gemfile
39
- - rvm: 2.4
40
- gemfile: gemfiles/rails_4_2.gemfile
41
- - rvm: 2.5
42
- gemfile: gemfiles/rails_4_2.gemfile
43
- - rvm: jruby
44
- gemfile: gemfiles/rails_4_2.gemfile
45
- - gemfile: gemfiles/rails_6_0.gemfile
46
35
  - rvm: ruby-head
47
36
  - rvm: jruby-head
48
37
  exclude:
data/Appraisals CHANGED
@@ -1,8 +1,4 @@
1
1
 
2
- appraise "rails_4_2" do
3
- gem "rails", "~> 4.2.0"
4
- end
5
-
6
2
  appraise "rails_5_0" do
7
3
  gem "rails", "~> 5.0.0"
8
4
  end
@@ -16,5 +12,5 @@ appraise "rails_5_2" do
16
12
  end
17
13
 
18
14
  appraise "rails_6_0" do
19
- gem "rails", "~> 6.0.0.beta1"
15
+ gem "rails", "~> 6.0.0"
20
16
  end
@@ -18,6 +18,14 @@ This project adheres to [Semantic Versioning](http://semver.org/).
18
18
  - Nothing
19
19
 
20
20
 
21
+ ## [2.9.0] - 2020-01-15
22
+
23
+ ### Added
24
+
25
+ - Add option `concurrent_uploads` to improve speed of uploading
26
+ (https://github.com/AssetSync/asset_sync/pull/393)
27
+
28
+
21
29
  ## [2.8.2] - 2019-12-27
22
30
 
23
31
  ### Changed
@@ -930,7 +938,8 @@ Changes:
930
938
  * Merge branch 'sinatra'
931
939
 
932
940
 
933
- [Unreleased]: https://github.com/AssetSync/asset_sync/compare/v2.8.2...HEAD
941
+ [Unreleased]: https://github.com/AssetSync/asset_sync/compare/v2.9.0...HEAD
942
+ [2.9.0]: https://github.com/AssetSync/asset_sync/compare/v2.8.2...v2.9.0
934
943
  [2.8.2]: https://github.com/AssetSync/asset_sync/compare/v2.8.1...v2.8.2
935
944
  [2.8.1]: https://github.com/AssetSync/asset_sync/compare/v2.8.0...v2.8.1
936
945
  [2.8.0]: https://github.com/AssetSync/asset_sync/compare/v2.7.0...v2.8.0
data/README.md CHANGED
@@ -141,7 +141,7 @@ The Built-in Initializer will configure **AssetSync** based on the contents of y
141
141
 
142
142
  Add your configuration details to **heroku**
143
143
 
144
- ​``` bash
144
+ ``` bash
145
145
  heroku config:add AWS_ACCESS_KEY_ID=xxxx
146
146
  heroku config:add AWS_SECRET_ACCESS_KEY=xxxx
147
147
  heroku config:add FOG_DIRECTORY=xxxx
@@ -242,6 +242,9 @@ AssetSync.configure do |config|
242
242
  # Upload the manifest file also.
243
243
  # config.include_manifest = false
244
244
  #
245
+ # Upload files concurrently
246
+ # config.concurrent_uploads = false
247
+ #
245
248
  # Fail silently. Useful for environments such as Heroku
246
249
  # config.fail_silently = true
247
250
  #
@@ -338,6 +341,7 @@ AssetSync.config.gzip_compression == ENV['ASSET_SYNC_GZIP_COMPRESSION']
338
341
  * **gzip\_compression**: (`true, false`) when enabled, will automatically replace files that have a gzip compressed equivalent with the compressed version. **default:** `'false'`
339
342
  * **manifest**: (`true, false`) when enabled, will use the `manifest.yml` generated by Rails to get the list of local files to upload. **experimental**. **default:** `'false'`
340
343
  * **include_manifest**: (`true, false`) when enabled, will upload the `manifest.yml` generated by Rails. **default:** `'false'`
344
+ * **concurrent_uploads**: (`true, false`) when enabled, will upload the files in different Threads, this greatly improves the upload speed. **default:** `'false'`
341
345
  * **enabled**: (`true, false`) when false, will disable asset sync. **default:** `'true'` (enabled)
342
346
  * **ignored\_files**: an array of files to ignore e.g. `['ignore_me.js', %r(ignore_some/\d{32}\.css)]` Useful if there are some files that are created dynamically on the server and you don't want to upload on deploy **default**: `[]`
343
347
  * **cache\_asset\_regexps**: an array of files to add cache headers e.g. `['cache_me.js', %r(cache_some\.\d{8}\.css)]` Useful if there are some files that are added to sprockets assets list and need to be set as 'Cacheable' on uploaded server. Only rails compiled regexp is matched internally **default**: `[]`
@@ -26,6 +26,7 @@ module AssetSync
26
26
  attr_accessor :cdn_distribution_id
27
27
  attr_accessor :cache_asset_regexps
28
28
  attr_accessor :include_manifest
29
+ attr_accessor :concurrent_uploads
29
30
  attr_writer :public_path
30
31
 
31
32
  # FOG configuration
@@ -66,6 +67,7 @@ module AssetSync
66
67
  validates :google_storage_access_key_id, :presence => true, :if => :google_interop?
67
68
  validates :google_json_key_location, :presence => true, :if => :google_service_account?
68
69
  validates :google_project, :presence => true, :if => :google_service_account?
70
+ validates :concurrent_uploads, :inclusion => { :in => [true, false] }
69
71
 
70
72
  def initialize
71
73
  self.fog_region = nil
@@ -84,6 +86,7 @@ module AssetSync
84
86
  self.invalidate = []
85
87
  self.cache_asset_regexps = []
86
88
  self.include_manifest = false
89
+ self.concurrent_uploads = false
87
90
  @additional_local_file_paths_procs = []
88
91
 
89
92
  load_yml! if defined?(::Rails) && yml_exists?
@@ -206,6 +209,7 @@ module AssetSync
206
209
  self.cdn_distribution_id = yml['cdn_distribution_id'] if yml.has_key?("cdn_distribution_id")
207
210
  self.cache_asset_regexps = yml['cache_asset_regexps'] if yml.has_key?("cache_asset_regexps")
208
211
  self.include_manifest = yml['include_manifest'] if yml.has_key?("include_manifest")
212
+ self.concurrent_uploads = yml['concurrent_uploads'] if yml.has_key?('concurrent_uploads')
209
213
 
210
214
  self.azure_storage_account_name = yml['azure_storage_account_name'] if yml.has_key?("azure_storage_account_name")
211
215
  self.azure_storage_access_key = yml['azure_storage_access_key'] if yml.has_key?("azure_storage_access_key")
@@ -42,6 +42,7 @@ module AssetSync
42
42
  config.gzip_compression = (ENV['ASSET_SYNC_GZIP_COMPRESSION'] == 'true') if ENV.has_key?('ASSET_SYNC_GZIP_COMPRESSION')
43
43
  config.manifest = (ENV['ASSET_SYNC_MANIFEST'] == 'true') if ENV.has_key?('ASSET_SYNC_MANIFEST')
44
44
  config.include_manifest = (ENV['ASSET_SYNC_INCLUDE_MANIFEST'] == 'true') if ENV.has_key?('ASSET_SYNC_INCLUDE_MANIFEST')
45
+ config.concurrent_uploads = (ENV['ASSET_SYNC_CONCURRENT_UPLOADS'] == 'true') if ENV.has_key?('ASSET_SYNC_CONCURRENT_UPLOADS')
45
46
  end
46
47
 
47
48
  config.prefix = ENV['ASSET_SYNC_PREFIX'] if ENV.has_key?('ASSET_SYNC_PREFIX')
@@ -249,10 +249,20 @@ module AssetSync
249
249
  local_files_to_upload = local_files - ignored_files - remote_files + always_upload_files
250
250
  local_files_to_upload = (local_files_to_upload + get_non_fingerprinted(local_files_to_upload)).uniq
251
251
 
252
- # Upload new files
253
- local_files_to_upload.each do |f|
254
- next unless File.file? "#{path}/#{f}" # Only files.
255
- upload_file f
252
+ if self.config.concurrent_uploads
253
+ threads = ThreadGroup.new
254
+ # Upload new files
255
+ local_files_to_upload.each do |f|
256
+ next unless File.file? "#{path}/#{f}" # Only files.
257
+ threads.add(Thread.new { upload_file f })
258
+ end
259
+ sleep 1 while threads.list.any? # wait for threads to finish uploading
260
+ else
261
+ # Upload new files
262
+ local_files_to_upload.each do |f|
263
+ next unless File.file? "#{path}/#{f}" # Only files.
264
+ upload_file f
265
+ end
256
266
  end
257
267
 
258
268
  if self.config.cdn_distribution_id && files_to_invalidate.any?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AssetSync
4
- VERSION = "2.8.2"
4
+ VERSION = "2.9.0"
5
5
  end
@@ -63,6 +63,9 @@ if defined?(AssetSync)
63
63
  # Upload the manifest file also.
64
64
  # config.include_manifest = false
65
65
  #
66
+ # Upload files concurrently
67
+ # config.concurrent_uploads = false
68
+ #
66
69
  # Fail silently. Useful for environments such as Heroku
67
70
  # config.fail_silently = true
68
71
  #
@@ -54,6 +54,22 @@ describe AssetSync::Storage do
54
54
  storage.upload_files
55
55
  end
56
56
 
57
+ it 'should upload files concurrently if enabled' do
58
+ @config.concurrent_uploads = true
59
+ storage = AssetSync::Storage.new(@config)
60
+
61
+ allow(storage).to receive(:get_local_files).and_return(@local_files)
62
+ allow(storage).to receive(:get_remote_files).and_return(@remote_files)
63
+ allow(File).to receive(:file?).and_return(true) # Pretend they all exist
64
+
65
+ expect(Thread).to receive(:new).exactly(3).times.and_call_original
66
+ (@local_files - @remote_files + storage.always_upload_files).each do |file|
67
+ expect(storage).to receive(:upload_file).with(file)
68
+ end
69
+
70
+ storage.upload_files
71
+ end
72
+
57
73
  it 'should upload updated non-fingerprinted files' do
58
74
  @local_files = [
59
75
  'public/image.png',
@@ -125,7 +141,7 @@ describe AssetSync::Storage do
125
141
  end
126
142
  end
127
143
 
128
- it 'should upload additonal files' do
144
+ it 'should upload additonal files' do
129
145
  @local_files = [
130
146
  'public/image.png',
131
147
  'public/image-82389298328.png',
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asset_sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.2
4
+ version: 2.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Hamilton
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2019-12-27 00:00:00.000000000 Z
14
+ date: 2020-01-15 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: fog-core
@@ -203,7 +203,6 @@ files:
203
203
  - UPGRADING.md
204
204
  - asset_sync.gemspec
205
205
  - docs/heroku.md
206
- - gemfiles/rails_4_2.gemfile
207
206
  - gemfiles/rails_5_0.gemfile
208
207
  - gemfiles/rails_5_1.gemfile
209
208
  - gemfiles/rails_5_2.gemfile
@@ -1,10 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rcov", platforms: :mri_18, group: [:development, :test]
6
- gem "simplecov", platforms: [:jruby, :mri_19, :ruby_19, :mri_20, :rbx], group: [:development, :test], require: false
7
- gem "jruby-openssl", platform: :jruby
8
- gem "rails", "~> 4.2.0"
9
-
10
- gemspec path: "../"