asset_sync 2.4.0 → 2.15.2
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 +68 -0
- data/.travis.yml +25 -26
- data/Appraisals +6 -10
- data/CHANGELOG.md +207 -2
- data/README.md +135 -10
- data/asset_sync.gemspec +7 -4
- 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/asset_sync.rb +10 -0
- data/lib/asset_sync/config.rb +163 -15
- data/lib/asset_sync/engine.rb +9 -0
- data/lib/asset_sync/multi_mime.rb +7 -2
- data/lib/asset_sync/storage.rb +84 -21
- 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 +26 -0
- data/lib/generators/asset_sync/templates/asset_sync.yml +25 -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 +60 -11
- 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: 637e59bd4543dca69ef7f27a5bb8e6759e1ab082d4279ac9fa34c93dfbb249f8
|
4
|
+
data.tar.gz: b6855c7789d2ab8ae49abf0d9606204239ab1949574af540b8e1aec60d79de87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0947b76c9abcd8aea09106f954f76acabbf3b35a782d6b9af531325590359b66a89d9cf8fdd608a9f763e8c7d63d707780993713f667d9a8be9c144a3e7641f7'
|
7
|
+
data.tar.gz: 50255f748090ce2c2923344b4878bf875e9886d59929dd2888ef91416ec86063988ca3e16ee6f71a94cda540a779e3474a6468a49af8901fbd3b19bc7cdeee24
|
@@ -0,0 +1,68 @@
|
|
1
|
+
name: Tests
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
paths-ignore:
|
8
|
+
- 'README.md'
|
9
|
+
- 'CHANGELOG.md'
|
10
|
+
push:
|
11
|
+
branches:
|
12
|
+
- master
|
13
|
+
paths-ignore:
|
14
|
+
- 'README.md'
|
15
|
+
- 'CHANGELOG.md'
|
16
|
+
|
17
|
+
jobs:
|
18
|
+
unit_tests:
|
19
|
+
name: Unit Tests
|
20
|
+
# Homemade support for [ci skip] no longer needed
|
21
|
+
# https://github.blog/changelog/2021-02-08-github-actions-skip-pull-request-and-push-workflows-with-skip-ci/
|
22
|
+
# if: "contains(github.event.commits[0].message, '[ci skip]') == false"
|
23
|
+
strategy:
|
24
|
+
fail-fast: false
|
25
|
+
matrix:
|
26
|
+
os:
|
27
|
+
- ubuntu
|
28
|
+
ruby:
|
29
|
+
- 2.5
|
30
|
+
- 2.6
|
31
|
+
- 2.7
|
32
|
+
- 3.0
|
33
|
+
- jruby
|
34
|
+
gemfile:
|
35
|
+
- gemfiles/rails_5_2.gemfile
|
36
|
+
- gemfiles/rails_6_0.gemfile
|
37
|
+
- gemfiles/rails_6_1.gemfile
|
38
|
+
allow_failures:
|
39
|
+
- false
|
40
|
+
include:
|
41
|
+
- os: ubuntu
|
42
|
+
ruby: ruby-head
|
43
|
+
gemfile: gemfiles/rails_6_1.gemfile
|
44
|
+
allow_failures: true
|
45
|
+
- os: ubuntu
|
46
|
+
ruby: jruby-head
|
47
|
+
gemfile: gemfiles/rails_6_1.gemfile
|
48
|
+
allow_failures: true
|
49
|
+
exclude:
|
50
|
+
- os: ubuntu
|
51
|
+
ruby: 3.0
|
52
|
+
gemfile: gemfiles/rails_5_2.gemfile
|
53
|
+
allow_failures: false
|
54
|
+
env:
|
55
|
+
BUNDLE_GEMFILE: "${{ matrix.gemfile }}"
|
56
|
+
ALLOW_FAILURES: "${{ matrix.allow_failures }}"
|
57
|
+
runs-on: ${{ matrix.os }}-latest
|
58
|
+
continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' }}
|
59
|
+
steps:
|
60
|
+
- name: Checkout
|
61
|
+
uses: actions/checkout@v2
|
62
|
+
- name: Setup Ruby
|
63
|
+
uses: ruby/setup-ruby@v1
|
64
|
+
with:
|
65
|
+
ruby-version: ${{ matrix.ruby }}
|
66
|
+
bundler-cache: true
|
67
|
+
- name: Test
|
68
|
+
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,191 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
18
18
|
- Nothing
|
19
19
|
|
20
20
|
|
21
|
+
## [2.15.2] - 2022-06-02
|
22
|
+
|
23
|
+
### Fixed
|
24
|
+
|
25
|
+
- Fix incorrect commented code in asset_sync.yml
|
26
|
+
(https://github.com/AssetSync/asset_sync/pull/426)
|
27
|
+
|
28
|
+
|
29
|
+
## [2.15.1] - 2021-11-22
|
30
|
+
|
31
|
+
### Changed
|
32
|
+
|
33
|
+
- Update dev dependency `fog-azure-rm` to become `gitlab-fog-azure-rm`
|
34
|
+
|
35
|
+
### Fixed
|
36
|
+
|
37
|
+
- Fix YAML config file parsing with Psych v4
|
38
|
+
(https://github.com/AssetSync/asset_sync/pull/422)
|
39
|
+
|
40
|
+
|
41
|
+
## [2.15.0] - 2021-08-05
|
42
|
+
|
43
|
+
### Added
|
44
|
+
|
45
|
+
- Add support for option `aws_acl`
|
46
|
+
(https://github.com/AssetSync/asset_sync/pull/420)
|
47
|
+
|
48
|
+
|
49
|
+
## [2.14.2] - 2021-05-31
|
50
|
+
|
51
|
+
### Added
|
52
|
+
|
53
|
+
- Add support for setting option `google_json_key_string` in YML (not new option)
|
54
|
+
(https://github.com/AssetSync/asset_sync/pull/419)
|
55
|
+
|
56
|
+
|
57
|
+
## [2.14.1] - 2021-05-14
|
58
|
+
|
59
|
+
### Added
|
60
|
+
|
61
|
+
- Add support for setting option `log_silently` in YML (not new option)
|
62
|
+
(https://github.com/AssetSync/asset_sync/pull/417)
|
63
|
+
|
64
|
+
|
65
|
+
## [2.14.0] - 2021-03-31
|
66
|
+
|
67
|
+
### Added
|
68
|
+
|
69
|
+
- Add support for fog option `google_json_key_string`
|
70
|
+
(https://github.com/AssetSync/asset_sync/pull/415)
|
71
|
+
|
72
|
+
|
73
|
+
## [2.13.1] - 2021-03-01
|
74
|
+
|
75
|
+
### Fixed
|
76
|
+
|
77
|
+
- Fix "files to be uploaded list" generation for file names with dashes
|
78
|
+
(https://github.com/AssetSync/asset_sync/pull/414)
|
79
|
+
|
80
|
+
|
81
|
+
## [2.13.0] - 2020-12-14
|
82
|
+
|
83
|
+
### Added
|
84
|
+
|
85
|
+
- Add Backblaze B2 Cloud Storage support
|
86
|
+
(https://github.com/AssetSync/asset_sync/pull/410)
|
87
|
+
|
88
|
+
|
89
|
+
## [2.12.1] - 2020-06-17
|
90
|
+
|
91
|
+
### Fixed
|
92
|
+
|
93
|
+
- Fix initializer template in generator
|
94
|
+
(https://github.com/AssetSync/asset_sync/pull/404)
|
95
|
+
|
96
|
+
|
97
|
+
## [2.12.0] - 2020-06-11
|
98
|
+
|
99
|
+
### Added
|
100
|
+
|
101
|
+
- Add option `aws_session_token` to support AWS Temporary Security Credentials
|
102
|
+
(https://github.com/AssetSync/asset_sync/pull/403)
|
103
|
+
|
104
|
+
|
105
|
+
## [2.11.0] - 2020-03-13
|
106
|
+
|
107
|
+
### Added
|
108
|
+
|
109
|
+
- Add option `remote_file_list_cache_file_path` to skip scanning remote
|
110
|
+
(https://github.com/AssetSync/asset_sync/pull/400)
|
111
|
+
|
112
|
+
|
113
|
+
## [2.10.0] - 2020-02-26
|
114
|
+
|
115
|
+
### Added
|
116
|
+
|
117
|
+
- Add option `concurrent_uploads_max_threads` to limit number of threads for uploading files
|
118
|
+
(https://github.com/AssetSync/asset_sync/pull/398)
|
119
|
+
|
120
|
+
|
121
|
+
## [2.9.1] - 2020-02-20
|
122
|
+
|
123
|
+
### Fixed
|
124
|
+
|
125
|
+
- Fix uploading of sprockets manifest file
|
126
|
+
(https://github.com/AssetSync/asset_sync/pull/397)
|
127
|
+
|
128
|
+
|
129
|
+
## [2.9.0] - 2020-01-15
|
130
|
+
|
131
|
+
### Added
|
132
|
+
|
133
|
+
- Add option `concurrent_uploads` to improve speed of uploading
|
134
|
+
(https://github.com/AssetSync/asset_sync/pull/393)
|
135
|
+
|
136
|
+
|
137
|
+
## [2.8.2] - 2019-12-27
|
138
|
+
|
139
|
+
### Changed
|
140
|
+
|
141
|
+
- Use `delete_multiple_objects` when storage is `aws`
|
142
|
+
(https://github.com/AssetSync/asset_sync/pull/392)
|
143
|
+
|
144
|
+
|
145
|
+
## [2.8.1] - 2019-07-25
|
146
|
+
|
147
|
+
### Changed
|
148
|
+
|
149
|
+
- Removed `rubyforge_project` from gemspec
|
150
|
+
(https://github.com/AssetSync/asset_sync/pull/386)
|
151
|
+
|
152
|
+
### Fixed
|
153
|
+
|
154
|
+
- Fixed when `fog_public` set to `false`, file were still set to be public
|
155
|
+
(https://github.com/AssetSync/asset_sync/pull/387)
|
156
|
+
|
157
|
+
|
158
|
+
## [2.8.0] - 2019-06-17
|
159
|
+
|
160
|
+
### Added
|
161
|
+
|
162
|
+
- Add option `fog_port`
|
163
|
+
(https://github.com/AssetSync/asset_sync/pull/385)
|
164
|
+
|
165
|
+
|
166
|
+
## [2.7.0] - 2019-03-15
|
167
|
+
|
168
|
+
### Added
|
169
|
+
|
170
|
+
- Adds JSON API support when using Google Storage
|
171
|
+
(https://github.com/AssetSync/asset_sync/pull/381)
|
172
|
+
|
173
|
+
### Changed
|
174
|
+
|
175
|
+
- Update `AssetSync::MultiMime.lookup` to always return strings (kind of internal change)
|
176
|
+
(https://github.com/AssetSync/asset_sync/pull/380)
|
177
|
+
|
178
|
+
|
179
|
+
## [2.6.0] - 2018-12-07
|
180
|
+
|
181
|
+
### Added
|
182
|
+
|
183
|
+
- Add option `fog_public`
|
184
|
+
(https://github.com/AssetSync/asset_sync/pull/377)
|
185
|
+
|
186
|
+
|
187
|
+
## [2.5.0] - 2018-10-25
|
188
|
+
|
189
|
+
### Added
|
190
|
+
|
191
|
+
- Add ruby only option `file_ext_to_mime_type_overrides`
|
192
|
+
(https://github.com/AssetSync/asset_sync/pull/374)
|
193
|
+
|
194
|
+
### Changed
|
195
|
+
|
196
|
+
- Start testing against rails 5.2, stop testing against rails 4.1
|
197
|
+
|
198
|
+
### Fixed
|
199
|
+
|
200
|
+
- Only enhance rake task assets:precompile if it's defined
|
201
|
+
(https://github.com/AssetSync/asset_sync/commit/e1eb1a16b06fd39def1759428a2d94733915bbff)
|
202
|
+
- Avoid ruby warning due to "method redefined"
|
203
|
+
(https://github.com/AssetSync/asset_sync/pull/371)
|
204
|
+
|
205
|
+
|
21
206
|
## [2.4.0] - 2017-12-20
|
22
207
|
|
23
208
|
### Added
|
@@ -78,7 +263,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
78
263
|
|
79
264
|
- Only support mime-type >= 2.99,
|
80
265
|
which is released at the end of 2015
|
81
|
-
- Only support
|
266
|
+
- Only support activemodel >= 4.1,
|
82
267
|
which is released in 2014
|
83
268
|
|
84
269
|
|
@@ -861,7 +1046,27 @@ Changes:
|
|
861
1046
|
* Merge branch 'sinatra'
|
862
1047
|
|
863
1048
|
|
864
|
-
[Unreleased]: https://github.com/AssetSync/asset_sync/compare/v2.
|
1049
|
+
[Unreleased]: https://github.com/AssetSync/asset_sync/compare/v2.15.2...HEAD
|
1050
|
+
[2.15.2]: https://github.com/AssetSync/asset_sync/compare/v2.15.1...v2.15.2
|
1051
|
+
[2.15.1]: https://github.com/AssetSync/asset_sync/compare/v2.15.0...v2.15.1
|
1052
|
+
[2.15.0]: https://github.com/AssetSync/asset_sync/compare/v2.14.2...v2.15.0
|
1053
|
+
[2.14.2]: https://github.com/AssetSync/asset_sync/compare/v2.14.1...v2.14.2
|
1054
|
+
[2.14.1]: https://github.com/AssetSync/asset_sync/compare/v2.14.0...v2.14.1
|
1055
|
+
[2.14.0]: https://github.com/AssetSync/asset_sync/compare/v2.13.1...v2.14.0
|
1056
|
+
[2.13.1]: https://github.com/AssetSync/asset_sync/compare/v2.13.0...v2.13.1
|
1057
|
+
[2.13.0]: https://github.com/AssetSync/asset_sync/compare/v2.12.1...v2.13.0
|
1058
|
+
[2.12.1]: https://github.com/AssetSync/asset_sync/compare/v2.12.0...v2.12.1
|
1059
|
+
[2.12.0]: https://github.com/AssetSync/asset_sync/compare/v2.11.0...v2.12.0
|
1060
|
+
[2.11.0]: https://github.com/AssetSync/asset_sync/compare/v2.10.0...v2.11.0
|
1061
|
+
[2.10.0]: https://github.com/AssetSync/asset_sync/compare/v2.9.1...v2.10.0
|
1062
|
+
[2.9.1]: https://github.com/AssetSync/asset_sync/compare/v2.9.0...v2.9.1
|
1063
|
+
[2.9.0]: https://github.com/AssetSync/asset_sync/compare/v2.8.2...v2.9.0
|
1064
|
+
[2.8.2]: https://github.com/AssetSync/asset_sync/compare/v2.8.1...v2.8.2
|
1065
|
+
[2.8.1]: https://github.com/AssetSync/asset_sync/compare/v2.8.0...v2.8.1
|
1066
|
+
[2.8.0]: https://github.com/AssetSync/asset_sync/compare/v2.7.0...v2.8.0
|
1067
|
+
[2.7.0]: https://github.com/AssetSync/asset_sync/compare/v2.6.0...v2.7.0
|
1068
|
+
[2.6.0]: https://github.com/AssetSync/asset_sync/compare/v2.5.0...v2.6.0
|
1069
|
+
[2.5.0]: https://github.com/AssetSync/asset_sync/compare/v2.4.0...v2.5.0
|
865
1070
|
[2.4.0]: https://github.com/AssetSync/asset_sync/compare/v2.3.0...v2.4.0
|
866
1071
|
[2.3.0]: https://github.com/AssetSync/asset_sync/compare/v2.2.0...v2.3.0
|
867
1072
|
[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
|
@@ -37,7 +35,17 @@ Or, to use Azure Blob storage, configure as this.
|
|
37
35
|
|
38
36
|
``` ruby
|
39
37
|
gem "asset_sync"
|
40
|
-
gem "fog-azure-rm"
|
38
|
+
gem "gitlab-fog-azure-rm"
|
39
|
+
|
40
|
+
# This gem seems unmaintianed
|
41
|
+
# gem "fog-azure-rm"
|
42
|
+
```
|
43
|
+
|
44
|
+
To use Backblaze B2, insert these.
|
45
|
+
|
46
|
+
``` ruby
|
47
|
+
gem "asset_sync"
|
48
|
+
gem "fog-backblaze"
|
41
49
|
```
|
42
50
|
|
43
51
|
|
@@ -79,6 +87,13 @@ Or, to use Azure Blob storage, configure as this.
|
|
79
87
|
config.action_controller.asset_host = "//#{ENV['AZURE_STORAGE_ACCOUNT_NAME']}.blob.core.windows.net/#{ENV['FOG_DIRECTORY']}"
|
80
88
|
```
|
81
89
|
|
90
|
+
Or, to use Backblaze B2, configure as this.
|
91
|
+
|
92
|
+
``` ruby
|
93
|
+
#config/environments/production.rb
|
94
|
+
config.action_controller.asset_host = "//f000.backblazeb2.com/file/#{ENV['FOG_DIRECTORY']}"
|
95
|
+
```
|
96
|
+
|
82
97
|
|
83
98
|
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
99
|
|
@@ -105,10 +120,10 @@ On **non default S3 bucket region**: If your bucket is set to a region that is n
|
|
105
120
|
|
106
121
|
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
122
|
|
108
|
-
```ruby
|
123
|
+
``` ruby
|
109
124
|
# store assets in a 'folder' instead of bucket root
|
110
125
|
config.assets.prefix = "/production/assets"
|
111
|
-
|
126
|
+
```
|
112
127
|
|
113
128
|
Also, ensure the following are defined (in production.rb or application.rb)
|
114
129
|
|
@@ -123,7 +138,7 @@ Additionally, if you depend on any configuration that is setup in your `initiali
|
|
123
138
|
|
124
139
|
**AssetSync** supports the following methods of configuration.
|
125
140
|
|
126
|
-
* [Built-in Initializer](https://github.com/
|
141
|
+
* [Built-in Initializer](https://github.com/AssetSync/asset_sync/blob/master/lib/asset_sync/engine.rb) (configured through environment variables)
|
127
142
|
* Rails Initializer
|
128
143
|
* A YAML config file
|
129
144
|
|
@@ -172,7 +187,17 @@ heroku config:add FOG_DIRECTORY=xxxx
|
|
172
187
|
heroku config:add FOG_PROVIDER=Rackspace
|
173
188
|
```
|
174
189
|
|
175
|
-
Google Storage Cloud configuration is supported as well
|
190
|
+
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
|
191
|
+
|
192
|
+
```bash
|
193
|
+
heroku config:add FOG_PROVIDER=Google
|
194
|
+
heroku config:add GOOGLE_PROJECT=xxxx
|
195
|
+
heroku config:add GOOGLE_JSON_KEY_LOCATION=xxxx
|
196
|
+
heroku config:add FOG_DIRECTORY=xxxx
|
197
|
+
```
|
198
|
+
|
199
|
+
If using the S3 API the following config is required
|
200
|
+
|
176
201
|
``` bash
|
177
202
|
heroku config:add FOG_PROVIDER=Google
|
178
203
|
heroku config:add GOOGLE_STORAGE_ACCESS_KEY_ID=xxxx
|
@@ -191,6 +216,7 @@ Run the included Rake task to generate a starting point.
|
|
191
216
|
rails g asset_sync:install --provider=Rackspace
|
192
217
|
rails g asset_sync:install --provider=AWS
|
193
218
|
rails g asset_sync:install --provider=AzureRM
|
219
|
+
rails g asset_sync:install --provider=Backblaze
|
194
220
|
|
195
221
|
The generator will create a Rails initializer at `config/initializers/asset_sync.rb`.
|
196
222
|
|
@@ -200,6 +226,7 @@ AssetSync.configure do |config|
|
|
200
226
|
config.fog_directory = ENV['FOG_DIRECTORY']
|
201
227
|
config.aws_access_key_id = ENV['AWS_ACCESS_KEY_ID']
|
202
228
|
config.aws_secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
|
229
|
+
config.aws_session_token = ENV['AWS_SESSION_TOKEN'] if ENV.key?('AWS_SESSION_TOKEN')
|
203
230
|
|
204
231
|
# Don't delete files from the store
|
205
232
|
# config.existing_remote_files = 'keep'
|
@@ -207,12 +234,25 @@ AssetSync.configure do |config|
|
|
207
234
|
# Increase upload performance by configuring your region
|
208
235
|
# config.fog_region = 'eu-west-1'
|
209
236
|
#
|
237
|
+
# Set `public` option when uploading file depending on value,
|
238
|
+
# Setting to "default" makes asset sync skip setting the option
|
239
|
+
# Possible values: true, false, "default" (default: true)
|
240
|
+
# config.fog_public = true
|
241
|
+
#
|
210
242
|
# Change AWS signature version. Default is 4
|
211
243
|
# config.aws_signature_version = 4
|
212
244
|
#
|
245
|
+
# Change canned ACL of uploaded object. Default is unset. Will override fog_public if set.
|
246
|
+
# Choose from: private | public-read | public-read-write | aws-exec-read |
|
247
|
+
# authenticated-read | bucket-owner-read | bucket-owner-full-control
|
248
|
+
# config.aws_acl = nil
|
249
|
+
#
|
213
250
|
# Change host option in fog (only if you need to)
|
214
251
|
# config.fog_host = 's3.amazonaws.com'
|
215
252
|
#
|
253
|
+
# Change port option in fog (only if you need to)
|
254
|
+
# config.fog_port = "9000"
|
255
|
+
#
|
216
256
|
# Use http instead of https.
|
217
257
|
# config.fog_scheme = 'http'
|
218
258
|
#
|
@@ -226,6 +266,15 @@ AssetSync.configure do |config|
|
|
226
266
|
# Upload the manifest file also.
|
227
267
|
# config.include_manifest = false
|
228
268
|
#
|
269
|
+
# Upload files concurrently
|
270
|
+
# config.concurrent_uploads = false
|
271
|
+
#
|
272
|
+
# Number of threads when concurrent_uploads is enabled
|
273
|
+
# config.concurrent_uploads_max_threads = 10
|
274
|
+
#
|
275
|
+
# Path to cache file to skip scanning remote
|
276
|
+
# config.remote_file_list_cache_file_path = './.asset_sync_remote_file_list_cache.json'
|
277
|
+
#
|
229
278
|
# Fail silently. Useful for environments such as Heroku
|
230
279
|
# config.fail_silently = true
|
231
280
|
#
|
@@ -248,6 +297,7 @@ Run the included Rake task to generate a starting point.
|
|
248
297
|
rails g asset_sync:install --use-yml --provider=Rackspace
|
249
298
|
rails g asset_sync:install --use-yml --provider=AWS
|
250
299
|
rails g asset_sync:install --use-yml --provider=AzureRM
|
300
|
+
rails g asset_sync:install --use-yml --provider=Backblaze
|
251
301
|
|
252
302
|
The generator will create a YAML file at `config/asset_sync.yml`.
|
253
303
|
|
@@ -267,6 +317,11 @@ defaults: &defaults
|
|
267
317
|
# Change AWS signature version. Default is 4
|
268
318
|
# aws_signature_version: 4
|
269
319
|
#
|
320
|
+
# Change canned ACL of uploaded object. Default is unset. Will override fog_public if set.
|
321
|
+
# Choose from: private | public-read | public-read-write | aws-exec-read |
|
322
|
+
# authenticated-read | bucket-owner-read | bucket-owner-full-control
|
323
|
+
# aws_acl: null
|
324
|
+
#
|
270
325
|
# Change host option in fog (only if you need to)
|
271
326
|
# fog_host: "s3.amazonaws.com"
|
272
327
|
#
|
@@ -322,6 +377,9 @@ AssetSync.config.gzip_compression == ENV['ASSET_SYNC_GZIP_COMPRESSION']
|
|
322
377
|
* **gzip\_compression**: (`true, false`) when enabled, will automatically replace files that have a gzip compressed equivalent with the compressed version. **default:** `'false'`
|
323
378
|
* **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
379
|
* **include_manifest**: (`true, false`) when enabled, will upload the `manifest.yml` generated by Rails. **default:** `'false'`
|
380
|
+
* **concurrent_uploads**: (`true, false`) when enabled, will upload the files in different Threads, this greatly improves the upload speed. **default:** `'false'`
|
381
|
+
* **concurrent_uploads_max_threads**: when concurrent_uploads is enabled, this determines the number of threads that will be created. **default:** `10`
|
382
|
+
* **remote_file_list_cache_file_path**: if present, use this path to cache remote file list to skip scanning remote **default:** `nil`
|
325
383
|
* **enabled**: (`true, false`) when false, will disable asset sync. **default:** `'true'` (enabled)
|
326
384
|
* **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
385
|
* **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 +402,26 @@ end
|
|
344
402
|
```
|
345
403
|
The blocks are run when local files are being scanned and uploaded
|
346
404
|
|
405
|
+
##### Config Method `file_ext_to_mime_type_overrides`
|
406
|
+
It's reported that `mime-types` 3.x returns `application/ecmascript` instead of `application/javascript`
|
407
|
+
Such change of mime type might cause some CDN to disable asset compression
|
408
|
+
So this gem has defined a default override for file ext `js` to be mapped to `application/javascript` by default
|
409
|
+
|
410
|
+
To customize the overrides:
|
411
|
+
```ruby
|
412
|
+
AssetSync.configure do |config|
|
413
|
+
# Clear the default overrides
|
414
|
+
config.file_ext_to_mime_type_overrides.clear
|
415
|
+
|
416
|
+
# Add/Edit overrides
|
417
|
+
# Will call `#to_s` for inputs
|
418
|
+
config.file_ext_to_mime_type_overrides.add(:js, :"application/x-javascript")
|
419
|
+
end
|
420
|
+
```
|
421
|
+
The blocks are run when local files are being scanned and uploaded
|
422
|
+
|
347
423
|
#### Fog (Required)
|
348
|
-
* **fog\_provider**: your storage provider *AWS* (S3) or *Rackspace* (Cloud Files) or *Google* (Google Storage) or *AzureRM* (Azure Blob)
|
424
|
+
* **fog\_provider**: your storage provider *AWS* (S3) or *Rackspace* (Cloud Files) or *Google* (Google Storage) or *AzureRM* (Azure Blob) or *Backblaze* (Backblaze B2)
|
349
425
|
* **fog\_directory**: your bucket name
|
350
426
|
|
351
427
|
#### Fog (Optional)
|
@@ -357,6 +433,7 @@ The blocks are run when local files are being scanned and uploaded
|
|
357
433
|
|
358
434
|
* **aws\_access\_key\_id**: your Amazon S3 access key
|
359
435
|
* **aws\_secret\_access\_key**: your Amazon S3 access secret
|
436
|
+
* **aws\_acl**: set [canned ACL](https://docs.aws.amazon.com/AmazonS3/latest/userguide/acl-overview.html#canned-acl) of uploaded object, will override fog_public if set
|
360
437
|
|
361
438
|
#### Rackspace
|
362
439
|
|
@@ -364,6 +441,14 @@ The blocks are run when local files are being scanned and uploaded
|
|
364
441
|
* **rackspace\_api\_key**: your Rackspace API Key.
|
365
442
|
|
366
443
|
#### Google Storage
|
444
|
+
|
445
|
+
When using the JSON API
|
446
|
+
|
447
|
+
- **google\_project**: your Google Cloud Project name where the Google Cloud Storage bucket resides
|
448
|
+
- **google\_json\_key\_location**: path to the location of the service account key. The service account key must be a JSON type key
|
449
|
+
|
450
|
+
When using the S3 API
|
451
|
+
|
367
452
|
* **google\_storage\_access\_key\_id**: your Google Storage access key
|
368
453
|
* **google\_storage\_secret\_access\_key**: your Google Storage access secret
|
369
454
|
|
@@ -371,6 +456,11 @@ The blocks are run when local files are being scanned and uploaded
|
|
371
456
|
* **azure\_storage\_account\_name**: your Azure Blob access key
|
372
457
|
* **azure\_storage\_access\_key**: your Azure Blob access secret
|
373
458
|
|
459
|
+
#### Backblaze B2
|
460
|
+
* **b2\_key\_id**: Your Backblaze B2 key ID
|
461
|
+
* **b2\_key\_token**: Your Backblaze B2 key token
|
462
|
+
* **b2\_bucket\_id**: Your Backblaze B2 bucket ID
|
463
|
+
|
374
464
|
#### Rackspace (Optional)
|
375
465
|
|
376
466
|
* **rackspace\_auth\_url**: Rackspace auth URL, for Rackspace London use: `https://lon.identity.api.rackspacecloud.com/v2.0`
|
@@ -494,6 +584,10 @@ AssetSync.configure do |config|
|
|
494
584
|
config.aws_access_key_id = ENV['AWS_ACCESS_KEY_ID']
|
495
585
|
config.aws_secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
|
496
586
|
config.prefix = 'assets'
|
587
|
+
# Can be a `Pathname` or `String`
|
588
|
+
# Will be converted into an `Pathname`
|
589
|
+
# If relative, will be converted into an absolute path
|
590
|
+
# via `::Rails.root` or `::Dir.pwd`
|
497
591
|
config.public_path = Pathname('./public')
|
498
592
|
end
|
499
593
|
```
|
@@ -523,6 +617,37 @@ namespace :assets do
|
|
523
617
|
end
|
524
618
|
```
|
525
619
|
|
620
|
+
## Webpacker (> 2.0) support
|
621
|
+
|
622
|
+
1. Add webpacker files and disable `run_on_precompile`:
|
623
|
+
```ruby
|
624
|
+
AssetSync.configure do |config|
|
625
|
+
# Disable automatic run on precompile in order to attach to webpacker rake task
|
626
|
+
config.run_on_precompile = false
|
627
|
+
# The block should return an array of file paths
|
628
|
+
config.add_local_file_paths do
|
629
|
+
# Support webpacker assets
|
630
|
+
public_root = Rails.root.join("public")
|
631
|
+
Dir.chdir(public_root) do
|
632
|
+
packs_dir = Webpacker.config.public_output_path.relative_path_from(public_root)
|
633
|
+
Dir[File.join(packs_dir, '/**/**')]
|
634
|
+
end
|
635
|
+
end
|
636
|
+
end
|
637
|
+
```
|
638
|
+
|
639
|
+
2. Add a `asset_sync.rake` in your `lib/tasks` directory that enhances the correct task, otherwise asset_sync runs before `webpacker:compile` does:
|
640
|
+
```
|
641
|
+
if defined?(AssetSync)
|
642
|
+
Rake::Task['webpacker:compile'].enhance do
|
643
|
+
Rake::Task["assets:sync"].invoke
|
644
|
+
end
|
645
|
+
end
|
646
|
+
```
|
647
|
+
|
648
|
+
### Caveat
|
649
|
+
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.
|
650
|
+
|
526
651
|
## Running the specs
|
527
652
|
|
528
653
|
Make sure you have a .env file with these details:-
|