webpacker_uploader 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b1f1e410b9ed124323d818d4b436581aecd735717f47176bf9754091209e608d
4
- data.tar.gz: e8732c0cab079cf51864b1addd8a3e8d94c1487fa371872213f5343f2473de03
3
+ metadata.gz: 0c6cbb5cf694108a74e0cf8bb306acf9adca3ccedfef971a30c33503e7ccc1a1
4
+ data.tar.gz: 542dd824922fb799670706955b354564f17a467b2e4cb5a5860d4380f4b5ee1a
5
5
  SHA512:
6
- metadata.gz: 0c52c1f98939ca6338579e23fbe186fadfa1b22204bf62ceaffdb3ec4e2387c2f0763330a0db7cfcbc898e7a77035719749458b5828a0d5b7ba3b3b78ecde8e0
7
- data.tar.gz: 2dde591f7f50548ad64a14f401b325aa3a4e83566c78463602406a458d6d6bc331843ab188fd7142c8be616722671574bf43ec36d0d0dcc9155f9253bdc61c84
6
+ metadata.gz: 96aba1a007135c90161ad63baeec1d2a3ea7e6aec85561d7e6e6919c614e00bb7c6252afd9e31f8263a2d121646c42e63eb3de26d79b789e0b9ccde1bd0a2c35
7
+ data.tar.gz: 522bb686c11ce429880befc7015b106f1230264aedde757e8ce7b47dd015485fbab45b71d69712cbe5c75488229c684dc3175ca9137f1ad60c795f5be04c4448
data/CHANGELOG.md CHANGED
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [[0.7.0]](https://github.com/tlatsas/webpacker_uploader/releases/tag/v0.7.0) - 2021-11-27
8
+
9
+ ### Added
10
+
11
+ - Support setting Cache-Control on uploaded files. ([#16](https://github.com/tlatsas/webpacker_uploader/pull/16), [@Dimitris24sta23](https://github.com/Dimitris24sta23))
12
+
7
13
  ## [[0.6.0]](https://github.com/tlatsas/webpacker_uploader/releases/tag/v0.6.0) - 2021-07-20
8
14
 
9
15
  ### Added
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- webpacker_uploader (0.6.0)
4
+ webpacker_uploader (0.7.0)
5
5
  mime-types
6
6
  rack (~> 2.0)
7
7
  webpacker (>= 5.1)
@@ -9,41 +9,41 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- actionpack (6.1.4)
13
- actionview (= 6.1.4)
14
- activesupport (= 6.1.4)
12
+ actionpack (6.1.4.1)
13
+ actionview (= 6.1.4.1)
14
+ activesupport (= 6.1.4.1)
15
15
  rack (~> 2.0, >= 2.0.9)
16
16
  rack-test (>= 0.6.3)
17
17
  rails-dom-testing (~> 2.0)
18
18
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
19
- actionview (6.1.4)
20
- activesupport (= 6.1.4)
19
+ actionview (6.1.4.1)
20
+ activesupport (= 6.1.4.1)
21
21
  builder (~> 3.1)
22
22
  erubi (~> 1.4)
23
23
  rails-dom-testing (~> 2.0)
24
24
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
25
- activesupport (6.1.4)
25
+ activesupport (6.1.4.1)
26
26
  concurrent-ruby (~> 1.0, >= 1.0.2)
27
27
  i18n (>= 1.6, < 2)
28
28
  minitest (>= 5.1)
29
29
  tzinfo (~> 2.0)
30
30
  zeitwerk (~> 2.3)
31
31
  ast (2.4.2)
32
- aws-eventstream (1.1.1)
33
- aws-partitions (1.477.0)
34
- aws-sdk-core (3.117.0)
32
+ aws-eventstream (1.2.0)
33
+ aws-partitions (1.507.0)
34
+ aws-sdk-core (3.121.1)
35
35
  aws-eventstream (~> 1, >= 1.0.2)
36
36
  aws-partitions (~> 1, >= 1.239.0)
37
37
  aws-sigv4 (~> 1.1)
38
38
  jmespath (~> 1.0)
39
- aws-sdk-kms (1.44.0)
40
- aws-sdk-core (~> 3, >= 3.112.0)
39
+ aws-sdk-kms (1.48.0)
40
+ aws-sdk-core (~> 3, >= 3.120.0)
41
41
  aws-sigv4 (~> 1.1)
42
- aws-sdk-s3 (1.96.1)
43
- aws-sdk-core (~> 3, >= 3.112.0)
42
+ aws-sdk-s3 (1.103.0)
43
+ aws-sdk-core (~> 3, >= 3.120.0)
44
44
  aws-sdk-kms (~> 1)
45
- aws-sigv4 (~> 1.1)
46
- aws-sigv4 (1.2.4)
45
+ aws-sigv4 (~> 1.4)
46
+ aws-sigv4 (1.4.0)
47
47
  aws-eventstream (~> 1, >= 1.0.2)
48
48
  builder (3.2.4)
49
49
  concurrent-ruby (1.1.9)
@@ -52,20 +52,20 @@ GEM
52
52
  i18n (1.8.10)
53
53
  concurrent-ruby (~> 1.0)
54
54
  jmespath (1.4.0)
55
- loofah (2.10.0)
55
+ loofah (2.12.0)
56
56
  crass (~> 1.0.2)
57
57
  nokogiri (>= 1.5.9)
58
58
  method_source (1.0.0)
59
59
  mime-types (3.3.1)
60
60
  mime-types-data (~> 3.2015)
61
- mime-types-data (3.2021.0704)
62
- mini_portile2 (2.5.3)
63
- minitest (5.14.2)
64
- nokogiri (1.11.7)
65
- mini_portile2 (~> 2.5.0)
61
+ mime-types-data (3.2021.0901)
62
+ mini_portile2 (2.6.1)
63
+ minitest (5.14.4)
64
+ nokogiri (1.12.5)
65
+ mini_portile2 (~> 2.6.1)
66
66
  racc (~> 1.4)
67
- parallel (1.20.1)
68
- parser (3.0.0.0)
67
+ parallel (1.21.0)
68
+ parser (3.0.2.0)
69
69
  ast (~> 2.4.1)
70
70
  racc (1.5.2)
71
71
  rack (2.2.3)
@@ -76,16 +76,16 @@ GEM
76
76
  rails-dom-testing (2.0.3)
77
77
  activesupport (>= 4.2.0)
78
78
  nokogiri (>= 1.6)
79
- rails-html-sanitizer (1.3.0)
79
+ rails-html-sanitizer (1.4.2)
80
80
  loofah (~> 2.3)
81
- railties (6.1.4)
82
- actionpack (= 6.1.4)
83
- activesupport (= 6.1.4)
81
+ railties (6.1.4.1)
82
+ actionpack (= 6.1.4.1)
83
+ activesupport (= 6.1.4.1)
84
84
  method_source
85
85
  rake (>= 0.13)
86
86
  thor (~> 1.0)
87
87
  rainbow (3.0.0)
88
- rake (12.3.3)
88
+ rake (13.0.6)
89
89
  regexp_parser (2.1.1)
90
90
  rexml (3.2.5)
91
91
  rubocop (1.11.0)
@@ -97,20 +97,20 @@ GEM
97
97
  rubocop-ast (>= 1.2.0, < 2.0)
98
98
  ruby-progressbar (~> 1.7)
99
99
  unicode-display_width (>= 1.4.0, < 3.0)
100
- rubocop-ast (1.4.1)
101
- parser (>= 2.7.1.5)
102
- rubocop-minitest (0.10.3)
103
- rubocop (>= 0.87, < 2.0)
104
- rubocop-performance (1.10.1)
105
- rubocop (>= 0.90.0, < 2.0)
100
+ rubocop-ast (1.12.0)
101
+ parser (>= 3.0.1.1)
102
+ rubocop-minitest (0.15.1)
103
+ rubocop (>= 0.90, < 2.0)
104
+ rubocop-performance (1.11.5)
105
+ rubocop (>= 1.7.0, < 2.0)
106
106
  rubocop-ast (>= 0.4.0)
107
107
  ruby-progressbar (1.11.0)
108
108
  semantic_range (3.0.0)
109
109
  thor (1.1.0)
110
110
  tzinfo (2.0.4)
111
111
  concurrent-ruby (~> 1.0)
112
- unicode-display_width (2.0.0)
113
- webpacker (5.4.0)
112
+ unicode-display_width (2.1.0)
113
+ webpacker (5.4.3)
114
114
  activesupport (>= 5.2)
115
115
  rack-proxy (>= 0.6.1)
116
116
  railties (>= 5.2)
data/README.md CHANGED
@@ -21,11 +21,15 @@ gem "webpacker_uploader", require: false
21
21
 
22
22
  and run:
23
23
 
24
- $ bundle install
24
+ ```sh
25
+ bundle install
26
+ ```
25
27
 
26
28
  or:
27
29
 
28
- $ gem install webpacker_uploader
30
+ ```sh
31
+ gem install webpacker_uploader
32
+ ```
29
33
 
30
34
  To use the aws provider install the aws-sdk-s3 gem. Add in your Gemfile:
31
35
 
@@ -103,6 +107,18 @@ WebpackerUploader.upload!(provider, prefix: "assets")
103
107
  This will prefix all remote file paths with `assets` so instead of storing `packs/application-dd6b1cd38bfa093df600.css` it
104
108
  will store `assets/packs/application-dd6b1cd38bfa093df600.css`.
105
109
 
110
+ ### Add a cache-control directive to remote files
111
+
112
+ ```ruby
113
+ WebpackerUploader.upload!(provider, cache_control: "public, max-age=3600")
114
+ ```
115
+
116
+ This option is used to specify caching behavior along the request/reply chain.
117
+
118
+ ```text
119
+ ⚠️ This option is applied to all uploaded files, not on a per-file basis.
120
+ ```
121
+
106
122
  ### Configuration
107
123
 
108
124
  WebpackerUploader currently supports the following configuration options:
@@ -45,7 +45,8 @@ class WebpackerUploader::Instance
45
45
  # @return [void]
46
46
  # @param provider [WebpackerUploader::Providers::Aws] A provider to use for file uploading.
47
47
  # @param prefix [String] Used to prefix the remote file paths.
48
- def upload!(provider, prefix: nil)
48
+ # @param cache_control [String] Used to add cache-control header to files.
49
+ def upload!(provider, prefix: nil, cache_control: nil)
49
50
  manifest.assets.each do |name, js_path|
50
51
  path = js_path[1..-1]
51
52
 
@@ -65,7 +66,7 @@ class WebpackerUploader::Instance
65
66
 
66
67
  config.logger.info("Processing #{file_path} as #{content_type}") if config.log_output?
67
68
 
68
- provider.upload!(remote_path, file_path, content_type)
69
+ provider.upload!(remote_path, file_path, content_type, cache_control)
69
70
  end
70
71
  end
71
72
  end
@@ -64,9 +64,9 @@ module WebpackerUploader
64
64
  # @param file [Pathname] Path of the local file.
65
65
  # @param content_type [String] The content type that will be set to the S3 object.
66
66
  # @return [void]
67
- def upload!(object_key, file, content_type = "")
67
+ def upload!(object_key, file, content_type = "", cache_control = "")
68
68
  object = @resource.bucket(@bucket_name).object(object_key)
69
- object.upload_file(file, content_type: content_type)
69
+ object.upload_file(file, content_type: content_type, cache_control: cache_control)
70
70
  end
71
71
 
72
72
  private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WebpackerUploader
4
- VERSION = "0.6.0"
4
+ VERSION = "0.7.0"
5
5
  end
data/test/test_helper.rb CHANGED
@@ -21,8 +21,8 @@ module WebpackerUploader::Providers
21
21
  @asset_objects = asset_objects
22
22
  end
23
23
 
24
- def upload!(object_key, file, content_type = "")
25
- @asset_objects << { object_key: object_key, file: file, content_type: content_type }
24
+ def upload!(object_key, file, content_type = "", cache_control = "")
25
+ @asset_objects << { object_key: object_key, file: file, content_type: content_type, cache_control: cache_control }
26
26
  end
27
27
  end
28
28
  end
@@ -29,4 +29,9 @@ class WebpackerUploaderTest < Minitest::Test
29
29
  assert_instance_of Pathname, @asset_objects.first[:file]
30
30
  assert_equal "text/css", @asset_objects.first[:content_type]
31
31
  end
32
+
33
+ def test_upload_with_cache_control
34
+ WebpackerUploader.upload!(@provider, cache_control: "cache_control")
35
+ assert_equal "cache_control", @asset_objects.first[:cache_control]
36
+ end
32
37
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webpacker_uploader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tasos Latsas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-20 00:00:00.000000000 Z
11
+ date: 2021-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: webpacker
@@ -148,7 +148,7 @@ metadata:
148
148
  homepage_uri: https://github.com/tlatsas/webpacker_uploader
149
149
  bug_tracker_uri: https://github.com/tlatsas/webpacker_uploader/issues
150
150
  changelog_uri: https://github.com/tlatsas/webpacker_uploader/blob/main/CHANGELOG.md
151
- source_code_uri: https://github.com/tlatsas/webpacker_uploader/tree/v0.6.0
151
+ source_code_uri: https://github.com/tlatsas/webpacker_uploader/tree/v0.7.0
152
152
  post_install_message:
153
153
  rdoc_options: []
154
154
  require_paths: