hanami-controller 2.0.2 → 2.1.0.beta2
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 +4 -4
- data/CHANGELOG.md +12 -0
- data/LICENSE.md +1 -1
- data/README.md +1 -1
- data/lib/hanami/action/request.rb +16 -5
- data/lib/hanami/action/response.rb +14 -4
- data/lib/hanami/action/session.rb +1 -1
- data/lib/hanami/action.rb +5 -5
- data/lib/hanami/controller/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7fc2d8c6c6c5d8427e000d3a9644ca79ebb06528052d9d85796aad26f12c00dd
|
4
|
+
data.tar.gz: 689ba6ba0655450344f3e87f9a7723760a4673df0b3beb6e7b21fca8a18f7fcd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e8bf47095abf0da69058e26e0d627cbb664c9b861a35de3b84173836f8cb76773bdf78ff233aedf8e09819de8f4ca5cc53f5116f73dd7d63fb54b1ae9c90656
|
7
|
+
data.tar.gz: b09e1c0506ef1e309e6c53bc37ad503dd8821b159d4a60bd1142be3b105cb24ff67abd57871005eddc807451712dbf507e24c95e0c2ff0f38b8e53d9160329b8
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,18 @@
|
|
2
2
|
|
3
3
|
Complete, fast and testable actions for Rack
|
4
4
|
|
5
|
+
## v2.1.0.beta2 - 2023-10-04
|
6
|
+
|
7
|
+
### Fixed
|
8
|
+
|
9
|
+
- [Luca Guidi] `Hanami::Action::Config#root`: don't check realpath existence to simplify the boot process of Hanami (#429)
|
10
|
+
|
11
|
+
## v2.1.0.beta1 - 2023-06-29
|
12
|
+
|
13
|
+
### Added
|
14
|
+
|
15
|
+
- [Tim Riley] Add `Request#session_enabled?` and `Response#session_enabled?` (#423)
|
16
|
+
|
5
17
|
## v2.0.2 - 2023-02-01
|
6
18
|
|
7
19
|
### Added
|
data/LICENSE.md
CHANGED
data/README.md
CHANGED
@@ -29,11 +29,11 @@ module Hanami
|
|
29
29
|
|
30
30
|
# @since 2.0.0
|
31
31
|
# @api private
|
32
|
-
def initialize(env:, params:,
|
32
|
+
def initialize(env:, params:, session_enabled: false)
|
33
33
|
super(env)
|
34
34
|
|
35
35
|
@params = params
|
36
|
-
@
|
36
|
+
@session_enabled = session_enabled
|
37
37
|
end
|
38
38
|
|
39
39
|
# Returns the request's ID
|
@@ -47,18 +47,29 @@ module Hanami
|
|
47
47
|
@id ||= @env[Action::REQUEST_ID] = SecureRandom.hex(Action::DEFAULT_ID_LENGTH)
|
48
48
|
end
|
49
49
|
|
50
|
+
# Returns true if the session is enabled for the request.
|
51
|
+
#
|
52
|
+
# @return [Boolean]
|
53
|
+
#
|
54
|
+
# @api public
|
55
|
+
# @since 2.1.0
|
56
|
+
def session_enabled?
|
57
|
+
@session_enabled
|
58
|
+
end
|
59
|
+
|
50
60
|
# Returns the session for the request.
|
51
61
|
#
|
52
62
|
# @return [Hash] the session object
|
53
63
|
#
|
54
|
-
# @raise [MissingSessionError] if
|
64
|
+
# @raise [MissingSessionError] if the session is not enabled
|
55
65
|
#
|
66
|
+
# @see #session_enabled?
|
56
67
|
# @see Response#session
|
57
68
|
#
|
58
69
|
# @since 2.0.0
|
59
70
|
# @api public
|
60
71
|
def session
|
61
|
-
unless
|
72
|
+
unless session_enabled?
|
62
73
|
raise Hanami::Action::MissingSessionError.new("Hanami::Action::Request#session")
|
63
74
|
end
|
64
75
|
|
@@ -76,7 +87,7 @@ module Hanami
|
|
76
87
|
# @since 2.0.0
|
77
88
|
# @api public
|
78
89
|
def flash
|
79
|
-
unless
|
90
|
+
unless session_enabled?
|
80
91
|
raise Hanami::Action::MissingSessionError.new("Hanami::Action::Request#flash")
|
81
92
|
end
|
82
93
|
|
@@ -48,7 +48,7 @@ module Hanami
|
|
48
48
|
|
49
49
|
# @since 2.0.0
|
50
50
|
# @api private
|
51
|
-
def initialize(request:, config:, content_type: nil, env: {}, headers: {}, view_options: nil,
|
51
|
+
def initialize(request:, config:, content_type: nil, env: {}, headers: {}, view_options: nil, session_enabled: false) # rubocop:disable Layout/LineLength, Metrics/ParameterLists
|
52
52
|
super([], 200, headers.dup)
|
53
53
|
self.content_type = content_type if content_type
|
54
54
|
|
@@ -59,7 +59,7 @@ module Hanami
|
|
59
59
|
@env = env
|
60
60
|
@view_options = view_options || DEFAULT_VIEW_OPTIONS
|
61
61
|
|
62
|
-
@
|
62
|
+
@session_enabled = session_enabled
|
63
63
|
@sending_file = false
|
64
64
|
end
|
65
65
|
|
@@ -187,6 +187,16 @@ module Hanami
|
|
187
187
|
@exposures[key] = value
|
188
188
|
end
|
189
189
|
|
190
|
+
# Returns true if the session is enabled for the request.
|
191
|
+
#
|
192
|
+
# @return [Boolean]
|
193
|
+
#
|
194
|
+
# @api public
|
195
|
+
# @since 2.1.0
|
196
|
+
def session_enabled?
|
197
|
+
@session_enabled
|
198
|
+
end
|
199
|
+
|
190
200
|
# Returns the session for the response.
|
191
201
|
#
|
192
202
|
# This is the same session object as the {Request}.
|
@@ -200,7 +210,7 @@ module Hanami
|
|
200
210
|
# @since 2.0.0
|
201
211
|
# @api public
|
202
212
|
def session
|
203
|
-
unless
|
213
|
+
unless session_enabled?
|
204
214
|
raise Hanami::Action::MissingSessionError.new("Hanami::Action::Response#session")
|
205
215
|
end
|
206
216
|
|
@@ -220,7 +230,7 @@ module Hanami
|
|
220
230
|
# @since 2.0.0
|
221
231
|
# @api public
|
222
232
|
def flash
|
223
|
-
unless
|
233
|
+
unless session_enabled?
|
224
234
|
raise Hanami::Action::MissingSessionError.new("Hanami::Action::Response#flash")
|
225
235
|
end
|
226
236
|
|
data/lib/hanami/action.rb
CHANGED
@@ -67,7 +67,7 @@ module Hanami
|
|
67
67
|
cookie_options.to_h.compact
|
68
68
|
}
|
69
69
|
setting :root_directory, constructor: -> (dir) {
|
70
|
-
Pathname(File.expand_path(dir || Dir.pwd))
|
70
|
+
Pathname(File.expand_path(dir || Dir.pwd))
|
71
71
|
}
|
72
72
|
setting :public_directory, default: Config::DEFAULT_PUBLIC_DIRECTORY
|
73
73
|
setting :before_callbacks, default: Utils::Callbacks::Chain.new, mutable: true
|
@@ -309,7 +309,7 @@ module Hanami
|
|
309
309
|
request = build_request(
|
310
310
|
env: env,
|
311
311
|
params: params,
|
312
|
-
|
312
|
+
session_enabled: session_enabled?
|
313
313
|
)
|
314
314
|
response = build_response(
|
315
315
|
request: request,
|
@@ -317,7 +317,7 @@ module Hanami
|
|
317
317
|
content_type: Mime.response_content_type_with_charset(request, config),
|
318
318
|
env: env,
|
319
319
|
headers: config.default_headers,
|
320
|
-
|
320
|
+
session_enabled: session_enabled?
|
321
321
|
)
|
322
322
|
|
323
323
|
enforce_accepted_mime_types(request)
|
@@ -424,10 +424,10 @@ module Hanami
|
|
424
424
|
nil
|
425
425
|
end
|
426
426
|
|
427
|
-
# @see Session#
|
427
|
+
# @see Session#session_enabled?
|
428
428
|
# @since 2.0.0
|
429
429
|
# @api private
|
430
|
-
def
|
430
|
+
def session_enabled?
|
431
431
|
false
|
432
432
|
end
|
433
433
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hanami-controller
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.1.0.beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luca Guidi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -218,11 +218,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
218
218
|
version: '3.0'
|
219
219
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
220
220
|
requirements:
|
221
|
-
- - "
|
221
|
+
- - ">"
|
222
222
|
- !ruby/object:Gem::Version
|
223
|
-
version:
|
223
|
+
version: 1.3.1
|
224
224
|
requirements: []
|
225
|
-
rubygems_version: 3.4.
|
225
|
+
rubygems_version: 3.4.13
|
226
226
|
signing_key:
|
227
227
|
specification_version: 4
|
228
228
|
summary: Complete, fast and testable actions for Rack and Hanami
|