hanami-action 3.0.0 → 3.0.1

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: cfd2248b12d546b250ad80e1c7115aa23dbcfab93eb7620dca331a4939af34f0
4
- data.tar.gz: aa6a3f85fe8328a8e5d796be22b9d802cff6f74d643a8f1189f8cef89aafc3d8
3
+ metadata.gz: 8ca2d8098c5bfeaaf4d1422c04eb56980cda8bc806b03f327f4ecf19d82a7ff3
4
+ data.tar.gz: f9f4e24aa1bac023962e562b1dcba5c232dfa3c7dc74610c983108b3f7eaa0f7
5
5
  SHA512:
6
- metadata.gz: 687db93c36b074e4015349842759091cbbb7fb35dda5f30ca1097cc629a1ee48767a2e3740ae54df491b4aee33e315b81e3e0e09a07b0fc0c37995f44c422a4f
7
- data.tar.gz: 29676466bb1d6aba7f7724aadc8c4bdc80f04d7c02bcb11414ad507e09fb623e628b75a23892b7fc10876a8141c180e49443cd503f61c26122196b7e89731088
6
+ metadata.gz: 5377fc1b6c6cf1c5b1be0832ba55e388cf47d8ad07dc3e4a594a506a080c32e641f1cd01685a370b9a9dbab61143e6ecac8b96646ccb77c821da57e43e9e8478
7
+ data.tar.gz: 50b96bbc3419ca3727708944e4f7d5e35b8de9d81ecb340ada4162c72d15114b3330cc22f03990f73bb3e4757f16b25283c93b7b48a43906baa2000de6859c37
data/CHANGELOG.md CHANGED
@@ -9,8 +9,12 @@ and this project adheres to [Break Versioning](https://www.taoensso.com/break-ve
9
9
 
10
10
  ### Added
11
11
 
12
+ - Support additional `Cache-Control` directives in `response.cache_control`: `:immutable`, `:must_understand`, `stale_while_revalidate:` (requires a duration) and `stale_if_error:` (requires a duration). (@timriley in #522)
13
+
12
14
  ### Changed
13
15
 
16
+ - `response.cache_control` raises `ArgumentError` for unknown directives instead of silently dropping them. (@timriley in #522)
17
+
14
18
  ### Deprecated
15
19
 
16
20
  ### Removed
@@ -19,7 +23,21 @@ and this project adheres to [Break Versioning](https://www.taoensso.com/break-ve
19
23
 
20
24
  ### Security
21
25
 
22
- [Unreleased]: https://github.com/hanami/hanami-action/compare/v3.0.0...HEAD
26
+ [Unreleased]: https://github.com/hanami/hanami-action/compare/v3.0.1...HEAD
27
+
28
+ ## [3.0.1] - 2026-07-03
29
+
30
+ Adding an improvement that was originally intended for 3.0.0.
31
+
32
+ ### Added
33
+
34
+ - Support additional `Cache-Control` directives in `response.cache_control`: `:immutable`, `:must_understand`, `stale_while_revalidate:` (requires a duration) and `stale_if_error:` (requires a duration). (@timriley in #522)
35
+
36
+ ### Changed
37
+
38
+ - `response.cache_control` raises `ArgumentError` for unknown directives instead of silently dropping them. (@timriley in #522)
39
+
40
+ [3.0.1]: https://github.com/hanami/hanami-action/compare/v3.0.0...v3.0.1
23
41
 
24
42
  ## [3.0.0] - 2026-06-30
25
43
 
@@ -7,13 +7,30 @@ module Hanami
7
7
  #
8
8
  # @since 0.3.0
9
9
  # @api private
10
- VALUE_DIRECTIVES = %i[max_age s_maxage min_fresh max_stale].freeze
10
+ VALUE_DIRECTIVES = %i[
11
+ max_age
12
+ max_stale
13
+ min_fresh
14
+ s_maxage
15
+ stale_if_error
16
+ stale_while_revalidate
17
+ ].freeze
11
18
 
12
19
  # Cache-Control directives which are implicitly true
13
20
  #
14
21
  # @since 0.3.0
15
22
  # @api private
16
- NON_VALUE_DIRECTIVES = %i[public private no_cache no_store no_transform must_revalidate proxy_revalidate].freeze
23
+ NON_VALUE_DIRECTIVES = %i[
24
+ immutable
25
+ must_revalidate
26
+ must_understand
27
+ no_cache
28
+ no_store
29
+ no_transform
30
+ private
31
+ proxy_revalidate
32
+ public
33
+ ].freeze
17
34
 
18
35
  # Class representing value directives
19
36
  #
@@ -41,7 +58,7 @@ module Hanami
41
58
  # @since 0.3.0
42
59
  # @api private
43
60
  def valid?
44
- VALUE_DIRECTIVES.include? @name
61
+ VALUE_DIRECTIVES.include?(@name)
45
62
  end
46
63
  end
47
64
 
@@ -71,7 +88,7 @@ module Hanami
71
88
  # @since 0.3.0
72
89
  # @api private
73
90
  def valid?
74
- NON_VALUE_DIRECTIVES.include? @name
91
+ NON_VALUE_DIRECTIVES.include?(@name)
75
92
  end
76
93
  end
77
94
 
@@ -104,7 +121,11 @@ module Hanami
104
121
  # @since 0.3.0
105
122
  # @api private
106
123
  def <<(directive)
107
- @directives << directive if directive.valid?
124
+ unless directive.valid?
125
+ raise ArgumentError.new("Unknown cache control directive: #{directive.name.inspect}")
126
+ end
127
+
128
+ @directives << directive
108
129
  end
109
130
 
110
131
  # @since 0.3.0
@@ -332,12 +332,17 @@ module Hanami
332
332
 
333
333
  # Specifies the response freshness policy for HTTP caches using the `Cache-Control` header.
334
334
  #
335
- # Any number of non-value directives (`:public`, `:private`, `:no_cache`, `:no_store`,
336
- # `:must_revalidate`, `:proxy_revalidate`) may be passed along with a Hash of value directives
337
- # (`:max_age`, `:min_stale`, `:s_max_age`).
335
+ # Directives come in two forms:
338
336
  #
339
- # See [RFC 2616 / 14.9](http://tools.ietf.org/html/rfc2616#section-14.9.1) for more on
340
- # standard cache control directives.
337
+ # - Non-value directives (such as `:public` or `:no_store`) are passed as bare symbols.
338
+ # - Value directives (such as `max_age:` or `s_maxage:`) are passed as a trailing Hash.
339
+ #
340
+ # See the `@option` entries below for the full set of supported directives. Passing an unknown
341
+ # directive raises an `ArgumentError`.
342
+ #
343
+ # See [MDN's Cache-Control reference][mdn] for more on the standard cache control directives.
344
+ #
345
+ # [mdn]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Cache-Control
341
346
  #
342
347
  # @example
343
348
  # # Set Cache-Control directives
@@ -349,15 +354,21 @@ module Hanami
349
354
  # response.get_header("Cache-Control") # => "private, no-store, max-age=900"
350
355
  #
351
356
  # @param values [Array<Symbol, Hash>] values to map to `Cache-Control` directives
352
- # @option values [Symbol] :public
353
- # @option values [Symbol] :private
357
+ # @option values [Symbol] :immutable
358
+ # @option values [Symbol] :must_revalidate
359
+ # @option values [Symbol] :must_understand
354
360
  # @option values [Symbol] :no_cache
355
361
  # @option values [Symbol] :no_store
356
- # @option values [Symbol] :must_validate
362
+ # @option values [Symbol] :no_transform
363
+ # @option values [Symbol] :private
357
364
  # @option values [Symbol] :proxy_revalidate
365
+ # @option values [Symbol] :public
358
366
  # @option values [Hash] :max_age
359
- # @option values [Hash] :min_stale
360
- # @option values [Hash] :s_max_age
367
+ # @option values [Hash] :max_stale
368
+ # @option values [Hash] :min_fresh
369
+ # @option values [Hash] :s_maxage
370
+ # @option values [Hash] :stale_if_error
371
+ # @option values [Hash] :stale_while_revalidate
361
372
  #
362
373
  # @return void
363
374
  #
@@ -8,6 +8,6 @@ module Hanami
8
8
  #
9
9
  # @since 3.0.0
10
10
  # @api public
11
- VERSION = "3.0.0"
11
+ VERSION = "3.0.1"
12
12
  end
13
13
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hanami-action
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hanakai team