hanami 2.0.0.beta3 → 2.0.0.beta4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +20 -0
  3. data/hanami.gemspec +5 -5
  4. data/lib/hanami/app.rb +4 -4
  5. data/lib/hanami/assets/{app_configuration.rb → app_config.rb} +10 -10
  6. data/lib/hanami/assets/{configuration.rb → config.rb} +4 -4
  7. data/lib/hanami/{configuration → config}/actions/content_security_policy.rb +2 -2
  8. data/lib/hanami/{configuration → config}/actions/cookies.rb +6 -5
  9. data/lib/hanami/{configuration → config}/actions/sessions.rb +2 -2
  10. data/lib/hanami/{configuration → config}/actions.rb +11 -12
  11. data/lib/hanami/{configuration → config}/logger.rb +2 -2
  12. data/lib/hanami/config/null_config.rb +14 -0
  13. data/lib/hanami/{configuration → config}/router.rb +8 -8
  14. data/lib/hanami/{configuration → config}/sessions.rb +2 -2
  15. data/lib/hanami/{configuration → config}/views.rb +10 -10
  16. data/lib/hanami/{configuration.rb → config.rb} +19 -19
  17. data/lib/hanami/errors.rb +3 -0
  18. data/lib/hanami/extensions/action/slice_configured_action.rb +1 -1
  19. data/lib/hanami/providers/inflector.rb +0 -2
  20. data/lib/hanami/providers/logger.rb +1 -3
  21. data/lib/hanami/providers/rack.rb +0 -2
  22. data/lib/hanami/providers/routes.rb +0 -2
  23. data/lib/hanami/settings/env_store.rb +3 -3
  24. data/lib/hanami/settings.rb +87 -5
  25. data/lib/hanami/slice/routing/middleware/stack.rb +45 -1
  26. data/lib/hanami/slice.rb +52 -37
  27. data/lib/hanami/slice_configurable.rb +1 -1
  28. data/lib/hanami/slice_registrar.rb +6 -0
  29. data/lib/hanami/version.rb +1 -1
  30. data/lib/hanami.rb +0 -1
  31. data/spec/integration/container/prepare_container_spec.rb +2 -0
  32. data/spec/integration/rack_app/body_parser_spec.rb +108 -0
  33. data/spec/integration/rack_app/middleware_spec.rb +28 -0
  34. data/spec/integration/settings/access_in_slice_class_body_spec.rb +82 -0
  35. data/spec/integration/settings/access_to_constants_spec.rb +23 -146
  36. data/spec/integration/{slices/slice_settings_spec.rb → settings/slice_registration_spec.rb} +5 -1
  37. data/spec/integration/settings/using_types_spec.rb +4 -11
  38. data/spec/support/app_integration.rb +18 -15
  39. data/spec/unit/hanami/{configuration → config}/actions/content_security_policy_spec.rb +10 -10
  40. data/spec/unit/hanami/{configuration → config}/actions/cookies_spec.rb +6 -6
  41. data/spec/unit/hanami/{configuration → config}/actions/csrf_protection_spec.rb +12 -12
  42. data/spec/unit/hanami/config/actions/default_values_spec.rb +54 -0
  43. data/spec/unit/hanami/{configuration → config}/actions/sessions_spec.rb +5 -5
  44. data/spec/unit/hanami/{configuration → config}/actions_spec.rb +9 -10
  45. data/spec/unit/hanami/{configuration → config}/base_url_spec.rb +2 -2
  46. data/spec/unit/hanami/{configuration → config}/inflector_spec.rb +2 -2
  47. data/spec/unit/hanami/{configuration → config}/logger_spec.rb +4 -4
  48. data/spec/unit/hanami/{configuration → config}/router_spec.rb +7 -8
  49. data/spec/unit/hanami/{configuration → config}/slices_spec.rb +2 -2
  50. data/spec/unit/hanami/{configuration → config}/views_spec.rb +11 -12
  51. data/spec/unit/hanami/{configuration_spec.rb → config_spec.rb} +3 -3
  52. data/spec/unit/hanami/settings_spec.rb +65 -10
  53. data/spec/unit/hanami/slice_configurable_spec.rb +21 -2
  54. data/spec/unit/hanami/version_spec.rb +1 -1
  55. metadata +73 -58
  56. data/lib/hanami/configuration/null_configuration.rb +0 -14
  57. data/lib/hanami/providers/settings.rb +0 -98
  58. data/spec/unit/hanami/configuration/actions/default_values_spec.rb +0 -52
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "dry/inflector"
4
- require "hanami/configuration"
4
+ require "hanami/config"
5
5
  require "hanami/slice_name"
