webpacker_uploader 0.6.0 → 0.7.1

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: b1f1e410b9ed124323d818d4b436581aecd735717f47176bf9754091209e608d
4
- data.tar.gz: e8732c0cab079cf51864b1addd8a3e8d94c1487fa371872213f5343f2473de03
3
+ metadata.gz: 96198a1aa60035fa87959114f6dde6550671c8dfed6c308e2edf96baf9645376
4
+ data.tar.gz: f1d88a52f9f75e7f044deccbbb7c923141eecfbc421dabc48ff3ac578b73795c
5
5
  SHA512:
6
- metadata.gz: 0c52c1f98939ca6338579e23fbe186fadfa1b22204bf62ceaffdb3ec4e2387c2f0763330a0db7cfcbc898e7a77035719749458b5828a0d5b7ba3b3b78ecde8e0
7
- data.tar.gz: 2dde591f7f50548ad64a14f401b325aa3a4e83566c78463602406a458d6d6bc331843ab188fd7142c8be616722671574bf43ec36d0d0dcc9155f9253bdc61c84
6
+ metadata.gz: 7fe1589c9e7b36aaacf0a582aa94f057ddd48b05ba20fca373bb8430a621edeaeb69e64b82831e2a621a6fe3729a3a49514fad40dba351cb005ff7f928d56f62
7
+ data.tar.gz: cb7127ff364dee3a702e36b4fce6a9a371f5dea1af50bfe3cbfd9844fe3d61778d0ebef9c14b4d0561930bbdaf75bba5e76055f16acbff35c9958a72ec6b50fc
data/.rubocop.yml CHANGED
@@ -3,7 +3,7 @@ require:
3
3
  - rubocop-minitest
4
4
 
5
5
  AllCops:
6
- TargetRubyVersion: 2.5
6
+ TargetRubyVersion: 2.6
7
7
  # RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
8
8
  # to ignore them, so only the ones explicitly set in this file are enabled.
9
9
  DisabledByDefault: true
