asset_sync 2.4.0 → 2.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/tests.yaml +64 -0
- data/.travis.yml +25 -26
- data/Appraisals +6 -10
- data/CHANGELOG.md +158 -2
- data/README.md +120 -9
- data/asset_sync.gemspec +4 -3
- data/gemfiles/{rails_4_1.gemfile → rails_5_2.gemfile} +1 -1
- data/gemfiles/{rails_4_2.gemfile → rails_6_0.gemfile} +1 -1
- data/gemfiles/{rails_5_0.gemfile → rails_6_1.gemfile} +1 -1
- data/lib/asset_sync/config.rb +150 -12
- data/lib/asset_sync/engine.rb +8 -0
- data/lib/asset_sync/multi_mime.rb +7 -2
- data/lib/asset_sync/storage.rb +81 -20
- data/lib/asset_sync/version.rb +1 -1
- data/lib/generators/asset_sync/install_generator.rb +21 -1
- data/lib/generators/asset_sync/templates/asset_sync.rb +21 -0
- data/lib/generators/asset_sync/templates/asset_sync.yml +20 -1
- data/lib/tasks/asset_sync.rake +3 -1
- data/spec/fixtures/backblaze_with_yml/config/asset_sync.yml +20 -0
- data/spec/fixtures/google_with_service_account_yml/config/asset_sync.yml +19 -0
- data/spec/integration/backblaze_intergration_spec.rb +74 -0
- data/spec/spec_helper.rb +6 -0
- data/spec/unit/asset_sync_spec.rb +35 -3
- data/spec/unit/backblaze_spec.rb +150 -0
- data/spec/unit/google_spec.rb +124 -29
- data/spec/unit/multi_mime_spec.rb +47 -0
- data/spec/unit/railsless_spec.rb +4 -3
- data/spec/unit/storage_spec.rb +150 -7
- metadata +49 -14
- data/gemfiles/rails_5_1.gemfile +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb865a74b05c9a16ce39367906e4b4e98e95aa1ee6513cce217c84bea8a832b6
|
4
|
+
data.tar.gz: 4684411bd7bddcf9daf4e6e9c1ba0b92fbf85cf67f2c9a42825b3c910e151c49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f02951393035ba6db862849187d74f41d49529206d6d8a13b84ccca91b7d7c533fee6f0ea2440ea4b4e35ed72967d2d7489cfb6118c9fb8895e201964f146f64
|
7
|
+
data.tar.gz: 51e1bd03d2acd5a528fa5960ff5986c29303bb8ec03ce643cb57bce30958fc5d1fab981de815459fc9b16eab176a1717ad1873a9b4f08a7659b94f5ed8b7bd5d
|
@@ -0,0 +1,64 @@
|
|
1
|
+
name: Tests
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
paths-ignore:
|
8
|
+
- 'README.md'
|
9
|
+
push:
|
10
|
+
branches:
|
11
|
+
- master
|
12
|
+
paths-ignore:
|
13
|
+
- 'README.md'
|
14
|
+
|
15
|
+
jobs:
|
16
|
+
unit_tests:
|
17
|
+
name: Unit Tests
|
18
|
+
if: "contains(github.event.commits[0].message, '[ci skip]') == false"
|
19
|
+
strategy:
|
20
|
+
fail-fast: false
|
21
|
+
matrix:
|
22
|
+
os:
|
23
|
+
- ubuntu
|
24
|
+
ruby:
|
25
|
+
- 2.5
|
26
|
+
- 2.6
|
27
|
+
- 2.7
|
28
|
+
- 3.0
|
29
|
+
- jruby
|
30
|
+
gemfile:
|
31
|
+
- gemfiles/rails_5_2.gemfile
|
32
|
+
- gemfiles/rails_6_0.gemfile
|
33
|
+
- gemfiles/rails_6_1.gemfile
|
34
|
+
allow_failures:
|
35
|
+
- false
|
36
|
+
include:
|
37
|
+
- os: ubuntu
|
38
|
+
ruby: ruby-head
|
39
|
+
gemfile: gemfiles/rails_6_1.gemfile
|
40
|
+
allow_failures: true
|
41
|
+
- os: ubuntu
|
42
|
+
ruby: jruby-head
|
43
|
+
gemfile: gemfiles/rails_6_1.gemfile
|
44
|
+
allow_failures: true
|
45
|
+
exclude:
|
46
|
+
- os: ubuntu
|
47
|
+
ruby: 3.0
|
48
|
+
gemfile: gemfiles/rails_5_2.gemfile
|
49
|
+
allow_failures: false
|
50
|
+
env:
|
51
|
+
BUNDLE_GEMFILE: "${{ matrix.gemfile }}"
|
52
|
+
ALLOW_FAILURES: "${{ matrix.allow_failures }}"
|
53
|
+
runs-on: ${{ matrix.os }}-latest
|
54
|
+
continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' }}
|
55
|
+
steps:
|
56
|
+
- name: Checkout
|
57
|
+
uses: actions/checkout@v2
|
58
|
+
- name: Setup Ruby
|
59
|
+
uses: ruby/setup-ruby@v1
|
60
|
+
with:
|
61
|
+
ruby-version: ${{ matrix.ruby }}
|
62
|
+
bundler-cache: true
|
63
|
+
- name: Test
|
64
|
+
run: bundle exec rake spec:unit || $ALLOW_FAILURES
|
data/.travis.yml
CHANGED
@@ -1,16 +1,28 @@
|
|
1
|
+
# Send builds to container-based infrastructure
|
2
|
+
# http://docs.travis-ci.com/user/workers/container-based-infrastructure/
|
3
|
+
sudo: false
|
1
4
|
language: ruby
|
5
|
+
arch:
|
6
|
+
- amd64
|
7
|
+
- ppc64le
|
8
|
+
cache:
|
9
|
+
bundler: true
|
2
10
|
rvm:
|
3
|
-
-
|
4
|
-
-
|
5
|
-
-
|
6
|
-
- rbx-2
|
11
|
+
- 2.5
|
12
|
+
- 2.6
|
13
|
+
- 2.7
|
7
14
|
- ruby-head
|
15
|
+
- jruby
|
8
16
|
- jruby-head
|
9
17
|
gemfile:
|
10
|
-
- gemfiles/
|
11
|
-
- gemfiles/
|
18
|
+
- gemfiles/rails_5_2.gemfile
|
19
|
+
- gemfiles/rails_6_0.gemfile
|
20
|
+
- gemfiles/rails_6_1.gemfile
|
12
21
|
before_install:
|
13
|
-
|
22
|
+
# Cannot use bundler 2.x due to dependency (mainly rails 4.2)
|
23
|
+
# Solution from https://github.com/rails/rails/blob/4-2-stable/.travis.yml
|
24
|
+
- "travis_retry gem update --system --no-doc || travis_retry gem update --system --no-rdoc --no-ri"
|
25
|
+
- "travis_retry gem install bundler -v '<2'"
|
14
26
|
env:
|
15
27
|
global:
|
16
28
|
- FOG_DIRECTORY=asset-sync-travis
|
@@ -18,25 +30,12 @@ env:
|
|
18
30
|
- secure: "dy8Fqlg3b1ZMK1BY5z6NMQLbzAVd7GWVYY0MeCQALz76zRac0z8MyU8hkv6h\nozFry7DSdbGehGT9foOnkWTwzGzf1rzdd5cmWrUPk1wDTRgMM9SrwodPj1TU\nzsq2EFx0a79vADQN8JXkpLC1YD6kEb9aWkTxrIT9KBgw+J5H32o="
|
19
31
|
- secure: "Hmx7D7/p2LlA2ya/xBIz21s/8MLIQCjvfYB7RWBNlWk1PfqRLAz8wX6TUVWy\nfAFktMjLnpRLRYO7AgQS4jcfQ/k0HYK9IXzqXzeI00TNm0Vwp0TCXhawiOFT\nSvUMhs2/1vRfjN0HOJ75XlWRhJzV/G5rOMiafAZLsVzN/0iiB8g="
|
20
32
|
matrix:
|
21
|
-
|
22
|
-
- rvm: 1.9.3
|
23
|
-
gemfile: gemfiles/rails_4.0.gemfile
|
24
|
-
- rvm: jruby-19mode
|
25
|
-
gemfile: gemfiles/rails_4.0.gemfile
|
26
|
-
- rvm: rbx-2
|
27
|
-
gemfile: gemfiles/rails_4.0.gemfile
|
28
|
-
- rvm: 2.0.0
|
29
|
-
gemfile: gemfiles/rails_3.2.gemfile
|
30
|
-
- rvm: 2.0.0
|
31
|
-
gemfile: gemfiles/rails_4.0.gemfile
|
32
|
-
- rvm: 2.1.2
|
33
|
-
gemfile: gemfiles/rails_4.1.gemfile
|
34
|
-
- rvm: 2.0.0
|
35
|
-
gemfile: gemfiles/rails_4.1.gemfile
|
36
|
-
- rvm: 2.1.2
|
37
|
-
gemfile: gemfiles/rails_4.1.gemfile
|
33
|
+
fast_finish: true
|
38
34
|
allow_failures:
|
39
|
-
- rvm: 1.9.2
|
40
|
-
- rvm: rbx-2
|
41
35
|
- rvm: ruby-head
|
42
36
|
- rvm: jruby-head
|
37
|
+
notifications:
|
38
|
+
webhooks:
|
39
|
+
urls:
|
40
|
+
- https://www.travisbuddy.com/
|
41
|
+
on_success: never
|
data/Appraisals
CHANGED
@@ -1,16 +1,12 @@
|
|
1
1
|
|
2
|
-
appraise "
|
3
|
-
gem "rails", "~>
|
2
|
+
appraise "rails_5_2" do
|
3
|
+
gem "rails", "~> 5.2.0"
|
4
4
|
end
|
5
5
|
|
6
|
-
appraise "
|
7
|
-
gem "rails", "~>
|
6
|
+
appraise "rails_6_0" do
|
7
|
+
gem "rails", "~> 6.0.0"
|
8
8
|
end
|
9
9
|
|
10
|
-
appraise "
|
11
|
-
gem "rails", "~>
|
12
|
-
end
|
13
|
-
|
14
|
-
appraise "rails_5_1" do
|
15
|
-
gem "rails", "~> 5.1.0"
|
10
|
+
appraise "rails_6_1" do
|
11
|
+
gem "rails", "~> 6.1.0"
|
16
12
|
end
|
data/CHANGELOG.md
CHANGED
@@ -18,6 +18,147 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
18
18
|
- Nothing
|
19
19
|
|
20
20
|
|
21
|
+
## [2.14.0] - 2020-03-31
|
22
|
+
|
23
|
+
### Added
|
24
|
+
|
25
|
+
- Add support for fog option `google_json_key_string`
|
26
|
+
(https://github.com/AssetSync/asset_sync/pull/415)
|
27
|
+
|
28
|
+
|
29
|
+
## [2.13.1] - 2021-03-01
|
30
|
+
|
31
|
+
### Fixed
|
32
|
+
|
33
|
+
- Fix "files to be uploaded list" generation for file names with dashes
|
34
|
+
(https://github.com/AssetSync/asset_sync/pull/414)
|
35
|
+
|
36
|
+
|
37
|
+
## [2.13.0] - 2020-12-14
|
38
|
+
|
39
|
+
### Added
|
40
|
+
|
41
|
+
- Add Backblaze B2 Cloud Storage support
|
42
|
+
(https://github.com/AssetSync/asset_sync/pull/410)
|
43
|
+
|
44
|
+
|
45
|
+
## [2.12.1] - 2020-06-17
|
46
|
+
|
47
|
+
### Fixed
|
48
|
+
|
49
|
+
- Fix initializer template in generator
|
50
|
+
(https://github.com/AssetSync/asset_sync/pull/404)
|
51
|
+
|
52
|
+
|
53
|
+
## [2.12.0] - 2020-06-11
|
54
|
+
|
55
|
+
### Added
|
56
|
+
|
57
|
+
- Add option `aws_session_token` to support AWS Temporary Security Credentials
|
58
|
+
(https://github.com/AssetSync/asset_sync/pull/403)
|
59
|
+
|
60
|
+
|
61
|
+
## [2.11.0] - 2020-03-13
|
62
|
+
|
63
|
+
### Added
|
64
|
+
|
65
|
+
- Add option `remote_file_list_cache_file_path` to skip scanning remote
|
66
|
+
(https://github.com/AssetSync/asset_sync/pull/400)
|
67
|
+
|
68
|
+
|
69
|
+
## [2.10.0] - 2020-02-26
|
70
|
+
|
71
|
+
### Added
|
72
|
+
|
73
|
+
- Add option `concurrent_uploads_max_threads` to limit number of threads for uploading files
|
74
|
+
(https://github.com/AssetSync/asset_sync/pull/398)
|
75
|
+
|
76
|
+
|
77
|
+
## [2.9.1] - 2020-02-20
|
78
|
+
|
79
|
+
### Fixed
|
80
|
+
|
81
|
+
- Fix uploading of sprockets manifest file
|
82
|
+
(https://github.com/AssetSync/asset_sync/pull/397)
|
83
|
+
|
84
|
+
|
85
|
+
## [2.9.0] - 2020-01-15
|
86
|
+
|
87
|
+
### Added
|
88
|
+
|
89
|
+
- Add option `concurrent_uploads` to improve speed of uploading
|
90
|
+
(https://github.com/AssetSync/asset_sync/pull/393)
|
91
|
+
|
92
|
+
|
93
|
+
## [2.8.2] - 2019-12-27
|
94
|
+
|
95
|
+
### Changed
|
96
|
+
|
97
|
+
- Use `delete_multiple_objects` when storage is `aws`
|
98
|
+
(https://github.com/AssetSync/asset_sync/pull/392)
|
99
|
+
|
100
|
+
|
101
|
+
## [2.8.1] - 2019-07-25
|
102
|
+
|
103
|
+
### Changed
|
104
|
+
|
105
|
+
- Removed `rubyforge_project` from gemspec
|
106
|
+
(https://github.com/AssetSync/asset_sync/pull/386)
|
107
|
+
|
108
|
+
### Fixed
|
109
|
+
|
110
|
+
- Fixed when `fog_public` set to `false`, file were still set to be public
|
111
|
+
(https://github.com/AssetSync/asset_sync/pull/387)
|
112
|
+
|
113
|
+
|
114
|
+
## [2.8.0] - 2019-06-17
|
115
|
+
|
116
|
+
### Added
|
117
|
+
|
118
|
+
- Add option `fog_port`
|
119
|
+
(https://github.com/AssetSync/asset_sync/pull/385)
|
120
|
+
|
121
|
+
|
122
|
+
## [2.7.0] - 2019-03-15
|
123
|
+
|
124
|
+
### Added
|
125
|
+
|
126
|
+
- Adds JSON API support when using Google Storage
|
127
|
+
(https://github.com/AssetSync/asset_sync/pull/381)
|
128
|
+
|
129
|
+
### Changed
|
130
|
+
|
131
|
+
- Update `AssetSync::MultiMime.lookup` to always return strings (kind of internal change)
|
132
|
+
(https://github.com/AssetSync/asset_sync/pull/380)
|
133
|
+
|
134
|
+
|
135
|
+
## [2.6.0] - 2018-12-07
|
136
|
+
|
137
|
+
### Added
|
138
|
+
|
139
|
+
- Add option `fog_public`
|
140
|
+
(https://github.com/AssetSync/asset_sync/pull/377)
|
141
|
+
|
142
|
+
|
143
|
+
## [2.5.0] - 2018-10-25
|
144
|
+
|
145
|
+
### Added
|
146
|
+
|
147
|
+
- Add ruby only option `file_ext_to_mime_type_overrides`
|
148
|
+
(https://github.com/AssetSync/asset_sync/pull/374)
|
149
|
+
|
150
|
+
### Changed
|
151
|
+
|
152
|
+
- Start testing against rails 5.2, stop testing against rails 4.1
|
153
|
+
|
154
|
+
### Fixed
|
155
|
+
|
156
|
+
- Only enhance rake task assets:precompile if it's defined
|
157
|
+
(https://github.com/AssetSync/asset_sync/commit/e1eb1a16b06fd39def1759428a2d94733915bbff)
|
158
|
+
- Avoid ruby warning due to "method redefined"
|
159
|
+
(https://github.com/AssetSync/asset_sync/pull/371)
|
160
|
+
|
161
|
+
|
21
162
|
## [2.4.0] - 2017-12-20
|
22
163
|
|
23
164
|
### Added
|
@@ -78,7 +219,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
78
219
|
|
79
220
|
- Only support mime-type >= 2.99,
|
80
221
|
which is released at the end of 2015
|
81
|
-
- Only support
|
222
|
+
- Only support activemodel >= 4.1,
|
82
223
|
which is released in 2014
|
83
224
|
|
84
225
|
|
@@ -861,7 +1002,22 @@ Changes:
|
|
861
1002
|
* Merge branch 'sinatra'
|
862
1003
|
|
863
1004
|
|
864
|
-
[Unreleased]: https://github.com/AssetSync/asset_sync/compare/v2.
|
1005
|
+
[Unreleased]: https://github.com/AssetSync/asset_sync/compare/v2.14.0...HEAD
|
1006
|
+
[2.14.0]: https://github.com/AssetSync/asset_sync/compare/v2.13.1...v2.14.0
|
1007
|
+
[2.13.1]: https://github.com/AssetSync/asset_sync/compare/v2.13.0...v2.13.1
|
1008
|
+
[2.13.0]: https://github.com/AssetSync/asset_sync/compare/v2.12.1...v2.13.0
|
1009
|
+
[2.12.1]: https://github.com/AssetSync/asset_sync/compare/v2.12.0...v2.12.1
|
1010
|
+
[2.12.0]: https://github.com/AssetSync/asset_sync/compare/v2.11.0...v2.12.0
|
1011
|
+
[2.11.0]: https://github.com/AssetSync/asset_sync/compare/v2.10.0...v2.11.0
|
1012
|
+
[2.10.0]: https://github.com/AssetSync/asset_sync/compare/v2.9.1...v2.10.0
|
1013
|
+
[2.9.1]: https://github.com/AssetSync/asset_sync/compare/v2.9.0...v2.9.1
|
1014
|
+
[2.9.0]: https://github.com/AssetSync/asset_sync/compare/v2.8.2...v2.9.0
|
1015
|
+
[2.8.2]: https://github.com/AssetSync/asset_sync/compare/v2.8.1...v2.8.2
|
1016
|
+
[2.8.1]: https://github.com/AssetSync/asset_sync/compare/v2.8.0...v2.8.1
|
1017
|
+
[2.8.0]: https://github.com/AssetSync/asset_sync/compare/v2.7.0...v2.8.0
|
1018
|
+
[2.7.0]: https://github.com/AssetSync/asset_sync/compare/v2.6.0...v2.7.0
|
1019
|
+
[2.6.0]: https://github.com/AssetSync/asset_sync/compare/v2.5.0...v2.6.0
|
1020
|
+
[2.5.0]: https://github.com/AssetSync/asset_sync/compare/v2.4.0...v2.5.0
|
865
1021
|
[2.4.0]: https://github.com/AssetSync/asset_sync/compare/v2.3.0...v2.4.0
|
866
1022
|
[2.3.0]: https://github.com/AssetSync/asset_sync/compare/v2.2.0...v2.3.0
|
867
1023
|
[2.2.0]: https://github.com/AssetSync/asset_sync/compare/v2.1.0...v2.2.0
|
data/README.md
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
|
2
2
|
[![Gem Version](https://img.shields.io/gem/v/asset_sync.svg?style=flat-square)](http://badge.fury.io/rb/asset_sync)
|
3
|
-
[![Build Status](https://img.shields.io/travis/
|
4
|
-
[![
|
5
|
-
|
6
|
-
(Build Status is broken as expected until Travis is fixed by AssetSync organization owner)
|
3
|
+
[![Build Status](https://img.shields.io/travis/AssetSync/asset_sync.svg?style=flat-square)](http://travis-ci.org/AssetSync/asset_sync)
|
4
|
+
[![Coverage Status](http://img.shields.io/coveralls/AssetSync/asset_sync.svg?style=flat-square)](https://coveralls.io/r/AssetSync/asset_sync)
|
7
5
|
|
8
6
|
|
9
7
|
# Asset Sync
|
@@ -40,6 +38,13 @@ gem "asset_sync"
|
|
40
38
|
gem "fog-azure-rm"
|
41
39
|
```
|
42
40
|
|
41
|
+
To use Backblaze B2, insert these.
|
42
|
+
|
43
|
+
``` ruby
|
44
|
+
gem "asset_sync"
|
45
|
+
gem "fog-backblaze"
|
46
|
+
```
|
47
|
+
|
43
48
|
|
44
49
|
### Extended Installation (Faster sync with turbosprockets)
|
45
50
|
|
@@ -79,6 +84,13 @@ Or, to use Azure Blob storage, configure as this.
|
|
79
84
|
config.action_controller.asset_host = "//#{ENV['AZURE_STORAGE_ACCOUNT_NAME']}.blob.core.windows.net/#{ENV['FOG_DIRECTORY']}"
|
80
85
|
```
|
81
86
|
|
87
|
+
Or, to use Backblaze B2, configure as this.
|
88
|
+
|
89
|
+
``` ruby
|
90
|
+
#config/environments/production.rb
|
91
|
+
config.action_controller.asset_host = "//f000.backblazeb2.com/file/#{ENV['FOG_DIRECTORY']}"
|
92
|
+
```
|
93
|
+
|
82
94
|
|
83
95
|
On **HTTPS**: the exclusion of any protocol in the asset host declaration above will allow browsers to choose the transport mechanism on the fly. So if your application is available under both HTTP and HTTPS the assets will be served to match.
|
84
96
|
|
@@ -105,10 +117,10 @@ On **non default S3 bucket region**: If your bucket is set to a region that is n
|
|
105
117
|
|
106
118
|
If you wish to have your assets sync to a sub-folder of your bucket instead of into the root add the following to your ``production.rb`` file
|
107
119
|
|
108
|
-
```ruby
|
120
|
+
``` ruby
|
109
121
|
# store assets in a 'folder' instead of bucket root
|
110
122
|
config.assets.prefix = "/production/assets"
|
111
|
-
|
123
|
+
```
|
112
124
|
|
113
125
|
Also, ensure the following are defined (in production.rb or application.rb)
|
114
126
|
|
@@ -123,7 +135,7 @@ Additionally, if you depend on any configuration that is setup in your `initiali
|
|
123
135
|
|
124
136
|
**AssetSync** supports the following methods of configuration.
|
125
137
|
|
126
|
-
* [Built-in Initializer](https://github.com/
|
138
|
+
* [Built-in Initializer](https://github.com/AssetSync/asset_sync/blob/master/lib/asset_sync/engine.rb) (configured through environment variables)
|
127
139
|
* Rails Initializer
|
128
140
|
* A YAML config file
|
129
141
|
|
@@ -172,7 +184,17 @@ heroku config:add FOG_DIRECTORY=xxxx
|
|
172
184
|
heroku config:add FOG_PROVIDER=Rackspace
|
173
185
|
```
|
174
186
|
|
175
|
-
Google Storage Cloud configuration is supported as well
|
187
|
+
Google Storage Cloud configuration is supported as well. The preferred option is using the [GCS JSON API](https://github.com/fog/fog-google#storage) which requires that you create an appropriate service account, generate the signatures and make them accessible to asset sync at the prescribed location
|
188
|
+
|
189
|
+
```bash
|
190
|
+
heroku config:add FOG_PROVIDER=Google
|
191
|
+
heroku config:add GOOGLE_PROJECT=xxxx
|
192
|
+
heroku config:add GOOGLE_JSON_KEY_LOCATION=xxxx
|
193
|
+
heroku config:add FOG_DIRECTORY=xxxx
|
194
|
+
```
|
195
|
+
|
196
|
+
If using the S3 API the following config is required
|
197
|
+
|
176
198
|
``` bash
|
177
199
|
heroku config:add FOG_PROVIDER=Google
|
178
200
|
heroku config:add GOOGLE_STORAGE_ACCESS_KEY_ID=xxxx
|
@@ -191,6 +213,7 @@ Run the included Rake task to generate a starting point.
|
|
191
213
|
rails g asset_sync:install --provider=Rackspace
|
192
214
|
rails g asset_sync:install --provider=AWS
|
193
215
|
rails g asset_sync:install --provider=AzureRM
|
216
|
+
rails g asset_sync:install --provider=Backblaze
|
194
217
|
|
195
218
|
The generator will create a Rails initializer at `config/initializers/asset_sync.rb`.
|
196
219
|
|
@@ -200,6 +223,7 @@ AssetSync.configure do |config|
|
|
200
223
|
config.fog_directory = ENV['FOG_DIRECTORY']
|
201
224
|
config.aws_access_key_id = ENV['AWS_ACCESS_KEY_ID']
|
202
225
|
config.aws_secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
|
226
|
+
config.aws_session_token = ENV['AWS_SESSION_TOKEN'] if ENV.key?('AWS_SESSION_TOKEN')
|
203
227
|
|
204
228
|
# Don't delete files from the store
|
205
229
|
# config.existing_remote_files = 'keep'
|
@@ -207,12 +231,20 @@ AssetSync.configure do |config|
|
|
207
231
|
# Increase upload performance by configuring your region
|
208
232
|
# config.fog_region = 'eu-west-1'
|
209
233
|
#
|
234
|
+
# Set `public` option when uploading file depending on value,
|
235
|
+
# Setting to "default" makes asset sync skip setting the option
|
236
|
+
# Possible values: true, false, "default" (default: true)
|
237
|
+
# config.fog_public = true
|
238
|
+
#
|
210
239
|
# Change AWS signature version. Default is 4
|
211
240
|
# config.aws_signature_version = 4
|
212
241
|
#
|
213
242
|
# Change host option in fog (only if you need to)
|
214
243
|
# config.fog_host = 's3.amazonaws.com'
|
215
244
|
#
|
245
|
+
# Change port option in fog (only if you need to)
|
246
|
+
# config.fog_port = "9000"
|
247
|
+
#
|
216
248
|
# Use http instead of https.
|
217
249
|
# config.fog_scheme = 'http'
|
218
250
|
#
|
@@ -226,6 +258,15 @@ AssetSync.configure do |config|
|
|
226
258
|
# Upload the manifest file also.
|
227
259
|
# config.include_manifest = false
|
228
260
|
#
|
261
|
+
# Upload files concurrently
|
262
|
+
# config.concurrent_uploads = false
|
263
|
+
#
|
264
|
+
# Number of threads when concurrent_uploads is enabled
|
265
|
+
# config.concurrent_uploads_max_threads = 10
|
266
|
+
#
|
267
|
+
# Path to cache file to skip scanning remote
|
268
|
+
# config.remote_file_list_cache_file_path = './.asset_sync_remote_file_list_cache.json'
|
269
|
+
#
|
229
270
|
# Fail silently. Useful for environments such as Heroku
|
230
271
|
# config.fail_silently = true
|
231
272
|
#
|
@@ -248,6 +289,7 @@ Run the included Rake task to generate a starting point.
|
|
248
289
|
rails g asset_sync:install --use-yml --provider=Rackspace
|
249
290
|
rails g asset_sync:install --use-yml --provider=AWS
|
250
291
|
rails g asset_sync:install --use-yml --provider=AzureRM
|
292
|
+
rails g asset_sync:install --use-yml --provider=Backblaze
|
251
293
|
|
252
294
|
The generator will create a YAML file at `config/asset_sync.yml`.
|
253
295
|
|
@@ -322,6 +364,9 @@ AssetSync.config.gzip_compression == ENV['ASSET_SYNC_GZIP_COMPRESSION']
|
|
322
364
|
* **gzip\_compression**: (`true, false`) when enabled, will automatically replace files that have a gzip compressed equivalent with the compressed version. **default:** `'false'`
|
323
365
|
* **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'`
|
324
366
|
* **include_manifest**: (`true, false`) when enabled, will upload the `manifest.yml` generated by Rails. **default:** `'false'`
|
367
|
+
* **concurrent_uploads**: (`true, false`) when enabled, will upload the files in different Threads, this greatly improves the upload speed. **default:** `'false'`
|
368
|
+
* **concurrent_uploads_max_threads**: when concurrent_uploads is enabled, this determines the number of threads that will be created. **default:** `10`
|
369
|
+
* **remote_file_list_cache_file_path**: if present, use this path to cache remote file list to skip scanning remote **default:** `nil`
|
325
370
|
* **enabled**: (`true, false`) when false, will disable asset sync. **default:** `'true'` (enabled)
|
326
371
|
* **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**: `[]`
|
327
372
|
* **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**: `[]`
|
@@ -344,8 +389,26 @@ end
|
|
344
389
|
```
|
345
390
|
The blocks are run when local files are being scanned and uploaded
|
346
391
|
|
392
|
+
##### Config Method `file_ext_to_mime_type_overrides`
|
393
|
+
It's reported that `mime-types` 3.x returns `application/ecmascript` instead of `application/javascript`
|
394
|
+
Such change of mime type might cause some CDN to disable asset compression
|
395
|
+
So this gem has defined a default override for file ext `js` to be mapped to `application/javascript` by default
|
396
|
+
|
397
|
+
To customize the overrides:
|
398
|
+
```ruby
|
399
|
+
AssetSync.configure do |config|
|
400
|
+
# Clear the default overrides
|
401
|
+
config.file_ext_to_mime_type_overrides.clear
|
402
|
+
|
403
|
+
# Add/Edit overrides
|
404
|
+
# Will call `#to_s` for inputs
|
405
|
+
config.file_ext_to_mime_type_overrides.add(:js, :"application/x-javascript")
|
406
|
+
end
|
407
|
+
```
|
408
|
+
The blocks are run when local files are being scanned and uploaded
|
409
|
+
|
347
410
|
#### Fog (Required)
|
348
|
-
* **fog\_provider**: your storage provider *AWS* (S3) or *Rackspace* (Cloud Files) or *Google* (Google Storage) or *AzureRM* (Azure Blob)
|
411
|
+
* **fog\_provider**: your storage provider *AWS* (S3) or *Rackspace* (Cloud Files) or *Google* (Google Storage) or *AzureRM* (Azure Blob) or *Backblaze* (Backblaze B2)
|
349
412
|
* **fog\_directory**: your bucket name
|
350
413
|
|
351
414
|
#### Fog (Optional)
|
@@ -364,6 +427,14 @@ The blocks are run when local files are being scanned and uploaded
|
|
364
427
|
* **rackspace\_api\_key**: your Rackspace API Key.
|
365
428
|
|
366
429
|
#### Google Storage
|
430
|
+
|
431
|
+
When using the JSON API
|
432
|
+
|
433
|
+
- **google\_project**: your Google Cloud Project name where the Google Cloud Storage bucket resides
|
434
|
+
- **google\_json\_key\_location**: path to the location of the service account key. The service account key must be a JSON type key
|
435
|
+
|
436
|
+
When using the S3 API
|
437
|
+
|
367
438
|
* **google\_storage\_access\_key\_id**: your Google Storage access key
|
368
439
|
* **google\_storage\_secret\_access\_key**: your Google Storage access secret
|
369
440
|
|
@@ -371,6 +442,11 @@ The blocks are run when local files are being scanned and uploaded
|
|
371
442
|
* **azure\_storage\_account\_name**: your Azure Blob access key
|
372
443
|
* **azure\_storage\_access\_key**: your Azure Blob access secret
|
373
444
|
|
445
|
+
#### Backblaze B2
|
446
|
+
* **b2\_key\_id**: Your Backblaze B2 key ID
|
447
|
+
* **b2\_key\_token**: Your Backblaze B2 key token
|
448
|
+
* **b2\_bucket\_id**: Your Backblaze B2 bucket ID
|
449
|
+
|
374
450
|
#### Rackspace (Optional)
|
375
451
|
|
376
452
|
* **rackspace\_auth\_url**: Rackspace auth URL, for Rackspace London use: `https://lon.identity.api.rackspacecloud.com/v2.0`
|
@@ -494,6 +570,10 @@ AssetSync.configure do |config|
|
|
494
570
|
config.aws_access_key_id = ENV['AWS_ACCESS_KEY_ID']
|
495
571
|
config.aws_secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
|
496
572
|
config.prefix = 'assets'
|
573
|
+
# Can be a `Pathname` or `String`
|
574
|
+
# Will be converted into an `Pathname`
|
575
|
+
# If relative, will be converted into an absolute path
|
576
|
+
# via `::Rails.root` or `::Dir.pwd`
|
497
577
|
config.public_path = Pathname('./public')
|
498
578
|
end
|
499
579
|
```
|
@@ -523,6 +603,37 @@ namespace :assets do
|
|
523
603
|
end
|
524
604
|
```
|
525
605
|
|
606
|
+
## Webpacker (> 2.0) support
|
607
|
+
|
608
|
+
1. Add webpacker files and disable `run_on_precompile`:
|
609
|
+
```ruby
|
610
|
+
AssetSync.configure do |config|
|
611
|
+
# Disable automatic run on precompile in order to attach to webpacker rake task
|
612
|
+
config.run_on_precompile = false
|
613
|
+
# The block should return an array of file paths
|
614
|
+
config.add_local_file_paths do
|
615
|
+
# Support webpacker assets
|
616
|
+
public_root = Rails.root.join("public")
|
617
|
+
Dir.chdir(public_root) do
|
618
|
+
packs_dir = Webpacker.config.public_output_path.relative_path_from(public_root)
|
619
|
+
Dir[File.join(packs_dir, '/**/**')]
|
620
|
+
end
|
621
|
+
end
|
622
|
+
end
|
623
|
+
```
|
624
|
+
|
625
|
+
2. Add a `asset_sync.rake` in your `lib/tasks` directory that enhances the correct task, otherwise asset_sync runs before `webpacker:compile` does:
|
626
|
+
```
|
627
|
+
if defined?(AssetSync)
|
628
|
+
Rake::Task['webpacker:compile'].enhance do
|
629
|
+
Rake::Task["assets:sync"].invoke
|
630
|
+
end
|
631
|
+
end
|
632
|
+
```
|
633
|
+
|
634
|
+
### Caveat
|
635
|
+
By adding local files outside the normal Rails `assets` directory, the uploading part works, however checking that the asset was previously uploaded is not working because asset_sync is only fetching the files in the `assets` directory on the remote bucket. This will mean additional time used to upload the same assets again on every precompilation.
|
636
|
+
|
526
637
|
## Running the specs
|
527
638
|
|
528
639
|
Make sure you have a .env file with these details:-
|