6
6
 
7
- RSpec.describe Hanami::Configuration, "#slices" do
7
+ RSpec.describe Hanami::Config, "#slices" do
8
8
  subject(:config) { described_class.new(app_name: app_name, env: :development) }
9
9
  let(:app_name) { Hanami::SliceName.new(double(name: "MyApp::App"), inflector: Dry::Inflector.new) }
10
10
 
@@ -1,25 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "hanami/configuration"
4
- require "hanami/configuration/views"
3
+ require "hanami/config"
5
4
  require "saharspec/matchers/dont"
6
5
 
7
- RSpec.describe Hanami::Configuration, "#views" do
8
- let(:configuration) { described_class.new(app_name: app_name, env: :development) }
6
+ RSpec.describe Hanami::Config, "#views" do
7
+ let(:config) { described_class.new(app_name: app_name, env: :development) }
9
8
  let(:app_name) { "MyApp::app" }
10
9
 
11
- subject(:views) { configuration.views }
10
+ subject(:views) { config.views }
12
11
 
13
12
  context "hanami-view is bundled" do
14
- it "exposes Hanami::Views's app configuration" do
15
- is_expected.to be_an_instance_of(Hanami::Configuration::Views)
13
+ it "exposes Hanami::Views's app config" do
14
+ is_expected.to be_an_instance_of(Hanami::Config::Views)
16
15
 
17
16
  is_expected.to respond_to(:finalize!)
18
17
  is_expected.to respond_to(:layouts_dir)
19
18
  is_expected.to respond_to(:layouts_dir=)
20
19
  end
21
20
 
22
- it "includes base view configuration" do
21
+ it "includes base view config" do
23
22
  expect(views).to respond_to(:paths)
24
23
  expect(views).to respond_to(:paths=)
25
24
  end
@@ -39,11 +38,11 @@ RSpec.describe Hanami::Configuration, "#views" do
39
38
  end
40
39
  end
41
40
 
42
- it "preserves default values from the base view configuration" do
41
+ it "preserves default values from the base view config" do
43
42
  expect(views.layouts_dir).to eq Hanami::View.config.layouts_dir
44
43
  end
45
44
 
46
- it "allows settings to be configured independently of the base view configuration" do
45
+ it "allows settings to be configured independently of the base view config" do
47
46
  expect { views.layouts_dir = "custom_layouts" }
48
47
  .to change { views.layouts_dir }.to("custom_layouts")
49
48
  .and(dont.change { Hanami::View.config.layouts_dir })
@@ -71,7 +70,7 @@ RSpec.describe Hanami::Configuration, "#views" do
71
70
  end
72
71
  end
73
72
 
74
- describe "finalized configuration" do
73
+ describe "finalized config" do
75
74
  before do
76
75
  views.finalize!
77
76
  end
@@ -97,7 +96,7 @@ RSpec.describe Hanami::Configuration, "#views" do
97
96
  end
98
97
 
99
98
  it "does not expose any settings" do
100
- is_expected.not_to be_an_instance_of(Hanami::Configuration::Views)
99
+ is_expected.not_to be_an_instance_of(Hanami::Config::Views)
101
100
  is_expected.not_to respond_to(:layouts_dir)
102
101
  is_expected.not_to respond_to(:layouts_dir=)
