asset_sync 2.6.0 → 2.7.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: 51ba6147cc39550e51d1eb1bc98420b53b0ca14fe96d90d34e7de36c8a9511b5
4
- data.tar.gz: 701e692e95ed4c8ad41a8a5d14e7356ee8c013221e675d7396a8b07816f7a226
3
+ metadata.gz: 543b0540bba53d960c7d755b04dafb6dd7a884a3073b2043aa3f2de554a9cffb
4
+ data.tar.gz: debe4684fcc49e58fc717971595d3db742266aba20ea418ba6a3331a6652534f
5
5
  SHA512:
6
- metadata.gz: f03b66ce2292d21a3e1a514307a3bf737c0ea856b46ee6e36aef40b93a2604b544e708f97f7b1e9fbfa81483545929cfb9e7714c4bf4172e6311e22f4cc7ffe2
7
- data.tar.gz: e228c684a414b1a9859ea8df91f76b1b6c5ad4234863b46307dd76b705aa8a71f18cba5ab8c959a33ac089ca9d5c355dc26391bb16441a8c802fc0f44f97c087
6
+ metadata.gz: 346531ad9fb1ce2065f5becb4c3283d5f3578ff573c19a254f4895e46a863c03cbacd708aa55d616586d02f37baecc7976a52b5dc05470920bae627b30f18e6a
7
+ data.tar.gz: 1a7162d20dd6727c5fa1464782ac68b3f20c4ad9b5204e2ca9eb9f3e5e476599ecacfb81f89a76748fab0e714ed23194515b98f95a0632de2acbb6146bc267cf
data/.travis.yml CHANGED
@@ -5,7 +5,6 @@ language: ruby
5
5
  cache:
6
6
  bundler: true
7
7
  rvm:
8
- - 2.2
9
8
  - 2.3
10
9
  - 2.4
11
10
  - 2.5
@@ -18,8 +17,12 @@ gemfile:
18
17
  - gemfiles/rails_5_0.gemfile
19
18
  - gemfiles/rails_5_1.gemfile
20
19
  - gemfiles/rails_5_2.gemfile
20
+ - gemfiles/rails_6_0.gemfile
21
21
  before_install:
22
- - gem install bundler
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 2.7.8 --no-doc || travis_retry gem update --system 2.7.8 --no-rdoc --no-ri"
25
+ - "travis_retry gem install bundler -v '<2'"
23
26
  env:
24
27
  global:
25
28
  - FOG_DIRECTORY=asset-sync-travis
@@ -29,9 +32,19 @@ env:
29
32
  matrix:
30
33
  fast_finish: true
31
34
  allow_failures:
32
- - rvm: 2.6
35
+ # bundler version conflict
36
+ - rvm: 2.3
37
+ gemfile: gemfiles/rails_4_2.gemfile
38
+ - rvm: jruby
39
+ gemfile: gemfiles/rails_4_2.gemfile
40
+ - gemfile: gemfiles/rails_6_0.gemfile
33
41
  - rvm: ruby-head
34
42
  - rvm: jruby-head
43
+ exclude:
44
+ - rvm: 2.3
45
+ gemfile: gemfiles/rails_6_0.gemfile
46
+ - rvm: 2.4
47
+ gemfile: gemfiles/rails_6_0.gemfile
35
48
  notifications:
36
49
  webhooks:
37
50
  urls:
data/Appraisals CHANGED
@@ -14,3 +14,7 @@ end
14
14
  appraise "rails_5_2" do
15
15
  gem "rails", "~> 5.2.0"
16
16
  end
