hanami-controller 2.0.2 → 2.1.0.beta2

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: 477af228e710dc40efbe4387c47f5cd04d24680f5041e0218390ad22e64fe349
4
- data.tar.gz: f70b9d82c375465cfebabcd00db19fb13243ea5888bc8096fbdeac3f01e86c9c
3
+ metadata.gz: 7fc2d8c6c6c5d8427e000d3a9644ca79ebb06528052d9d85796aad26f12c00dd
4
+ data.tar.gz: 689ba6ba0655450344f3e87f9a7723760a4673df0b3beb6e7b21fca8a18f7fcd
5
5
  SHA512:
6
- metadata.gz: 202511cc4ae1c987c1990a93b6041b3dc3edf8c9391d3938499aea83fe672d43f69d8cf90420d4b222de88124c1222e2aea8fbf7d981ada5a0cf0b8c8d9a40a3
7
- data.tar.gz: 4af98190f0ea03130a595cfa2cb222d321b77f22d3e9003daa932786b1bb2de68984d0175cb107b10af656e1e9409c38f4096959f570c2d5aaf168502481d435
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
@@ -1,4 +1,4 @@
1
- Copyright © 2014-2021 Luca Guidi
1
+ Copyright © 2014 Hanami Team
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -961,4 +961,4 @@ __Hanami::Controller__ uses [Semantic Versioning 2.0.0](http://semver.org)
961
961
 
962
962
  ## Copyright
963
963
 
964
- Copyright © 2014-2022 Hanami Team – Released under MIT License
964
+ Copyright © 2014 Hanami Team – Released under MIT License
@@ -29,11 +29,11 @@ module Hanami
29
29
 
30
30
  # @since 2.0.0
31
31
  # @api private
32
- def initialize(env:, params:, sessions_enabled: false)
32
+ def initialize(env:, params:, session_enabled: false)
33
33
  super(env)
34
34
 
35
35
  @params = params
36
- @sessions_enabled = sessions_enabled
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 sessions are not enabled
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 @sessions_enabled
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 @sessions_enabled
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, sessions_enabled: false) # rubocop:disable Layout/LineLength, Metrics/ParameterLists
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
- @sessions_enabled = sessions_enabled
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 @sessions_enabled
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 @sessions_enabled
233
+ unless session_enabled?
224
234
  raise Hanami::Action::MissingSessionError.new("Hanami::Action::Response#flash")
225
235
  end
226
236
 
@@ -21,7 +21,7 @@ module Hanami
21
21
 
22
22
  private
23
23
 
24
- def sessions_enabled?
24
+ def session_enabled?
25
25
  true
26
26
  end
27
27
 
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)).realpath
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
- sessions_enabled: sessions_enabled?
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
- sessions_enabled: sessions_enabled?
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#sessions_enabled?
427
+ # @see Session#session_enabled?
428
428
  # @since 2.0.0
429
429
  # @api private
430
- def sessions_enabled?
430
+ def session_enabled?
431
431
  false
432
432
  end
433
433
 
@@ -8,6 +8,6 @@ module Hanami
8
8
  #
9
9
  # @since 0.1.0
10
10
  # @api public
11
- VERSION = "2.0.2"
11
+ VERSION = "2.1.0.beta2"
12
12
  end
13
13
  end
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.2
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-02-01 00:00:00.000000000 Z
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: '0'
223
+ version: 1.3.1
224
224
  requirements: []
225
- rubygems_version: 3.4.5
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