103
102
  end
@@ -1,11 +1,11 @@
1
- require "hanami/configuration"
1
+ require "hanami/config"
2
2
 
3
- RSpec.describe Hanami::Configuration do
3
+ RSpec.describe Hanami::Config do
4
4
  let(:config) { described_class.new(app_name: app_name, env: env) }
5
5
  let(:app_name) { "MyApp::app" }
6
6
  let(:env) { :development }
7
7
 
8
- describe "environment-specific configuration" do
8
+ describe "environment-specific config" do
9
9
  before do
10
10
  config.logger.level = :debug__set_without_env
11
11
  end
@@ -5,51 +5,106 @@ require "hanami/settings"
5
5
  RSpec.describe Hanami::Settings do
6
6
  describe "#initialize" do
7
7
  it "uses values from the store when present" do
8
- config_class = Class.new(described_class) do
8
+ settings_class = Class.new(described_class) do
9
9
  setting :database_url, default: "postgres://localhost/test_app_development"
10
10
  end
11
- store = { database_url: "mysql://localhost/test_app_development" }.freeze
12
11
 
13
- instance = config_class.new(store)
12
+ store = {database_url: "mysql://localhost/test_app_development"}.freeze
13
+
14
+ instance = settings_class.new(store)
14
15
 
15
16
  expect(instance.config.database_url).to eq("mysql://localhost/test_app_development")
16
17
  end
17
18
 
18
19
  it "uses defaults when values are not present in the store" do
19
- config_class = Class.new(described_class) do
20
+ settings_class = Class.new(described_class) do
20
21
  setting :database_url, default: "postgres://localhost/test_app_development"
21
22
  end
23
+
22
24
  store = {}.freeze
23
25
 
24
- instance = config_class.new(store)
26
+ instance = settings_class.new(store)
25
27
 
26
28
  expect(instance.config.database_url).to eq("postgres://localhost/test_app_development")
27
29
  end
28
30
 
29
- it "collects error for all failed settings" do
30
- config_class = Class.new(described_class) do
31
+ it "collects error for all setting values failing their constructors" do
32
+ settings_class = Class.new(described_class) do
31
33
  setting :database_url, constructor: ->(_v) { raise "nope to database" }
32
34
  setting :redis_url, constructor: ->(_v) { raise "nope to redis" }
33
35
  end
36
+
34
37
  store = {
35
38
  database_url: "postgres://localhost/test_app_development",
36
39
  redis_url: "redis://localhost:6379"
37
40
  }.freeze
38
41
 