17
+
18
+ appraise "rails_6_0" do
19
+ gem "rails", "~> 6.0.0.beta1"
20
+ end
data/CHANGELOG.md CHANGED
@@ -18,6 +18,19 @@ This project adheres to [Semantic Versioning](http://semver.org/).
18
18
  - Nothing
19
19
 
20
20
 
21
+ ## [2.7.0] - 2019-03-15
22
+
23
+ ### Added
24
+
25
+ - Adds JSON API support when using Google Storage
26
+ (https://github.com/AssetSync/asset_sync/pull/381)
27
+
28
+ ### Changed
29
+
30
+ - Update `AssetSync::MultiMime.lookup` to always return strings (kind of internal change)
31
+ (https://github.com/AssetSync/asset_sync/pull/380)
32
+
33
+
21
34
  ## [2.6.0] - 2018-12-07
22
35
 
23
36
  ### Added
@@ -888,7 +901,8 @@ Changes:
888
901
  * Merge branch 'sinatra'
889
902
 
890
903
 
891
- [Unreleased]: https://github.com/AssetSync/asset_sync/compare/v2.6.0...HEAD
904
+ [Unreleased]: https://github.com/AssetSync/asset_sync/compare/v2.7.0...HEAD
905
+ [2.7.0]: https://github.com/AssetSync/asset_sync/compare/v2.6.0...v2.7.0
892
906
  [2.6.0]: https://github.com/AssetSync/asset_sync/compare/v2.5.0...v2.6.0
893
907
  [2.5.0]: https://github.com/AssetSync/asset_sync/compare/v2.4.0...v2.5.0
894
908
  [2.4.0]: https://github.com/AssetSync/asset_sync/compare/v2.3.0...v2.4.0
data/README.md CHANGED
@@ -106,7 +106,7 @@ If you wish to have your assets sync to a sub-folder of your bucket instead of i
106
106
  ```ruby
107
107
  # store assets in a 'folder' instead of bucket root
108
108
  config.assets.prefix = "/production/assets"
109
- ````
109
+ ​````
110
110
 
111
111
  Also, ensure the following are defined (in production.rb or application.rb)
112
112
 
@@ -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
@@ -170,7 +170,17 @@ heroku config:add FOG_DIRECTORY=xxxx
170
170
  heroku config:add FOG_PROVIDER=Rackspace
171
171
  ```
172
172
 
173
- Google Storage Cloud configuration is supported as well
173
+ 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
174
+
175
+ ```bash
176
+ heroku config:add FOG_PROVIDER=Google
177
+ heroku config:add GOOGLE_PROJECT=xxxx
178
+ heroku config:add GOOGLE_JSON_KEY_LOCATION=xxxx
179
+ heroku config:add FOG_DIRECTORY=xxxx
180
+ ```
181
+
182
+ If using the S3 API the following config is required
183
+
174
184
  ``` bash
175
185
  heroku config:add FOG_PROVIDER=Google
176
186
  heroku config:add GOOGLE_STORAGE_ACCESS_KEY_ID=xxxx
@@ -385,6 +395,14 @@ The blocks are run when local files are being scanned and uploaded
385
395
  * **rackspace\_api\_key**: your Rackspace API Key.
386
396
 
387
397
  #### Google Storage
398
+
399
+ When using the JSON API
400
+
401
+ - **google\_project**: your Google Cloud Project name where the Google Cloud Storage bucket resides
402
+ - **google\_json\_key\_location**: path to the location of the service account key. The service account key must be a JSON type key
403
+
404
+ When using the S3 API
405
+
388
406
  * **google\_storage\_access\_key\_id**: your Google Storage access key
389
407
  * **google\_storage\_secret\_access\_key**: your Google Storage access secret
390
408
 
@@ -584,7 +602,7 @@ Make sure you have a .env file with these details:-
584
602
  AWS_SECRET_ACCESS_KEY=<yoursecretkey>
585
603
  FOG_DIRECTORY=<yourbucket>
586
604
  FOG_REGION=<youbucketregion>
587
-
605
+
588
606
  # for AzureRM provider
589
607
  AZURE_STORAGE_ACCOUNT_NAME=<youraccountname>
590
608
  AZURE_STORAGE_ACCESS_KEY=<youraccesskey>
@@ -0,0 +1,10 @@
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", "~> 6.0.0.beta1"
9
+
10
+ gemspec path: "../"
@@ -44,7 +44,9 @@ module AssetSync
44
44
  attr_accessor :rackspace_username, :rackspace_api_key, :rackspace_auth_url
45
45
 
46
46
  # Google Storage
47
- attr_accessor :google_storage_secret_access_key, :google_storage_access_key_id
47
+ attr_accessor :google_storage_secret_access_key, :google_storage_access_key_id # when using S3 interop
48
+ attr_accessor :google_json_key_location # when using service accounts
49
+ attr_accessor :google_project # when using service accounts
48
50
 
49
51
  # Azure Blob with Fog::AzureRM
50
52
  attr_accessor :azure_storage_account_name
@@ -59,8 +61,10 @@ module AssetSync
59
61
  validates :aws_secret_access_key, :presence => true, :if => proc {aws? && !aws_iam?}
60
62
  validates :rackspace_username, :presence => true, :if => :rackspace?
61
63
  validates :rackspace_api_key, :presence => true, :if => :rackspace?
62
- validates :google_storage_secret_access_key, :presence => true, :if => :google?
63
- validates :google_storage_access_key_id, :presence => true, :if => :google?
64
+ validates :google_storage_secret_access_key, :presence => true, :if => :google_interop?
65
+ validates :google_storage_access_key_id, :presence => true, :if => :google_interop?
66
+ validates :google_json_key_location, :presence => true, :if => :google_service_account?
67
+ validates :google_project, :presence => true, :if => :google_service_account?
64
68
 
65
69
  def initialize
66
70
  self.fog_region = nil
@@ -130,6 +134,14 @@ module AssetSync
130
134
  fog_provider =~ /google/i
131
135
  end
132
136
 
137
+ def google_interop?
138
+ google? && google_json_key_location.nil?
139
+ end
140
+
141
+ def google_service_account?
142
+ google? && google_json_key_location
143
+ end
144
+
133
145
  def azure_rm?
134
146
  fog_provider =~ /azurerm/i
135
147
  end
@@ -176,8 +188,10 @@ module AssetSync
176
188
  self.rackspace_username = yml["rackspace_username"]
177
189
  self.rackspace_auth_url = yml["rackspace_auth_url"] if yml.has_key?("rackspace_auth_url")
178
190
  self.rackspace_api_key = yml["rackspace_api_key"]
179
- self.google_storage_secret_access_key = yml["google_storage_secret_access_key"]
180
- self.google_storage_access_key_id = yml["google_storage_access_key_id"]
191
+ self.google_json_key_location = yml["google_json_key_location"] if yml.has_key?("google_json_key_location")
192
+ self.google_project = yml["google_project"] if yml.has_key?("google_project")
193
+ self.google_storage_secret_access_key = yml["google_storage_secret_access_key"] if yml.has_key?("google_storage_secret_access_key")
194
+ self.google_storage_access_key_id = yml["google_storage_access_key_id"] if yml.has_key?("google_storage_access_key_id")
181
195
  self.existing_remote_files = yml["existing_remote_files"] if yml.has_key?("existing_remote_files")
182
196
  self.gzip_compression = yml["gzip_compression"] if yml.has_key?("gzip_compression")
183
197
  self.manifest = yml["manifest"] if yml.has_key?("manifest")
@@ -236,10 +250,14 @@ module AssetSync
236
250
  options.merge!({ :rackspace_region => fog_region }) if fog_region
237
251
  options.merge!({ :rackspace_auth_url => rackspace_auth_url }) if rackspace_auth_url
238
252
  elsif google?
239
- options.merge!({
240
- :google_storage_secret_access_key => google_storage_secret_access_key,
241
- :google_storage_access_key_id => google_storage_access_key_id
242
- })
253
+ if google_json_key_location
254
+ options.merge!({:google_json_key_location => google_json_key_location, :google_project => google_project})
255
+ else
256
+ options.merge!({
257
+ :google_storage_secret_access_key => google_storage_secret_access_key,
258
+ :google_storage_access_key_id => google_storage_access_key_id
259
+ })
260
+ end
243
261
  options.merge!({:region => fog_region}) if fog_region
244
262
  elsif azure_rm?
245
263
  require 'fog/azurerm'
@@ -11,9 +11,9 @@ module AssetSync
11
11
  end
12
12
 
13
13
  if defined?(::MIME::Types)
14
- ::MIME::Types.type_for(ext).first
14
+ ::MIME::Types.type_for(ext).first.to_s
15
15
  elsif defined?(::Mime::Type)
16
- ::Mime::Type.lookup_by_extension(ext)
16
+ ::Mime::Type.lookup_by_extension(ext).to_s
17
17
  elsif defined?(::Rack::Mime)
18
18
  ext_with_dot = ".#{ext}"
19
19
  ::Rack::Mime.mime_type(ext_with_dot)
@@ -231,12 +231,6 @@ module AssetSync
231
231
  })
232
232
  end
233
233
 
234
- if config.azure_rm?
235
- # converts content_type from MIME::Type to String.
236
- # because Azure::Storage (called from Fog::AzureRM) expects content_type as a String like "application/json; charset=utf-8"
237
- file[:content_type] = file[:content_type].content_type if file[:content_type].is_a?(::MIME::Type)
238
- end
239
-
240
234
  bucket.files.create( file ) unless ignore
241
235
  file_handle.close
242
236
  gzip_file_handle.close if gzip_file_handle
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AssetSync
4
- VERSION = "2.6.0".freeze
4
+ VERSION = "2.7.0".freeze
5
5
  end
@@ -0,0 +1,19 @@
1
+ defaults: &defaults
2
+ fog_provider: "Google"
3
+ google_json_key_location: 'gcs.json'
4
+ google_project: 'some-project'
5
+
6
+ development:
7
+ <<: *defaults
8
+ fog_directory: "rails_app_development"
9
+ existing_remote_files: keep
10
+
11
+ test:
12
+ <<: *defaults
13
+ fog_directory: "rails_app_test"
14
+ existing_remote_files: keep
15
+
16
+ production:
17
+ <<: *defaults
18
+ fog_directory: "rails_app_production"
19
+ existing_remote_files: delete
@@ -8,8 +8,6 @@ describe AssetSync do
8
8
  AssetSync.config = AssetSync::Config.new
9
9
  AssetSync.configure do |config|
10
10
  config.fog_provider = 'Google'
11
- config.google_storage_access_key_id = 'aaaa'
12
- config.google_storage_secret_access_key = 'bbbb'
13
11
  config.fog_directory = 'mybucket'
14
12
  config.existing_remote_files = "keep"
15
13
  end
@@ -24,14 +22,6 @@ describe AssetSync do
24
22
  expect(AssetSync.config.existing_remote_files?).to eq(true)
25
23
  end
26
24
 
27
- it "should configure google_storage_access_key_id" do
28
- expect(AssetSync.config.google_storage_access_key_id).to eq("aaaa")
29
- end
30
-
31
- it "should configure google_storage_secret_access_key" do
32
- expect(AssetSync.config.google_storage_secret_access_key).to eq("bbbb")
33
- end
34
-
35
25
  it "should configure fog_directory" do
36
26
  expect(AssetSync.config.fog_directory).to eq("mybucket")
37
27
  end
@@ -47,36 +37,119 @@ describe AssetSync do
47
37
  it "should default manifest to false" do
48
38
  expect(AssetSync.config.manifest).to be_falsey
49
39
  end
50
- end
51
40
 
52
- describe 'from yml' do
53
- before(:each) do
54
- set_rails_root('google_with_yml')
55
- AssetSync.config = AssetSync::Config.new
56
- end
41
+ describe "when using S3 interop API" do
42
+ before(:each) do
43
+ AssetSync.configure do |config|
44
+ config.google_storage_access_key_id = 'aaaa'
45
+ config.google_storage_secret_access_key = 'bbbb'
46
+ end
47
+ end
57
48
 
58
- it "should configure google_storage_access_key_id" do
59
- expect(AssetSync.config.google_storage_access_key_id).to eq("xxxx")
60
- end
49
+ it "should configure google_storage_access_key_id" do
50
+ expect(AssetSync.config.google_storage_access_key_id).to eq("aaaa")
51
+ end
61
52
 
62
- it "should configure google_storage_secret_access_key" do
63
- expect(AssetSync.config.google_storage_secret_access_key).to eq("zzzz")
64
- end
53
+ it "should configure google_storage_secret_access_key" do
54
+ expect(AssetSync.config.google_storage_secret_access_key).to eq("bbbb")
55
+ end
65
56
 
66
- it "should configure google_storage_access_key" do
67
- expect(AssetSync.config.fog_directory).to eq("rails_app_test")
57
+ it "should return the correct fog_options" do
58
+ expected_fog_options = { google_storage_access_key_id: "aaaa",
59
+ google_storage_secret_access_key: "bbbb",
60
+ provider: "Google"}
61
+ expect(AssetSync.config.fog_options).to eq(expected_fog_options)
62
+ end
63
+
64
+ it "should not require that google_json_key_location be set" do
65
+ expect(AssetSync.config.valid?).to eq(true)
66
+ end
67
+
68
+ it "should require that google_storage_secret_access_key or access_key_id be set" do
69
+
70
+ AssetSync.configure do |config|
71
+ config.google_storage_access_key_id = nil
72
+ config.google_storage_secret_access_key = nil
73
+ end
74
+
75
+ expect(AssetSync.config.valid?).to eq(false)
76
+ end
68
77
  end
69
78
 
70
- it "should configure google_storage_access_key" do
71
- expect(AssetSync.config.existing_remote_files).to eq("keep")
79
+ describe "when using service account" do
80
+ before(:each) do
81
+ AssetSync.configure do |config|
82
+ config.google_json_key_location = '/path/to.json'
83
+ config.google_project = 'a-google-project-name'
84
+ end
85
+ end
86
+
87
+ it "should configure google_json_key_location" do
88
+ expect(AssetSync.config.google_json_key_location).to eq("/path/to.json")
89
+ end
90
+
91
+ it "should return the correct fog_options" do
92
+ expected_fog_options = { google_json_key_location: "/path/to.json",
93
+ google_project: 'a-google-project-name',
94
+ provider: "Google"}
95
+ expect(AssetSync.config.fog_options).to eq(expected_fog_options)
96
+ end
97
+ it "should not require that google_storage_secret_access_key or access_key_id be set" do
98
+ expect(AssetSync.config.valid?).to eq(true)
99
+ end
72
100
  end
73
101
 
74
- it "should default gzip_compression to false" do
75
- expect(AssetSync.config.gzip_compression).to be_falsey
102
+ end
103
+
104
+ describe 'from yml' do
105
+ describe 'when using S3 interop API' do
106
+ before(:each) do
107
+ set_rails_root('google_with_yml')
108
+ AssetSync.config = AssetSync::Config.new
109
+ end
110
+
111
+ it "should configure google_storage_access_key_id" do
112
+ expect(AssetSync.config.google_storage_access_key_id).to eq("xxxx")
113
+ end
114
+
115
+ it "should configure google_storage_secret_access_key" do
116
+ expect(AssetSync.config.google_storage_secret_access_key).to eq("zzzz")
117
+ end
118
+
119
+ it "should not configure google_json_key_location" do
120
+ expect(AssetSync.config.google_json_key_location).to eq(nil)
121
+ end
122
+
123
+ it "should configure fog_directory" do
124
+ expect(AssetSync.config.fog_directory).to eq("rails_app_test")
125
+ end
126
+
127
+ it "should configure existing_remote_files" do
128
+ expect(AssetSync.config.existing_remote_files).to eq("keep")
129
+ end
130
+
131
+ it "should default gzip_compression to false" do
132
+ expect(AssetSync.config.gzip_compression).to be_falsey
133
+ end
134
+
135
+ it "should default manifest to false" do
136
+ expect(AssetSync.config.manifest).to be_falsey
137
+ end
76
138
  end
77
139
 
78
- it "should default manifest to false" do
79
- expect(AssetSync.config.manifest).to be_falsey
140
+ describe 'when using service account API' do
141
+ before(:each) do
142
+ set_rails_root('google_with_service_account_yml')
143
+ AssetSync.config = AssetSync::Config.new
144
+ end
145
+
146
+ it "should configure google_json_key_location" do
147
+ expect(AssetSync.config.google_json_key_location).to eq("gcs.json")
148
+ end
149
+
150
+ it "should not configure google_storage_secret_access_key" do
151
+ expect(AssetSync.config.google_storage_secret_access_key).to eq(nil)
152
+ end
80
153
  end
81
154
  end
82
155
 
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.6.0
4
+ version: 2.7.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: 2018-12-07 00:00:00.000000000 Z
14
+ date: 2019-03-15 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: fog-core
@@ -207,6 +207,7 @@ files:
207
207
  - gemfiles/rails_5_0.gemfile
208
208
  - gemfiles/rails_5_1.gemfile
209
209
  - gemfiles/rails_5_2.gemfile
210
+ - gemfiles/rails_6_0.gemfile
210
211
  - lib/asset_sync.rb
211
212
  - lib/asset_sync/asset_sync.rb
212
213
  - lib/asset_sync/config.rb
@@ -223,6 +224,7 @@ files:
223
224
  - spec/dummy_app/app/assets/javascripts/application.js
224
225
  - spec/fixtures/aws_with_yml/config/asset_sync.yml
225
226
  - spec/fixtures/azure_rm_with_yml/config/asset_sync.yml
227
+ - spec/fixtures/google_with_service_account_yml/config/asset_sync.yml
226
228
  - spec/fixtures/google_with_yml/config/asset_sync.yml
227
229
  - spec/fixtures/rackspace_with_yml/config/asset_sync.yml
228
230
  - spec/fixtures/with_invalid_yml/config/asset_sync.yml
@@ -255,8 +257,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
255
257
  - !ruby/object:Gem::Version
256
258
  version: '0'
257
259
  requirements: []
258
- rubyforge_project: asset_sync
259
- rubygems_version: 2.7.8
260
+ rubygems_version: 3.0.3
260
261
  signing_key:
261
262
  specification_version: 4
262
263
  summary: Synchronises Assets in a Rails 3 application and Amazon S3/Cloudfront and
@@ -266,6 +267,7 @@ test_files:
266
267
  - spec/dummy_app/app/assets/javascripts/application.js
267
268
  - spec/fixtures/aws_with_yml/config/asset_sync.yml
268
269
  - spec/fixtures/azure_rm_with_yml/config/asset_sync.yml
270
+ - spec/fixtures/google_with_service_account_yml/config/asset_sync.yml
269
271
  - spec/fixtures/google_with_yml/config/asset_sync.yml
270
272
  - spec/fixtures/rackspace_with_yml/config/asset_sync.yml
271
273
  - spec/fixtures/with_invalid_yml/config/asset_sync.yml