data/CHANGELOG.md CHANGED
@@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file. The format
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [[0.7.1]](https://github.com/tlatsas/webpacker_uploader/releases/tag/v0.7.1) - 2023-01-05
8
+
9
+ ### Changed
10
+
11
+ - Bump dependencies
12
+
13
+ ## [[0.7.0]](https://github.com/tlatsas/webpacker_uploader/releases/tag/v0.7.0) - 2021-11-27
14
+
15
+ ### Added
16
+
17
+ - Support setting Cache-Control on uploaded files. ([#16](https://github.com/tlatsas/webpacker_uploader/pull/16), [@Dimitris24sta23](https://github.com/Dimitris24sta23))
18
+
7
19
  ## [[0.6.0]](https://github.com/tlatsas/webpacker_uploader/releases/tag/v0.6.0) - 2021-07-20
8
20
 
9
21
  ### Added
data/Gemfile.lock CHANGED
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- webpacker_uploader (0.6.0)
4
+ webpacker_uploader (0.7.1)
5
+ activesupport (< 7.0)
5
6
  mime-types
6
7
  rack (~> 2.0)
7
8
  webpacker (>= 5.1)
@@ -9,84 +10,84 @@ PATH
9
10
  GEM
10
11
  remote: https://rubygems.org/
11
12
  specs:
12
- actionpack (6.1.4)
13
- actionview (= 6.1.4)
14
- activesupport (= 6.1.4)
13
+ actionpack (6.1.7)
14
+ actionview (= 6.1.7)
15
+ activesupport (= 6.1.7)
15
16
  rack (~> 2.0, >= 2.0.9)
16
17
  rack-test (>= 0.6.3)
17
18
  rails-dom-testing (~> 2.0)
18
19
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
19
- actionview (6.1.4)
20
- activesupport (= 6.1.4)
20
+ actionview (6.1.7)
21
+ activesupport (= 6.1.7)
21
22
  builder (~> 3.1)
22
23
  erubi (~> 1.4)
23
24
  rails-dom-testing (~> 2.0)
24
25
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
25
- activesupport (6.1.4)
26
+ activesupport (6.1.7)
26
27
  concurrent-ruby (~> 1.0, >= 1.0.2)
27
28
  i18n (>= 1.6, < 2)
28
29
  minitest (>= 5.1)
29
30
  tzinfo (~> 2.0)
30
31
  zeitwerk (~> 2.3)
31
32
  ast (2.4.2)
32
- aws-eventstream (1.1.1)
33
- aws-partitions (1.477.0)
34
- aws-sdk-core (3.117.0)
33
+ aws-eventstream (1.2.0)
34
+ aws-partitions (1.586.0)
35
+ aws-sdk-core (3.130.2)
35
36
  aws-eventstream (~> 1, >= 1.0.2)
36
- aws-partitions (~> 1, >= 1.239.0)
37
+ aws-partitions (~> 1, >= 1.525.0)
37
38
  aws-sigv4 (~> 1.1)
38
39
  jmespath (~> 1.0)
39
- aws-sdk-kms (1.44.0)
40
- aws-sdk-core (~> 3, >= 3.112.0)
40
+ aws-sdk-kms (1.56.0)
41
+ aws-sdk-core (~> 3, >= 3.127.0)
41
42
  aws-sigv4 (~> 1.1)
42
- aws-sdk-s3 (1.96.1)
43
- aws-sdk-core (~> 3, >= 3.112.0)
43
+ aws-sdk-s3 (1.114.0)
44
+ aws-sdk-core (~> 3, >= 3.127.0)
44
45
  aws-sdk-kms (~> 1)
45
- aws-sigv4 (~> 1.1)
46
- aws-sigv4 (1.2.4)
46
+ aws-sigv4 (~> 1.4)
47
+ aws-sigv4 (1.5.0)
47
48
  aws-eventstream (~> 1, >= 1.0.2)
48
49
  builder (3.2.4)
49
- concurrent-ruby (1.1.9)
50
+ concurrent-ruby (1.1.10)
50
51
  crass (1.0.6)
51
- erubi (1.10.0)
52
- i18n (1.8.10)
52
+ erubi (1.12.0)
53
+ i18n (1.12.0)
53
54
  concurrent-ruby (~> 1.0)
54
- jmespath (1.4.0)
55
- loofah (2.10.0)
55
+ jmespath (1.6.1)
56
+ loofah (2.19.1)
56
57
  crass (~> 1.0.2)
57
58
  nokogiri (>= 1.5.9)
58
59
  method_source (1.0.0)
59
- mime-types (3.3.1)
60
+ mime-types (3.4.1)
60
61
  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)
62
+ mime-types-data (3.2022.0105)
63
+ mini_portile2 (2.8.1)
64
+ minitest (5.15.0)
65
+ nokogiri (1.13.10)
66
+ mini_portile2 (~> 2.8.0)
66
67
  racc (~> 1.4)
67
- parallel (1.20.1)
68
- parser (3.0.0.0)
68
+ parallel (1.22.1)
69
+ parser (3.1.2.0)
69
70
  ast (~> 2.4.1)
70
- racc (1.5.2)
71
- rack (2.2.3)
72
- rack-proxy (0.7.0)
71
+ racc (1.6.2)
72
+ rack (2.2.5)
73
+ rack-proxy (0.7.4)
73
74
  rack
74
- rack-test (1.1.0)
75
- rack (>= 1.0, < 3)
75
+ rack-test (2.0.2)
76
+ rack (>= 1.3)
76
77
  rails-dom-testing (2.0.3)
77
78
  activesupport (>= 4.2.0)
78
79
  nokogiri (>= 1.6)
79
- rails-html-sanitizer (1.3.0)
80
- loofah (~> 2.3)
81
- railties (6.1.4)
82
- actionpack (= 6.1.4)
83
- activesupport (= 6.1.4)
80
+ rails-html-sanitizer (1.4.4)
81
+ loofah (~> 2.19, >= 2.19.1)
82
+ railties (6.1.7)
83
+ actionpack (= 6.1.7)
84
+ activesupport (= 6.1.7)
84
85
  method_source
85
- rake (>= 0.13)
86
+ rake (>= 12.2)
86
87
  thor (~> 1.0)
87
- rainbow (3.0.0)
88
- rake (12.3.3)
89
- regexp_parser (2.1.1)
88
+ rainbow (3.1.1)
89
+ rake (13.0.6)
90
+ regexp_parser (2.3.1)
90
91
  rexml (3.2.5)
91
92
  rubocop (1.11.0)
92
93
  parallel (~> 1.10)
@@ -97,26 +98,28 @@ GEM
97
98
  rubocop-ast (>= 1.2.0, < 2.0)
98
99
  ruby-progressbar (~> 1.7)
99
100
  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)
101
+ rubocop-ast (1.17.0)
102
+ parser (>= 3.1.1.0)
103
+ rubocop-minitest (0.19.1)
104
+ rubocop (>= 0.90, < 2.0)
105
+ rubocop-performance (1.13.3)
106
+ rubocop (>= 1.7.0, < 2.0)
106
107
  rubocop-ast (>= 0.4.0)
107
108
  ruby-progressbar (1.11.0)
108
109
  semantic_range (3.0.0)
109
- thor (1.1.0)
110
- tzinfo (2.0.4)
110
+ thor (1.2.1)
111
+ tzinfo (2.0.5)
111
112
  concurrent-ruby (~> 1.0)
112
- unicode-display_width (2.0.0)
113
- webpacker (5.4.0)
113
+ unicode-display_width (2.1.0)
114
+ webpacker (5.4.3)
114
115
  activesupport (>= 5.2)
115
116
  rack-proxy (>= 0.6.1)
116
117
  railties (>= 5.2)
117
118
  semantic_range (>= 2.3.0)
118
- yard (0.9.26)
119
- zeitwerk (2.4.2)
119
+ webrick (1.7.0)
120
+ yard (0.9.27)
121
+ webrick (~> 1.7.0)
122
+ zeitwerk (2.6.6)
120
123
 
121
124
  PLATFORMS
122
125
  ruby
@@ -133,4 +136,4 @@ DEPENDENCIES
133
136
  yard (~> 0.9)
134
137
 
135
138
  BUNDLED WITH
136
- 2.1.4
139
+ 2.3.3
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # WebpackerUploader
2
2
 
3
- [![Ruby tests](https://img.shields.io/github/workflow/status/tlatsas/webpacker_uploader/Ruby%20tests?style=flat-square)](https://github.com/tlatsas/webpacker_uploader/actions)
4
- [![RuboCop](https://img.shields.io/github/workflow/status/tlatsas/webpacker_uploader/RuboCop?label=rubocop&style=flat-square)](https://github.com/tlatsas/webpacker_uploader/actions)
3
+ [![Ruby tests](https://img.shields.io/github/actions/workflow/status/tlatsas/webpacker_uploader/ruby.yml?style=flat-square)](https://github.com/tlatsas/webpacker_uploader/actions)
4
+ [![RuboCop](https://img.shields.io/github/actions/workflow/status/tlatsas/webpacker_uploader/rubocop.yml?label=rubocop&style=flat-square)](https://github.com/tlatsas/webpacker_uploader/actions)
5
5
  [![Gem](https://img.shields.io/gem/v/webpacker_uploader?style=flat-square)](https://rubygems.org/gems/webpacker_uploader)
6
6
  [![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg?style=flat-square)](https://www.rubydoc.info/gems/webpacker_uploader)
7
7
 
@@ -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,12 +107,24 @@ 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:
109
125
 
110
126
  | option | description | default value |
111
- |----------------------|--------------------------------------------------------------|---------------------------------------|
127
+ | -------------------- | ------------------------------------------------------------ | ------------------------------------- |
112
128
  | ignored_extensions | Which files uploader should skip based on the file extension | [] |
113
129
  | logger | The logger to use for logging | ActiveSupport::Logger.new(STDOUT) |
114
130
  | log_output | Log output as we upload files | true |
@@ -159,7 +175,7 @@ docker compose -f "integration/docker-compose.yml" up --detach
159
175
 
160
176
  To run the tests, use `rake test:integration`.
161
177
 
162
- To stop the container once done run: `docker-compose -f "integration/docker-compose.yml" down`
178
+ To stop the container once done run: `docker-compose -f "integration/docker-compose.yml" down`
163
179
 
164
180
  ## Contributing
165
181
 
@@ -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.1"
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
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.homepage = "https://github.com/tlatsas/webpacker_uploader"
12
12
  s.license = "MIT"
13
13
 
14
- s.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
14
+ s.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
15
15
 
16
16
  s.metadata = {
17
17
  "homepage_uri" => s.homepage,
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
25
25
  s.require_paths = ["lib"]
26
26
 
27
27
  s.add_dependency "webpacker", ">= 5.1"
28
+ s.add_dependency "activesupport", "< 7.0"
28
29
  s.add_dependency "mime-types"
29
30
  s.add_dependency "rack", "~> 2.0"
30
31
 
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.1
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: 2023-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: webpacker
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '5.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activesupport
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "<"
32
+ - !ruby/object:Gem::Version
33
+ version: '7.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "<"
39
+ - !ruby/object:Gem::Version
40
+ version: '7.0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: mime-types
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -148,7 +162,7 @@ metadata:
148
162
  homepage_uri: https://github.com/tlatsas/webpacker_uploader
149
163
  bug_tracker_uri: https://github.com/tlatsas/webpacker_uploader/issues
150
164
  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
165
+ source_code_uri: https://github.com/tlatsas/webpacker_uploader/tree/v0.7.1
152
166
  post_install_message:
153
167
  rdoc_options: []
154
168
  require_paths:
@@ -157,7 +171,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
157
171
  requirements:
158
172
  - - ">="
159
173
  - !ruby/object:Gem::Version
160
- version: 2.5.0
174
+ version: 2.6.0
161
175
  required_rubygems_version: !ruby/object:Gem::Requirement
162
176
  requirements:
163
177
  - - ">="