39
- expect { config_class.new(store) }.to raise_error(
42
+ expect { settings_class.new(store) }.to raise_error(
40
43
  described_class::InvalidSettingsError,
41
44
  /(database_url: nope to database).*(redis_url: nope to redis)/m,
42
45
  )
43
46
  end
47
+
48
+ it "collects errors for missing settings failing their constructors" do
49
+ settings_class = Class.new(described_class) do
50
+ setting :database_url, constructor: ->(_v) { raise "nope to database" }
51
+ end
52
+
53
+ store = {}
54
+
55
+ expect { settings_class.new(store) }.to raise_error(
56
+ described_class::InvalidSettingsError,
57
+ /database_url: nope to database/m,
58
+ )
59
+ end
60
+
61
+ it "finalizes the config" do
62
+ settings_class = Class.new(described_class) do
63
+ setting :database_url
64
+ end
65
+
66
+ store = {database_url: "postgres://localhost/test_app_development"}
67
+
68
+ settings = settings_class.new(store)
69
+
70
+ expect(settings.config).to be_frozen
71
+ expect { settings.database_url = "new" }.to raise_error(Dry::Configurable::FrozenConfig)
72
+ end
73
+ end
74
+
75
+ describe "#inspect" do
76
+ it "shows keys" do
77
+ settings_class = Class.new(described_class) do
78
+ setting :password, default: "dont_tell_anybody"
79
+ setting :passphrase, default: "shhhh"
80
+ end
81
+
82
+ expect(settings_class.new.inspect).to eq(
83
+ "#<#{settings_class.to_s} [password, passphrase]>"
84
+ )
85
+ end
86
+ end
87
+
88
+ describe "#inspect_values" do
89
+ it "shows keys & values" do
90
+ settings_class = Class.new(described_class) do
91
+ setting :password, default: "dont_tell_anybody"
92
+ setting :passphrase, default: "shhh"
93
+ end
94
+
95
+ expect(settings_class.new.inspect_values).to eq(
96
+ "#<#{settings_class.to_s} password=\"dont_tell_anybody\" passphrase=\"shhh\">"
97
+ )
98
+ end
44
99
  end
45
100
 
46
101
  it "delegates unknown methods to config" do
47
- config_class = Class.new(described_class) do
102
+ settings_class = Class.new(described_class) do
48
103
  setting :foo, default: "bar"
49
104
  end
50
105
  store = {}.freeze
51
106
 
52
- instance = config_class.new(store)
107
+ instance = settings_class.new(store)
53
108
 
54
109
  expect(instance.foo).to eq("bar")
55
110
  end
@@ -28,8 +28,6 @@ RSpec.describe Hanami::SliceConfigurable, :app_integration do
28
28
  end
29
29
  end
30
30
  end
31
-
32
- Hanami.app.prepare
33
31
  end
34
32
 
35
33
  context "subclass inside slice namespace" do
@@ -101,4 +99,25 @@ RSpec.describe Hanami::SliceConfigurable, :app_integration do
101
99
  end
102
100
  end
103
101
  end
102
+
103
+ context "subclass inside nested slice namespace" do
104
+ before do
105
+ module Main
106
+ class Slice
107
+ register_slice :nested
108
+ end
109
+ end
110
+
111
+ module Nested
112
+ class MySubclass < TestApp::BaseClass
113
+ end
114
+ end
115
+ end
116
+
117
+ subject(:subclass) { Nested::MySubclass }
118
+
119
+ it "calls `configure_for_slice` with the nested slice" do
120
+ expect(subclass.traces).to eq [Nested::Slice]
121
+ end
122
+ end
104
123
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  RSpec.describe "Hanami::VERSION" do
4
4
  it "returns current version" do
5
- expect(Hanami::VERSION).to eq("2.0.0.beta3")
5
+ expect(Hanami::VERSION).to eq("2.0.0.beta4")
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hanami
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.beta3
4
+ version: 2.0.0.beta4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Guidi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-21 00:00:00.000000000 Z
11
+ date: 2022-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -36,28 +36,40 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '0.15'
39
+ version: '0.16'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 0.16.1
40
43
  type: :runtime
41
44
  prerelease: false
42
45
  version_requirements: !ruby/object:Gem::Requirement
43
46
  requirements:
44
47
  - - "~>"
45
48
  - !ruby/object:Gem::Version
46
- version: '0.15'
49
+ version: '0.16'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 0.16.1
47
53
  - !ruby/object:Gem::Dependency
48
54
  name: dry-core
49
55
  requirement: !ruby/object:Gem::Requirement
50
56
  requirements:
51
57
  - - "~>"
52
58
  - !ruby/object:Gem::Version
53
- version: '0.7'
59
+ version: '0.9'
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 0.9.1
54
63
  type: :runtime
55
64
  prerelease: false
56
65
  version_requirements: !ruby/object:Gem::Requirement
57
66
  requirements:
58
67
  - - "~>"
59
68
  - !ruby/object:Gem::Version
60
- version: '0.7'
69
+ version: '0.9'
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: 0.9.1
61
73
  - !ruby/object:Gem::Dependency
62
74
  name: dry-inflector
63
75
  requirement: !ruby/object:Gem::Requirement
@@ -84,40 +96,40 @@ dependencies:
84
96
  requirements:
85
97
  - - "~>"
86
98
  - !ruby/object:Gem::Version
87
- version: '0.25'
99
+ version: '0.27'
88
100
  - - ">="
89
101
  - !ruby/object:Gem::Version
90
- version: 0.25.0
102
+ version: 0.27.2
91
103
  type: :runtime
92
104
  prerelease: false
93
105
  version_requirements: !ruby/object:Gem::Requirement
94
106
  requirements:
95
107
  - - "~>"
96
108
  - !ruby/object:Gem::Version
97
- version: '0.25'
109
+ version: '0.27'
98
110
  - - ">="
99
111
  - !ruby/object:Gem::Version
100
- version: 0.25.0
112
+ version: 0.27.2
101
113
  - !ruby/object:Gem::Dependency
102
114
  name: dry-monitor
103
115
  requirement: !ruby/object:Gem::Requirement
104
116
  requirements:
105
117
  - - "~>"
106
118
  - !ruby/object:Gem::Version
107
- version: '0.6'
119
+ version: '0.7'
108
120
  - - ">="
109
121
  - !ruby/object:Gem::Version
110
- version: 0.6.3
122
+ version: '0.7'
111
123
  type: :runtime
112
124
  prerelease: false
113
125
  version_requirements: !ruby/object:Gem::Requirement
114
126
  requirements:
115
127
  - - "~>"
116
128
  - !ruby/object:Gem::Version
117
- version: '0.6'
129
+ version: '0.7'
118
130
  - - ">="
119
131
  - !ruby/object:Gem::Version
120
- version: 0.6.3
132
+ version: '0.7'
121
133
  - !ruby/object:Gem::Dependency
122
134
  name: hanami-cli
123
135
  requirement: !ruby/object:Gem::Requirement
@@ -152,14 +164,14 @@ dependencies:
152
164
  requirements:
153
165
  - - "~>"
154
166
  - !ruby/object:Gem::Version
155
- version: '2.4'
167
+ version: '2.6'
156
168
  type: :runtime
157
169
  prerelease: false
158
170
  version_requirements: !ruby/object:Gem::Requirement
159
171
  requirements:
160
172
  - - "~>"
161
173
  - !ruby/object:Gem::Version
162
- version: '2.4'
174
+ version: '2.6'
163
175
  - !ruby/object:Gem::Dependency
164
176
  name: rspec
165
177
  requirement: !ruby/object:Gem::Requirement
@@ -217,19 +229,19 @@ files:
217
229
  - hanami.gemspec
218
230
  - lib/hanami.rb
219
231
  - lib/hanami/app.rb
220
- - lib/hanami/assets/app_configuration.rb
221
- - lib/hanami/assets/configuration.rb
232
+ - lib/hanami/assets/app_config.rb
233
+ - lib/hanami/assets/config.rb
222
234
  - lib/hanami/boot.rb
223
- - lib/hanami/configuration.rb
224
- - lib/hanami/configuration/actions.rb
225
- - lib/hanami/configuration/actions/content_security_policy.rb
226
- - lib/hanami/configuration/actions/cookies.rb
227
- - lib/hanami/configuration/actions/sessions.rb
228
- - lib/hanami/configuration/logger.rb
229
- - lib/hanami/configuration/null_configuration.rb
230
- - lib/hanami/configuration/router.rb
231
- - lib/hanami/configuration/sessions.rb
232
- - lib/hanami/configuration/views.rb
235
+ - lib/hanami/config.rb
236
+ - lib/hanami/config/actions.rb
237
+ - lib/hanami/config/actions/content_security_policy.rb
238
+ - lib/hanami/config/actions/cookies.rb
239
+ - lib/hanami/config/actions/sessions.rb
240
+ - lib/hanami/config/logger.rb
241
+ - lib/hanami/config/null_config.rb
242
+ - lib/hanami/config/router.rb
243
+ - lib/hanami/config/sessions.rb
244
+ - lib/hanami/config/views.rb
233
245
  - lib/hanami/constants.rb
234
246
  - lib/hanami/errors.rb
235
247
  - lib/hanami/extensions.rb
@@ -244,7 +256,6 @@ files:
244
256
  - lib/hanami/providers/logger.rb
245
257
  - lib/hanami/providers/rack.rb
246
258
  - lib/hanami/providers/routes.rb
247
- - lib/hanami/providers/settings.rb
248
259
  - lib/hanami/rake_tasks.rb
249
260
  - lib/hanami/routes.rb
250
261
  - lib/hanami/settings.rb
@@ -282,19 +293,21 @@ files:
282
293
  - spec/integration/container/shutdown_spec.rb
283
294
  - spec/integration/container/standard_bootable_components_spec.rb
284
295
  - spec/integration/dotenv_loading_spec.rb
296
+ - spec/integration/rack_app/body_parser_spec.rb
285
297
  - spec/integration/rack_app/middleware_spec.rb
286
298
  - spec/integration/rack_app/non_booted_rack_app_spec.rb
287
299
  - spec/integration/rack_app/rack_app_spec.rb
300
+ - spec/integration/settings/access_in_slice_class_body_spec.rb
288
301
  - spec/integration/settings/access_to_constants_spec.rb
289
302
  - spec/integration/settings/loading_from_env_spec.rb
290
303
  - spec/integration/settings/settings_component_loading_spec.rb
304
+ - spec/integration/settings/slice_registration_spec.rb
291
305
  - spec/integration/settings/using_types_spec.rb
292
306
  - spec/integration/setup_spec.rb
293
307
  - spec/integration/slices/external_slice_spec.rb
294
308
  - spec/integration/slices/slice_configuration_spec.rb
295
309
  - spec/integration/slices/slice_loading_spec.rb
296
310
  - spec/integration/slices/slice_routing_spec.rb
297
- - spec/integration/slices/slice_settings_spec.rb
298
311
  - spec/integration/slices_spec.rb
299
312
  - spec/integration/view/context/assets_spec.rb
300
313
  - spec/integration/view/context/inflector_spec.rb
@@ -322,19 +335,19 @@ files:
322
335
  - spec/support/shared_examples/cli/generate/migration.rb
323
336
  - spec/support/shared_examples/cli/generate/model.rb
324
337
  - spec/support/shared_examples/cli/new.rb
325
- - spec/unit/hanami/configuration/actions/content_security_policy_spec.rb
326
- - spec/unit/hanami/configuration/actions/cookies_spec.rb
327
- - spec/unit/hanami/configuration/actions/csrf_protection_spec.rb
328
- - spec/unit/hanami/configuration/actions/default_values_spec.rb
329
- - spec/unit/hanami/configuration/actions/sessions_spec.rb
330
- - spec/unit/hanami/configuration/actions_spec.rb
331
- - spec/unit/hanami/configuration/base_url_spec.rb
332
- - spec/unit/hanami/configuration/inflector_spec.rb
333
- - spec/unit/hanami/configuration/logger_spec.rb
334
- - spec/unit/hanami/configuration/router_spec.rb
335
- - spec/unit/hanami/configuration/slices_spec.rb
336
- - spec/unit/hanami/configuration/views_spec.rb
337
- - spec/unit/hanami/configuration_spec.rb
338
+ - spec/unit/hanami/config/actions/content_security_policy_spec.rb
339
+ - spec/unit/hanami/config/actions/cookies_spec.rb
340
+ - spec/unit/hanami/config/actions/csrf_protection_spec.rb
341
+ - spec/unit/hanami/config/actions/default_values_spec.rb
342
+ - spec/unit/hanami/config/actions/sessions_spec.rb
343
+ - spec/unit/hanami/config/actions_spec.rb
344
+ - spec/unit/hanami/config/base_url_spec.rb
345
+ - spec/unit/hanami/config/inflector_spec.rb
346
+ - spec/unit/hanami/config/logger_spec.rb
347
+ - spec/unit/hanami/config/router_spec.rb
348
+ - spec/unit/hanami/config/slices_spec.rb
349
+ - spec/unit/hanami/config/views_spec.rb
350
+ - spec/unit/hanami/config_spec.rb
338
351
  - spec/unit/hanami/env_spec.rb
339
352
  - spec/unit/hanami/settings/env_store_spec.rb
340
353
  - spec/unit/hanami/settings_spec.rb
@@ -364,7 +377,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
364
377
  - !ruby/object:Gem::Version
365
378
  version: 1.3.1
366
379
  requirements: []
367
- rubygems_version: 3.3.3
380
+ rubygems_version: 3.3.7
368
381
  signing_key:
369
382
  specification_version: 4
370
383
  summary: The web, with simplicity
@@ -390,19 +403,21 @@ test_files:
390
403
  - spec/integration/container/shutdown_spec.rb
391
404
  - spec/integration/container/standard_bootable_components_spec.rb
392
405
  - spec/integration/dotenv_loading_spec.rb
406
+ - spec/integration/rack_app/body_parser_spec.rb
393
407
  - spec/integration/rack_app/middleware_spec.rb
394
408
  - spec/integration/rack_app/non_booted_rack_app_spec.rb
395
409
  - spec/integration/rack_app/rack_app_spec.rb
410
+ - spec/integration/settings/access_in_slice_class_body_spec.rb
396
411
  - spec/integration/settings/access_to_constants_spec.rb
397
412
  - spec/integration/settings/loading_from_env_spec.rb
398
413
  - spec/integration/settings/settings_component_loading_spec.rb
414
+ - spec/integration/settings/slice_registration_spec.rb
399
415
  - spec/integration/settings/using_types_spec.rb
400
416
  - spec/integration/setup_spec.rb
401
417
  - spec/integration/slices/external_slice_spec.rb
402
418
  - spec/integration/slices/slice_configuration_spec.rb
403
419
  - spec/integration/slices/slice_loading_spec.rb
404
420
  - spec/integration/slices/slice_routing_spec.rb
405
- - spec/integration/slices/slice_settings_spec.rb
406
421
  - spec/integration/slices_spec.rb
407
422
  - spec/integration/view/context/assets_spec.rb
408
423
  - spec/integration/view/context/inflector_spec.rb
@@ -430,19 +445,19 @@ test_files:
430
445
  - spec/support/shared_examples/cli/generate/migration.rb
431
446
  - spec/support/shared_examples/cli/generate/model.rb
432
447
  - spec/support/shared_examples/cli/new.rb
433
- - spec/unit/hanami/configuration/actions/content_security_policy_spec.rb
434
- - spec/unit/hanami/configuration/actions/cookies_spec.rb
435
- - spec/unit/hanami/configuration/actions/csrf_protection_spec.rb
436
- - spec/unit/hanami/configuration/actions/default_values_spec.rb
437
- - spec/unit/hanami/configuration/actions/sessions_spec.rb
438
- - spec/unit/hanami/configuration/actions_spec.rb
439
- - spec/unit/hanami/configuration/base_url_spec.rb
440
- - spec/unit/hanami/configuration/inflector_spec.rb
441
- - spec/unit/hanami/configuration/logger_spec.rb
442
- - spec/unit/hanami/configuration/router_spec.rb
443
- - spec/unit/hanami/configuration/slices_spec.rb
444
- - spec/unit/hanami/configuration/views_spec.rb
445
- - spec/unit/hanami/configuration_spec.rb
448
+ - spec/unit/hanami/config/actions/content_security_policy_spec.rb
449
+ - spec/unit/hanami/config/actions/cookies_spec.rb
450
+ - spec/unit/hanami/config/actions/csrf_protection_spec.rb
451
+ - spec/unit/hanami/config/actions/default_values_spec.rb
452
+ - spec/unit/hanami/config/actions/sessions_spec.rb
453
+ - spec/unit/hanami/config/actions_spec.rb
454
+ - spec/unit/hanami/config/base_url_spec.rb
455
+ - spec/unit/hanami/config/inflector_spec.rb
456
+ - spec/unit/hanami/config/logger_spec.rb
457
+ - spec/unit/hanami/config/router_spec.rb
458
+ - spec/unit/hanami/config/slices_spec.rb
459
+ - spec/unit/hanami/config/views_spec.rb
460
+ - spec/unit/hanami/config_spec.rb
446
461
  - spec/unit/hanami/env_spec.rb
447
462
  - spec/unit/hanami/settings/env_store_spec.rb
448
463
  - spec/unit/hanami/settings_spec.rb
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "dry/configurable"
4
-
5
- module Hanami
6
- class Configuration
7
- # NullConfiguration can serve as a fallback configuration object when out-of-gem
8
- # configuration objects are not available (specifically, when the
9
- # hanami-controller, hanami-router or hanami-view gems are not loaded)
10
- class NullConfiguration
11
- include Dry::Configurable
12
- end
13
- end
14
- end
@@ -1,98 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "dry/system/provider/source"
4
- require_relative "../constants"
5
- require_relative "../errors"
6
-
7
- module Hanami
8
- module Providers
9
- # The settings provider loads and registers the "settings" component in app and slice
10
- # containers.
11
- #
12
- # To register this provider with a slice container, you should use
13
- # {.register_with_slice}, which will register the provider only if settings are
14
- # defined for the slice.
15
- #
16
- # @see Slice::ClassMethods.prepare_container_providers
17
- #
18
- # @api private
19
- # @since 2.0.0
20
- class Settings < Dry::System::Provider::Source
21
- class << self
22
- # Registers the provider with the slice's container, but only if settings are
23
- # defined for the slice.
24
- def register_with_slice(slice)
25
- return unless settings_defined?(slice)
26
-
27
- slice.register_provider(:settings, source: with_slice(slice))
28
- end
29
-
30
- # Creates a new subclass of the provider for the given slice.
31
- #
32
- # You must do this before registering the provider with a container. The provider
33
- # uses the slice to locate the settings definition based on the slice's config.
34
- def with_slice(slice)
35
- Class.new(self) do |klass|
36
- klass.instance_variable_set(:@slice, slice)
37
- end
38
- end
39
-
40
- # Returns the slice for the provider
41
- def slice
42
- unless @slice
43
- raise SliceLoadError, "a slice must be given to #{self} via `.with_slice(slice)`"
44
- end
45
-
46
- @slice
47
- end
48
-
49
- private
50
-
51
- # Returns true if settings are defined for the slice.
52
- #
53
- # Settings are considered defined if a `Settings` class is already defined in the
54
- # slice namespace, or a `config/settings.rb` exists under the slice root.
55
- def settings_defined?(slice)
56
- slice.namespace.const_defined?(SETTINGS_CLASS_NAME) ||
57
- slice.root.join("#{SETTINGS_PATH}#{RB_EXT}").file?
58
- end
59
- end
60
-
61
- def prepare
62
- require_slice_settings unless slice_settings_class?
63
- end
64
-
65
- def start
66
- settings = slice_settings_class.new(slice.config.settings_store)
67
-
68
- register :settings, settings
69
- end
70
-
71
- private
72
-
73
- def slice
74
- self.class.slice
75
- end
76
-
77
- def slice_settings_class?
78
- slice.namespace.const_defined?(SETTINGS_CLASS_NAME)
79
- end
80
-
81
- def slice_settings_class
82
- slice.namespace.const_get(SETTINGS_CLASS_NAME)
83
- end
84
-
85
- def require_slice_settings
86
- require "hanami/settings"
87
-
88
- slice_settings_require_path = File.join(slice.root, SETTINGS_PATH)
89
-
90
- begin
91
- require slice_settings_require_path
92
- rescue LoadError => e
93
- raise e unless e.path == slice_settings_require_path
94
- end
95
- end
96
- end
97
- end
98
- end