hanami 2.0.0.beta3 → 2.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +39 -0
- data/hanami.gemspec +9 -8
- data/lib/hanami/app.rb +50 -39
- data/lib/hanami/assets/app_config.rb +61 -0
- data/lib/hanami/assets/{configuration.rb → config.rb} +9 -10
- data/lib/hanami/{configuration → config}/actions/content_security_policy.rb +3 -3
- data/lib/hanami/config/actions/cookies.rb +57 -0
- data/lib/hanami/config/actions/sessions.rb +83 -0
- data/lib/hanami/config/actions.rb +164 -0
- data/lib/hanami/config/logger.rb +176 -0
- data/lib/hanami/config/null_config.rb +14 -0
- data/lib/hanami/{configuration → config}/router.rb +8 -9
- data/lib/hanami/{configuration → config}/views.rb +16 -20
- data/lib/hanami/config.rb +396 -0
- data/lib/hanami/constants.rb +4 -0
- data/lib/hanami/errors.rb +20 -0
- data/lib/hanami/extensions/action/slice_configured_action.rb +10 -6
- data/lib/hanami/extensions/action.rb +59 -7
- data/lib/hanami/extensions/view/context.rb +3 -4
- data/lib/hanami/extensions/view/slice_configured_view.rb +4 -4
- data/lib/hanami/extensions/view.rb +7 -5
- data/lib/hanami/providers/inflector.rb +6 -2
- data/lib/hanami/providers/logger.rb +9 -3
- data/lib/hanami/providers/rack.rb +12 -2
- data/lib/hanami/providers/routes.rb +14 -6
- data/lib/hanami/routes.rb +36 -1
- data/lib/hanami/settings/env_store.rb +4 -4
- data/lib/hanami/settings.rb +169 -21
- data/lib/hanami/slice/router.rb +38 -16
- data/lib/hanami/slice/routing/middleware/stack.rb +108 -40
- data/lib/hanami/slice/routing/resolver.rb +10 -17
- data/lib/hanami/slice/view_name_inferrer.rb +1 -1
- data/lib/hanami/slice.rb +605 -51
- data/lib/hanami/slice_configurable.rb +1 -1
- data/lib/hanami/slice_registrar.rb +25 -14
- data/lib/hanami/version.rb +2 -3
- data/lib/hanami/web/rack_logger.rb +14 -4
- data/lib/hanami.rb +122 -24
- data/spec/integration/action/csrf_protection_spec.rb +1 -1
- data/spec/integration/container/application_routes_helper_spec.rb +3 -1
- data/spec/integration/container/prepare_container_spec.rb +2 -0
- data/spec/integration/container/provider_lifecycle_spec.rb +61 -0
- data/spec/integration/container/standard_providers/rack_provider_spec.rb +44 -0
- data/spec/integration/container/{standard_bootable_components_spec.rb → standard_providers_spec.rb} +3 -3
- data/spec/integration/rack_app/body_parser_spec.rb +111 -0
- data/spec/integration/rack_app/middleware_spec.rb +455 -3
- data/spec/integration/rack_app/non_booted_rack_app_spec.rb +2 -1
- data/spec/integration/rack_app/rack_app_spec.rb +39 -11
- data/spec/integration/settings/access_in_slice_class_body_spec.rb +82 -0
- data/spec/integration/settings/access_to_constants_spec.rb +23 -146
- data/spec/integration/{slices/slice_settings_spec.rb → settings/slice_registration_spec.rb} +5 -1
- data/spec/integration/settings/using_types_spec.rb +4 -11
- data/spec/integration/setup_spec.rb +4 -4
- data/spec/integration/slices/external_slice_spec.rb +2 -1
- data/spec/integration/slices/slice_configuration_spec.rb +3 -1
- data/spec/integration/slices/slice_loading_spec.rb +4 -4
- data/spec/integration/slices/slice_routing_spec.rb +4 -3
- data/spec/integration/slices_spec.rb +100 -0
- data/spec/isolation/hanami/boot/success_spec.rb +1 -1
- data/spec/support/app_integration.rb +10 -15
- data/spec/unit/hanami/{configuration → config}/actions/content_security_policy_spec.rb +16 -16
- data/spec/unit/hanami/{configuration → config}/actions/cookies_spec.rb +6 -6
- data/spec/unit/hanami/{configuration → config}/actions/csrf_protection_spec.rb +12 -12
- data/spec/unit/hanami/config/actions/default_values_spec.rb +54 -0
- data/spec/unit/hanami/{configuration → config}/actions/sessions_spec.rb +6 -8
- data/spec/unit/hanami/{configuration → config}/actions_spec.rb +8 -20
- data/spec/unit/hanami/{configuration → config}/base_url_spec.rb +2 -2
- data/spec/unit/hanami/{configuration → config}/inflector_spec.rb +2 -2
- data/spec/unit/hanami/{configuration → config}/logger_spec.rb +42 -59
- data/spec/unit/hanami/{configuration → config}/router_spec.rb +7 -8
- data/spec/unit/hanami/{configuration → config}/slices_spec.rb +2 -2
- data/spec/unit/hanami/{configuration → config}/views_spec.rb +13 -24
- data/spec/unit/hanami/settings_spec.rb +65 -10
- data/spec/unit/hanami/slice_configurable_spec.rb +21 -2
- data/spec/unit/hanami/slice_spec.rb +32 -0
- data/spec/unit/hanami/version_spec.rb +1 -1
- data/spec/unit/hanami/web/rack_logger_spec.rb +13 -2
- metadata +100 -76
- data/lib/hanami/assets/app_configuration.rb +0 -69
- data/lib/hanami/configuration/actions/cookies.rb +0 -29
- data/lib/hanami/configuration/actions/sessions.rb +0 -46
- data/lib/hanami/configuration/actions.rb +0 -101
- data/lib/hanami/configuration/logger.rb +0 -87
- data/lib/hanami/configuration/null_configuration.rb +0 -14
- data/lib/hanami/configuration/sessions.rb +0 -50
- data/lib/hanami/configuration.rb +0 -234
- data/lib/hanami/providers/settings.rb +0 -98
- data/spec/unit/hanami/configuration/actions/default_values_spec.rb +0 -52
- data/spec/unit/hanami/configuration_spec.rb +0 -43
@@ -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
|
-
|
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
|
-
|
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
|
-
|
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 =
|
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
|
30
|
-
|
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 {
|
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::FrozenConfigError)
|
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
|
-
|
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 =
|
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
|
+
|
110
|
+
module Nested
|
111
|
+
class MySubclass < TestApp::BaseClass
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
subject(:subclass) { Main::Nested::MySubclass }
|
118
|
+
|
119
|
+
it "calls `configure_for_slice` with the nested slice" do
|
120
|
+
expect(subclass.traces).to eq [Main::Nested::Slice]
|
121
|
+
end
|
122
|
+
end
|
104
123
|
end
|
@@ -8,6 +8,38 @@ RSpec.describe Hanami::Slice, :app_integration do
|
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
+
describe ".environemnt" do
|
12
|
+
subject(:slice) { Hanami.app.register_slice(:main) }
|
13
|
+
|
14
|
+
before do
|
15
|
+
allow(slice.config).to receive(:env) { :development }
|
16
|
+
end
|
17
|
+
|
18
|
+
it "evaluates the block with the env matches the Hanami.env" do
|
19
|
+
expect {
|
20
|
+
slice.environment(:development) do
|
21
|
+
config.logger.level = :info
|
22
|
+
end
|
23
|
+
}
|
24
|
+
.to change { slice.config.logger.level }
|
25
|
+
.to :info
|
26
|
+
end
|
27
|
+
|
28
|
+
it "yields the slice to the block" do
|
29
|
+
captured_slice = nil
|
30
|
+
slice.environment(:development) { |slice| captured_slice = slice }
|
31
|
+
expect(captured_slice).to be slice
|
32
|
+
end
|
33
|
+
|
34
|
+
it "does not evaluate the block with the env does not match the Hanami.env" do
|
35
|
+
expect {
|
36
|
+
slice.environment(:test) do
|
37
|
+
config.logger.level = :info
|
38
|
+
end
|
39
|
+
}.not_to(change { slice.config.logger.level })
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
11
43
|
describe ".prepare" do
|
12
44
|
it "raises an error if the slice class is anonymous" do
|
13
45
|
expect { Class.new(described_class).prepare }
|
@@ -1,13 +1,24 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "hanami/web/rack_logger"
|
4
|
-
require "
|
4
|
+
require "dry/logger"
|
5
5
|
require "stringio"
|
6
6
|
require "rack/mock"
|
7
7
|
|
8
8
|
RSpec.describe Hanami::Web::RackLogger do
|
9
9
|
subject { described_class.new(logger) }
|
10
|
-
|
10
|
+
|
11
|
+
let(:logger) do
|
12
|
+
Dry.Logger(
|
13
|
+
app_name,
|
14
|
+
stream: stream,
|
15
|
+
level: :debug,
|
16
|
+
filters: filters,
|
17
|
+
formatter: :rack,
|
18
|
+
template: "[%<progname>s] [%<severity>s] [%<time>s] %<message>s"
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
11
22
|
let(:stream) { StringIO.new }
|
12
23
|
let(:filters) { ["user.password"] }
|
13
24
|
let(:app_name) { "my_app" }
|
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.
|
4
|
+
version: 2.0.0.rc1
|
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-
|
11
|
+
date: 2022-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -36,130 +36,150 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '0
|
39
|
+
version: '1.0'
|
40
|
+
- - "<"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '2'
|
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
|
49
|
+
version: '1.0'
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '2'
|
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
|
59
|
+
version: '1.0'
|
60
|
+
- - "<"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '2'
|
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
|
69
|
+
version: '1.0'
|
70
|
+
- - "<"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '2'
|
61
73
|
- !ruby/object:Gem::Dependency
|
62
74
|
name: dry-inflector
|
63
75
|
requirement: !ruby/object:Gem::Requirement
|
64
76
|
requirements:
|
65
77
|
- - "~>"
|
66
78
|
- !ruby/object:Gem::Version
|
67
|
-
version: '0
|
68
|
-
- - "
|
79
|
+
version: '1.0'
|
80
|
+
- - "<"
|
69
81
|
- !ruby/object:Gem::Version
|
70
|
-
version:
|
82
|
+
version: '2'
|
71
83
|
type: :runtime
|
72
84
|
prerelease: false
|
73
85
|
version_requirements: !ruby/object:Gem::Requirement
|
74
86
|
requirements:
|
75
87
|
- - "~>"
|
76
88
|
- !ruby/object:Gem::Version
|
77
|
-
version: '0
|
78
|
-
- - "
|
89
|
+
version: '1.0'
|
90
|
+
- - "<"
|
79
91
|
- !ruby/object:Gem::Version
|
80
|
-
version:
|
92
|
+
version: '2'
|
81
93
|
- !ruby/object:Gem::Dependency
|
82
|
-
name: dry-
|
94
|
+
name: dry-monitor
|
83
95
|
requirement: !ruby/object:Gem::Requirement
|
84
96
|
requirements:
|
85
97
|
- - "~>"
|
86
98
|
- !ruby/object:Gem::Version
|
87
|
-
version: '0
|
88
|
-
- - "
|
99
|
+
version: '1.0'
|
100
|
+
- - "<"
|
89
101
|
- !ruby/object:Gem::Version
|
90
|
-
version:
|
102
|
+
version: '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
|
98
|
-
- - "
|
109
|
+
version: '1.0'
|
110
|
+
- - "<"
|
99
111
|
- !ruby/object:Gem::Version
|
100
|
-
version:
|
112
|
+
version: '2'
|
101
113
|
- !ruby/object:Gem::Dependency
|
102
|
-
name: dry-
|
114
|
+
name: dry-system
|
103
115
|
requirement: !ruby/object:Gem::Requirement
|
104
116
|
requirements:
|
105
117
|
- - "~>"
|
106
118
|
- !ruby/object:Gem::Version
|
107
|
-
version:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: 0.6.3
|
119
|
+
version: 1.0.rc
|
111
120
|
type: :runtime
|
112
121
|
prerelease: false
|
113
122
|
version_requirements: !ruby/object:Gem::Requirement
|
114
123
|
requirements:
|
115
124
|
- - "~>"
|
116
125
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
118
|
-
|
126
|
+
version: 1.0.rc
|
127
|
+
- !ruby/object:Gem::Dependency
|
128
|
+
name: dry-logger
|
129
|
+
requirement: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - "~>"
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: 1.0.rc
|
134
|
+
type: :runtime
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - "~>"
|
119
139
|
- !ruby/object:Gem::Version
|
120
|
-
version: 0.
|
140
|
+
version: 1.0.rc
|
121
141
|
- !ruby/object:Gem::Dependency
|
122
142
|
name: hanami-cli
|
123
143
|
requirement: !ruby/object:Gem::Requirement
|
124
144
|
requirements:
|
125
145
|
- - "~>"
|
126
146
|
- !ruby/object:Gem::Version
|
127
|
-
version: 2.0.
|
147
|
+
version: 2.0.rc
|
128
148
|
type: :runtime
|
129
149
|
prerelease: false
|
130
150
|
version_requirements: !ruby/object:Gem::Requirement
|
131
151
|
requirements:
|
132
152
|
- - "~>"
|
133
153
|
- !ruby/object:Gem::Version
|
134
|
-
version: 2.0.
|
154
|
+
version: 2.0.rc
|
135
155
|
- !ruby/object:Gem::Dependency
|
136
156
|
name: hanami-utils
|
137
157
|
requirement: !ruby/object:Gem::Requirement
|
138
158
|
requirements:
|
139
159
|
- - "~>"
|
140
160
|
- !ruby/object:Gem::Version
|
141
|
-
version: 2.0.
|
161
|
+
version: 2.0.rc
|
142
162
|
type: :runtime
|
143
163
|
prerelease: false
|
144
164
|
version_requirements: !ruby/object:Gem::Requirement
|
145
165
|
requirements:
|
146
166
|
- - "~>"
|
147
167
|
- !ruby/object:Gem::Version
|
148
|
-
version: 2.0.
|
168
|
+
version: 2.0.rc
|
149
169
|
- !ruby/object:Gem::Dependency
|
150
170
|
name: zeitwerk
|
151
171
|
requirement: !ruby/object:Gem::Requirement
|
152
172
|
requirements:
|
153
173
|
- - "~>"
|
154
174
|
- !ruby/object:Gem::Version
|
155
|
-
version: '2.
|
175
|
+
version: '2.6'
|
156
176
|
type: :runtime
|
157
177
|
prerelease: false
|
158
178
|
version_requirements: !ruby/object:Gem::Requirement
|
159
179
|
requirements:
|
160
180
|
- - "~>"
|
161
181
|
- !ruby/object:Gem::Version
|
162
|
-
version: '2.
|
182
|
+
version: '2.6'
|
163
183
|
- !ruby/object:Gem::Dependency
|
164
184
|
name: rspec
|
165
185
|
requirement: !ruby/object:Gem::Requirement
|
@@ -217,19 +237,18 @@ files:
|
|
217
237
|
- hanami.gemspec
|
218
238
|
- lib/hanami.rb
|
219
239
|
- lib/hanami/app.rb
|
220
|
-
- lib/hanami/assets/
|
221
|
-
- lib/hanami/assets/
|
240
|
+
- lib/hanami/assets/app_config.rb
|
241
|
+
- lib/hanami/assets/config.rb
|
222
242
|
- lib/hanami/boot.rb
|
223
|
-
- lib/hanami/
|
224
|
-
- lib/hanami/
|
225
|
-
- lib/hanami/
|
226
|
-
- lib/hanami/
|
227
|
-
- lib/hanami/
|
228
|
-
- lib/hanami/
|
229
|
-
- lib/hanami/
|
230
|
-
- lib/hanami/
|
231
|
-
- lib/hanami/
|
232
|
-
- lib/hanami/configuration/views.rb
|
243
|
+
- lib/hanami/config.rb
|
244
|
+
- lib/hanami/config/actions.rb
|
245
|
+
- lib/hanami/config/actions/content_security_policy.rb
|
246
|
+
- lib/hanami/config/actions/cookies.rb
|
247
|
+
- lib/hanami/config/actions/sessions.rb
|
248
|
+
- lib/hanami/config/logger.rb
|
249
|
+
- lib/hanami/config/null_config.rb
|
250
|
+
- lib/hanami/config/router.rb
|
251
|
+
- lib/hanami/config/views.rb
|
233
252
|
- lib/hanami/constants.rb
|
234
253
|
- lib/hanami/errors.rb
|
235
254
|
- lib/hanami/extensions.rb
|
@@ -244,7 +263,6 @@ files:
|
|
244
263
|
- lib/hanami/providers/logger.rb
|
245
264
|
- lib/hanami/providers/rack.rb
|
246
265
|
- lib/hanami/providers/routes.rb
|
247
|
-
- lib/hanami/providers/settings.rb
|
248
266
|
- lib/hanami/rake_tasks.rb
|
249
267
|
- lib/hanami/routes.rb
|
250
268
|
- lib/hanami/settings.rb
|
@@ -279,22 +297,26 @@ files:
|
|
279
297
|
- spec/integration/container/autoloader_spec.rb
|
280
298
|
- spec/integration/container/imports_spec.rb
|
281
299
|
- spec/integration/container/prepare_container_spec.rb
|
300
|
+
- spec/integration/container/provider_lifecycle_spec.rb
|
282
301
|
- spec/integration/container/shutdown_spec.rb
|
283
|
-
- spec/integration/container/
|
302
|
+
- spec/integration/container/standard_providers/rack_provider_spec.rb
|
303
|
+
- spec/integration/container/standard_providers_spec.rb
|
284
304
|
- spec/integration/dotenv_loading_spec.rb
|
305
|
+
- spec/integration/rack_app/body_parser_spec.rb
|
285
306
|
- spec/integration/rack_app/middleware_spec.rb
|
286
307
|
- spec/integration/rack_app/non_booted_rack_app_spec.rb
|
287
308
|
- spec/integration/rack_app/rack_app_spec.rb
|
309
|
+
- spec/integration/settings/access_in_slice_class_body_spec.rb
|
288
310
|
- spec/integration/settings/access_to_constants_spec.rb
|
289
311
|
- spec/integration/settings/loading_from_env_spec.rb
|
290
312
|
- spec/integration/settings/settings_component_loading_spec.rb
|
313
|
+
- spec/integration/settings/slice_registration_spec.rb
|
291
314
|
- spec/integration/settings/using_types_spec.rb
|
292
315
|
- spec/integration/setup_spec.rb
|
293
316
|
- spec/integration/slices/external_slice_spec.rb
|
294
317
|
- spec/integration/slices/slice_configuration_spec.rb
|
295
318
|
- spec/integration/slices/slice_loading_spec.rb
|
296
319
|
- spec/integration/slices/slice_routing_spec.rb
|
297
|
-
- spec/integration/slices/slice_settings_spec.rb
|
298
320
|
- spec/integration/slices_spec.rb
|
299
321
|
- spec/integration/view/context/assets_spec.rb
|
300
322
|
- spec/integration/view/context/inflector_spec.rb
|
@@ -322,19 +344,18 @@ files:
|
|
322
344
|
- spec/support/shared_examples/cli/generate/migration.rb
|
323
345
|
- spec/support/shared_examples/cli/generate/model.rb
|
324
346
|
- spec/support/shared_examples/cli/new.rb
|
325
|
-
- spec/unit/hanami/
|
326
|
-
- spec/unit/hanami/
|
327
|
-
- spec/unit/hanami/
|
328
|
-
- spec/unit/hanami/
|
329
|
-
- spec/unit/hanami/
|
330
|
-
- spec/unit/hanami/
|
331
|
-
- spec/unit/hanami/
|
332
|
-
- spec/unit/hanami/
|
333
|
-
- spec/unit/hanami/
|
334
|
-
- spec/unit/hanami/
|
335
|
-
- spec/unit/hanami/
|
336
|
-
- spec/unit/hanami/
|
337
|
-
- spec/unit/hanami/configuration_spec.rb
|
347
|
+
- spec/unit/hanami/config/actions/content_security_policy_spec.rb
|
348
|
+
- spec/unit/hanami/config/actions/cookies_spec.rb
|
349
|
+
- spec/unit/hanami/config/actions/csrf_protection_spec.rb
|
350
|
+
- spec/unit/hanami/config/actions/default_values_spec.rb
|
351
|
+
- spec/unit/hanami/config/actions/sessions_spec.rb
|
352
|
+
- spec/unit/hanami/config/actions_spec.rb
|
353
|
+
- spec/unit/hanami/config/base_url_spec.rb
|
354
|
+
- spec/unit/hanami/config/inflector_spec.rb
|
355
|
+
- spec/unit/hanami/config/logger_spec.rb
|
356
|
+
- spec/unit/hanami/config/router_spec.rb
|
357
|
+
- spec/unit/hanami/config/slices_spec.rb
|
358
|
+
- spec/unit/hanami/config/views_spec.rb
|
338
359
|
- spec/unit/hanami/env_spec.rb
|
339
360
|
- spec/unit/hanami/settings/env_store_spec.rb
|
340
361
|
- spec/unit/hanami/settings_spec.rb
|
@@ -387,22 +408,26 @@ test_files:
|
|
387
408
|
- spec/integration/container/autoloader_spec.rb
|
388
409
|
- spec/integration/container/imports_spec.rb
|
389
410
|
- spec/integration/container/prepare_container_spec.rb
|
411
|
+
- spec/integration/container/provider_lifecycle_spec.rb
|
390
412
|
- spec/integration/container/shutdown_spec.rb
|
391
|
-
- spec/integration/container/
|
413
|
+
- spec/integration/container/standard_providers/rack_provider_spec.rb
|
414
|
+
- spec/integration/container/standard_providers_spec.rb
|
392
415
|
- spec/integration/dotenv_loading_spec.rb
|
416
|
+
- spec/integration/rack_app/body_parser_spec.rb
|
393
417
|
- spec/integration/rack_app/middleware_spec.rb
|
394
418
|
- spec/integration/rack_app/non_booted_rack_app_spec.rb
|
395
419
|
- spec/integration/rack_app/rack_app_spec.rb
|
420
|
+
- spec/integration/settings/access_in_slice_class_body_spec.rb
|
396
421
|
- spec/integration/settings/access_to_constants_spec.rb
|
397
422
|
- spec/integration/settings/loading_from_env_spec.rb
|
398
423
|
- spec/integration/settings/settings_component_loading_spec.rb
|
424
|
+
- spec/integration/settings/slice_registration_spec.rb
|
399
425
|
- spec/integration/settings/using_types_spec.rb
|
400
426
|
- spec/integration/setup_spec.rb
|
401
427
|
- spec/integration/slices/external_slice_spec.rb
|
402
428
|
- spec/integration/slices/slice_configuration_spec.rb
|
403
429
|
- spec/integration/slices/slice_loading_spec.rb
|
404
430
|
- spec/integration/slices/slice_routing_spec.rb
|
405
|
-
- spec/integration/slices/slice_settings_spec.rb
|
406
431
|
- spec/integration/slices_spec.rb
|
407
432
|
- spec/integration/view/context/assets_spec.rb
|
408
433
|
- spec/integration/view/context/inflector_spec.rb
|
@@ -430,19 +455,18 @@ test_files:
|
|
430
455
|
- spec/support/shared_examples/cli/generate/migration.rb
|
431
456
|
- spec/support/shared_examples/cli/generate/model.rb
|
432
457
|
- spec/support/shared_examples/cli/new.rb
|
433
|
-
- spec/unit/hanami/
|
434
|
-
- spec/unit/hanami/
|
435
|
-
- spec/unit/hanami/
|
436
|
-
- spec/unit/hanami/
|
437
|
-
- spec/unit/hanami/
|
438
|
-
- spec/unit/hanami/
|
439
|
-
- spec/unit/hanami/
|
440
|
-
- spec/unit/hanami/
|
441
|
-
- spec/unit/hanami/
|
442
|
-
- spec/unit/hanami/
|
443
|
-
- spec/unit/hanami/
|
444
|
-
- spec/unit/hanami/
|
445
|
-
- spec/unit/hanami/configuration_spec.rb
|
458
|
+
- spec/unit/hanami/config/actions/content_security_policy_spec.rb
|
459
|
+
- spec/unit/hanami/config/actions/cookies_spec.rb
|
460
|
+
- spec/unit/hanami/config/actions/csrf_protection_spec.rb
|
461
|
+
- spec/unit/hanami/config/actions/default_values_spec.rb
|
462
|
+
- spec/unit/hanami/config/actions/sessions_spec.rb
|
463
|
+
- spec/unit/hanami/config/actions_spec.rb
|
464
|
+
- spec/unit/hanami/config/base_url_spec.rb
|
465
|
+
- spec/unit/hanami/config/inflector_spec.rb
|
466
|
+
- spec/unit/hanami/config/logger_spec.rb
|
467
|
+
- spec/unit/hanami/config/router_spec.rb
|
468
|
+
- spec/unit/hanami/config/slices_spec.rb
|
469
|
+
- spec/unit/hanami/config/views_spec.rb
|
446
470
|
- spec/unit/hanami/env_spec.rb
|
447
471
|
- spec/unit/hanami/settings/env_store_spec.rb
|
448
472
|
- spec/unit/hanami/settings_spec.rb
|
@@ -1,69 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "hanami/assets/configuration"
|
4
|
-
require "dry/configurable"
|
5
|
-
|
6
|
-
module Hanami
|
7
|
-
module Assets
|
8
|
-
# @since 2.0.0
|
9
|
-
# @api public
|
10
|
-
class AppConfiguration
|
11
|
-
include Dry::Configurable
|
12
|
-
|
13
|
-
# @since 2.0.0
|
14
|
-
# @api private
|
15
|
-
attr_reader :base_configuration
|
16
|
-
protected :base_configuration
|
17
|
-
|
18
|
-
setting :server_url, default: "http://localhost:8080"
|
19
|
-
|
20
|
-
# @since 2.0.0
|
21
|
-
# @api private
|
22
|
-
def initialize(*)
|
23
|
-
super
|
24
|
-
|
25
|
-
@base_configuration = Assets::Configuration.new
|
26
|
-
end
|
27
|
-
|
28
|
-
def initialize_copy(source)
|
29
|
-
super
|
30
|
-
@base_configuration = source.base_configuration.dup
|
31
|
-
end
|
32
|
-
|
33
|
-
# @since 2.0.0
|
34
|
-
# @api private
|
35
|
-
def finalize!
|
36
|
-
end
|
37
|
-
|
38
|
-
# Returns the list of available settings
|
39
|
-
#
|
40
|
-
# @return [Set]
|
41
|
-
#
|
42
|
-
# @since 2.0.0
|
43
|
-
# @api private
|
44
|
-
def settings
|
45
|
-
base_configuration.settings + self.class.settings
|
46
|
-
end
|
47
|
-
|
48
|
-
private
|
49
|
-
|
50
|
-
# @since 2.0.0
|
51
|
-
# @api private
|
52
|
-
def method_missing(name, *args, &block)
|
53
|
-
if config.respond_to?(name)
|
54
|
-
config.public_send(name, *args, &block)
|
55
|
-
elsif base_configuration.respond_to?(name)
|
56
|
-
base_configuration.public_send(name, *args, &block)
|
57
|
-
else
|
58
|
-
super
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
# @since 2.0.0
|
63
|
-
# @api private
|
64
|
-
def respond_to_missing?(name, _incude_all = false)
|
65
|
-
config.respond_to?(name) || base_configuration.respond_to?(name) || super
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|