hanami 2.0.0.beta3 → 2.0.0.beta4
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 +20 -0
- data/hanami.gemspec +5 -5
- data/lib/hanami/app.rb +4 -4
- data/lib/hanami/assets/{app_configuration.rb → app_config.rb} +10 -10
- data/lib/hanami/assets/{configuration.rb → config.rb} +4 -4
- data/lib/hanami/{configuration → config}/actions/content_security_policy.rb +2 -2
- data/lib/hanami/{configuration → config}/actions/cookies.rb +6 -5
- data/lib/hanami/{configuration → config}/actions/sessions.rb +2 -2
- data/lib/hanami/{configuration → config}/actions.rb +11 -12
- data/lib/hanami/{configuration → config}/logger.rb +2 -2
- data/lib/hanami/config/null_config.rb +14 -0
- data/lib/hanami/{configuration → config}/router.rb +8 -8
- data/lib/hanami/{configuration → config}/sessions.rb +2 -2
- data/lib/hanami/{configuration → config}/views.rb +10 -10
- data/lib/hanami/{configuration.rb → config.rb} +19 -19
- data/lib/hanami/errors.rb +3 -0
- data/lib/hanami/extensions/action/slice_configured_action.rb +1 -1
- data/lib/hanami/providers/inflector.rb +0 -2
- data/lib/hanami/providers/logger.rb +1 -3
- data/lib/hanami/providers/rack.rb +0 -2
- data/lib/hanami/providers/routes.rb +0 -2
- data/lib/hanami/settings/env_store.rb +3 -3
- data/lib/hanami/settings.rb +87 -5
- data/lib/hanami/slice/routing/middleware/stack.rb +45 -1
- data/lib/hanami/slice.rb +52 -37
- data/lib/hanami/slice_configurable.rb +1 -1
- data/lib/hanami/slice_registrar.rb +6 -0
- data/lib/hanami/version.rb +1 -1
- data/lib/hanami.rb +0 -1
- data/spec/integration/container/prepare_container_spec.rb +2 -0
- data/spec/integration/rack_app/body_parser_spec.rb +108 -0
- data/spec/integration/rack_app/middleware_spec.rb +28 -0
- 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/support/app_integration.rb +18 -15
- data/spec/unit/hanami/{configuration → config}/actions/content_security_policy_spec.rb +10 -10
- 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 +5 -5
- data/spec/unit/hanami/{configuration → config}/actions_spec.rb +9 -10
- 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 +4 -4
- 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 +11 -12
- data/spec/unit/hanami/{configuration_spec.rb → config_spec.rb} +3 -3
- data/spec/unit/hanami/settings_spec.rb +65 -10
- data/spec/unit/hanami/slice_configurable_spec.rb +21 -2
- data/spec/unit/hanami/version_spec.rb +1 -1
- metadata +73 -58
- data/lib/hanami/configuration/null_configuration.rb +0 -14
- data/lib/hanami/providers/settings.rb +0 -98
- data/spec/unit/hanami/configuration/actions/default_values_spec.rb +0 -52
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: afcc32f5e8f7ba0a0acb001c4c36ea5a654f73e705b22e73cfc2a2835858af3e
|
4
|
+
data.tar.gz: d183f4cdec177426f339eeae371320880927d15463982d82daeffacd632fe09f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1cca2e0e675ba87e678c14d4733bc172af135ea8fbf751fb1d1749faef2cf9a96629eae77fac339c5d435f6d3744dc6da1f1c32bf63881563ceb435337725bb
|
7
|
+
data.tar.gz: 5a466e081c89ded4a30f4ba8655c2981ba26f9cbb16a5f5e8deb6034f806f4ec203a62556c4ad372b8fd4619e959eb8beb3781a6e8e0451e04aaa0dc2099129f
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,26 @@
|
|
2
2
|
|
3
3
|
The web, with simplicity.
|
4
4
|
|
5
|
+
## v2.0.0.beta4 - 2022-10-24
|
6
|
+
|
7
|
+
### Added
|
8
|
+
|
9
|
+
- [Peter Solnica] Improve middleware config by avoiding class names and requires: symbols instead of classes can be passed as middleware identifiers (`config.middleware.use(:body_parser, :json)`); constant namespaces can be configured for resolving symbols into class names (`config.middleware.namespaces = [Hanami::Middleware, MyStuff::Middlewares]`), with the first match winning; first-party middleware classes are required automatically. (#1215)
|
10
|
+
|
11
|
+
### Fixed
|
12
|
+
|
13
|
+
- [Luca Guidi] Do not attempt to load routes if hanami-router is not bundled (#1214)
|
14
|
+
- [Marc Busqué] Ensure nested slices are considered when auto-configuring application components using `Hanami::SliceConfigurable` (#1212)
|
15
|
+
- [Tim Riley] Ensure errors are raised during settings loading for any settings that are missing entirely from ENV (#1222)
|
16
|
+
|
17
|
+
### Changed
|
18
|
+
|
19
|
+
- [Tim Riley] Rename `Hanami::App.configuration` to `Hanami::App.config` and `Hanami::Configuration` to `Hanami::Config` (#1218)
|
20
|
+
- [Tim Riley] Make `Hanami::App.settings` available as a class method again (#1213)
|
21
|
+
- [Tim Riley] `config/settings.rb` in apps no longer has access to autoloaded constants (changed back to behavior pre-beta3) (#1213)
|
22
|
+
- [Tim Riley] Auto-generate a nested `Types` module in `Hanami::Settings` subclasses if dry-types is available, for added convenience in type checking settings (#1213)
|
23
|
+
- [Marc Busqué] Hide values from `Hanami::Settings#inspect` (values may contain sensitive data). Values can be inspected via `#inspect_values` (#1217)
|
24
|
+
|
5
25
|
## v2.0.0.beta3 - 2022-09-21
|
6
26
|
|
7
27
|
### Changed
|
data/hanami.gemspec
CHANGED
@@ -32,14 +32,14 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
33
33
|
|
34
34
|
spec.add_dependency "bundler", ">= 1.16", "< 3"
|
35
|
-
spec.add_dependency "dry-configurable", "~> 0.
|
36
|
-
spec.add_dependency "dry-core", "~> 0.
|
35
|
+
spec.add_dependency "dry-configurable", "~> 0.16", ">= 0.16.1"
|
36
|
+
spec.add_dependency "dry-core", "~> 0.9", ">= 0.9.1"
|
37
37
|
spec.add_dependency "dry-inflector", "~> 0.2", ">= 0.2.1"
|
38
|
-
spec.add_dependency "dry-system", "~> 0.
|
39
|
-
spec.add_dependency "dry-monitor", "~> 0.
|
38
|
+
spec.add_dependency "dry-system", "~> 0.27", ">= 0.27.2"
|
39
|
+
spec.add_dependency "dry-monitor", "~> 0.7", ">= 0.7"
|
40
40
|
spec.add_dependency "hanami-cli", "~> 2.0.beta"
|
41
41
|
spec.add_dependency "hanami-utils", "~> 2.0.beta"
|
42
|
-
spec.add_dependency "zeitwerk", "~> 2.
|
42
|
+
spec.add_dependency "zeitwerk", "~> 2.6"
|
43
43
|
|
44
44
|
spec.add_development_dependency "rspec", "~> 3.8"
|
45
45
|
spec.add_development_dependency "rack-test", "~> 1.1"
|
data/lib/hanami/app.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative "
|
3
|
+
require_relative "config"
|
4
4
|
require_relative "constants"
|
5
5
|
require_relative "slice"
|
6
6
|
require_relative "slice_name"
|
@@ -29,7 +29,7 @@ module Hanami
|
|
29
29
|
|
30
30
|
@_mutex.synchronize do
|
31
31
|
subclass.class_eval do
|
32
|
-
@
|
32
|
+
@config = Hanami::Config.new(app_name: slice_name, env: Hanami.env)
|
33
33
|
|
34
34
|
# Prepare the load path (based on the default root of `Dir.pwd`) as early as
|
35
35
|
# possible, so you can make a `require` inside the body of an `App` subclass,
|
@@ -43,7 +43,7 @@ module Hanami
|
|
43
43
|
|
44
44
|
# App class interface
|
45
45
|
module ClassMethods
|
46
|
-
attr_reader :
|
46
|
+
attr_reader :config
|
47
47
|
|
48
48
|
def app_name
|
49
49
|
slice_name
|
@@ -152,7 +152,7 @@ module Hanami
|
|
152
152
|
|
153
153
|
# When auto-registering components in app/, ignore files in `app/lib/` (these will
|
154
154
|
# be auto-registered as above), as well as the configured no_auto_register_paths
|
155
|
-
no_auto_register_paths = ([LIB_DIR] +
|
155
|
+
no_auto_register_paths = ([LIB_DIR] + config.no_auto_register_paths)
|
156
156
|
.map { |path|
|
157
157
|
path.end_with?(File::SEPARATOR) ? path : "#{path}#{File::SEPARATOR}"
|
158
158
|
}
|
@@ -1,19 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "hanami/assets/configuration"
|
4
3
|
require "dry/configurable"
|
4
|
+
require_relative "config"
|
5
5
|
|
6
6
|
module Hanami
|
7
7
|
module Assets
|
8
8
|
# @since 2.0.0
|
9
9
|
# @api public
|
10
|
-
class
|
10
|
+
class AppConfig
|
11
11
|
include Dry::Configurable
|
12
12
|
|
13
13
|
# @since 2.0.0
|
14
14
|
# @api private
|
15
|
-
attr_reader :
|
16
|
-
protected :
|
15
|
+
attr_reader :base_config
|
16
|
+
protected :base_config
|
17
17
|
|
18
18
|
setting :server_url, default: "http://localhost:8080"
|
19
19
|
|
@@ -22,12 +22,12 @@ module Hanami
|
|
22
22
|
def initialize(*)
|
23
23
|
super
|
24
24
|
|
25
|
-
@
|
25
|
+
@base_config = Config.new
|
26
26
|
end
|
27
27
|
|
28
28
|
def initialize_copy(source)
|
29
29
|
super
|
30
|
-
@
|
30
|
+
@base_config = source.base_config.dup
|
31
31
|
end
|
32
32
|
|
33
33
|
# @since 2.0.0
|
@@ -42,7 +42,7 @@ module Hanami
|
|
42
42
|
# @since 2.0.0
|
43
43
|
# @api private
|
44
44
|
def settings
|
45
|
-
|
45
|
+
base_config.settings + self.class.settings
|
46
46
|
end
|
47
47
|
|
48
48
|
private
|
@@ -52,8 +52,8 @@ module Hanami
|
|
52
52
|
def method_missing(name, *args, &block)
|
53
53
|
if config.respond_to?(name)
|
54
54
|
config.public_send(name, *args, &block)
|
55
|
-
elsif
|
56
|
-
|
55
|
+
elsif base_config.respond_to?(name)
|
56
|
+
base_config.public_send(name, *args, &block)
|
57
57
|
else
|
58
58
|
super
|
59
59
|
end
|
@@ -62,7 +62,7 @@ module Hanami
|
|
62
62
|
# @since 2.0.0
|
63
63
|
# @api private
|
64
64
|
def respond_to_missing?(name, _incude_all = false)
|
65
|
-
config.respond_to?(name) ||
|
65
|
+
config.respond_to?(name) || base_config.respond_to?(name) || super
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
@@ -6,14 +6,14 @@ module Hanami
|
|
6
6
|
module Assets
|
7
7
|
# @since 2.0.0
|
8
8
|
# @api public
|
9
|
-
class
|
9
|
+
class Config
|
10
10
|
include Dry::Configurable
|
11
11
|
|
12
|
-
# Initialize the
|
12
|
+
# Initialize the Config
|
13
13
|
#
|
14
|
-
# @yield [config] the
|
14
|
+
# @yield [config] the config object
|
15
15
|
#
|
16
|
-
# @return [
|
16
|
+
# @return [Config]
|
17
17
|
#
|
18
18
|
# @since 2.0.0
|
19
19
|
# @api private
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Hanami
|
4
|
-
class
|
4
|
+
class Config
|
5
5
|
class Actions
|
6
|
-
#
|
6
|
+
# Config for Content Security Policy in Hanami apps
|
7
7
|
#
|
8
8
|
# @since 2.0.0
|
9
9
|
class ContentSecurityPolicy
|
@@ -1,12 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Hanami
|
4
|
-
class
|
4
|
+
class Config
|
5
5
|
class Actions
|
6
|
-
# Wrapper for app-level
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
6
|
+
# Wrapper for app-level config of HTTP cookies for Hanami actions.
|
7
|
+
#
|
8
|
+
# This decorates the hash of cookie options that is otherwise directly configurable on
|
9
|
+
# actions, and adds the `enabled?` method to allow app base action to determine whether to
|
10
|
+
# include the `Action::Cookies` module.
|
10
11
|
#
|
11
12
|
# @since 2.0.0
|
12
13
|
class Cookies
|
@@ -5,9 +5,9 @@ require "hanami/utils/string"
|
|
5
5
|
require "hanami/utils/class"
|
6
6
|
|
7
7
|
module Hanami
|
8
|
-
class
|
8
|
+
class Config
|
9
9
|
class Actions
|
10
|
-
#
|
10
|
+
# Config for HTTP sessions in Hanami actions
|
11
11
|
#
|
12
12
|
# @since 2.0.0
|
13
13
|
class Sessions
|
@@ -1,15 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "dry/configurable"
|
4
|
-
require "hanami/action/configuration"
|
5
4
|
require_relative "actions/cookies"
|
6
5
|
require_relative "actions/sessions"
|
7
6
|
require_relative "actions/content_security_policy"
|
8
7
|
require_relative "../slice/view_name_inferrer"
|
9
8
|
|
10
9
|
module Hanami
|
11
|
-
class
|
12
|
-
# Hanami actions
|
10
|
+
class Config
|
11
|
+
# Hanami actions config
|
13
12
|
#
|
14
13
|
# @since 2.0.0
|
15
14
|
class Actions
|
@@ -26,13 +25,13 @@ module Hanami
|
|
26
25
|
|
27
26
|
attr_accessor :content_security_policy
|
28
27
|
|
29
|
-
attr_reader :
|
30
|
-
protected :
|
28
|
+
attr_reader :base_config
|
29
|
+
protected :base_config
|
31
30
|
|
32
31
|
def initialize(*, **options)
|
33
32
|
super()
|
34
33
|
|
35
|
-
@
|
34
|
+
@base_config = Hanami::Action.config.dup
|
36
35
|
@content_security_policy = ContentSecurityPolicy.new do |csp|
|
37
36
|
if assets_server_url = options[:assets_server_url]
|
38
37
|
csp[:script_src] += " #{assets_server_url}"
|
@@ -45,7 +44,7 @@ module Hanami
|
|
45
44
|
|
46
45
|
def initialize_copy(source)
|
47
46
|
super
|
48
|
-
@
|
47
|
+
@base_config = source.base_config.dup
|
49
48
|
@content_security_policy = source.content_security_policy.dup
|
50
49
|
end
|
51
50
|
|
@@ -66,12 +65,12 @@ module Hanami
|
|
66
65
|
# @since 2.0.0
|
67
66
|
# @api private
|
68
67
|
def settings
|
69
|
-
|
68
|
+
Hanami::Action.settings + self.class.settings
|
70
69
|
end
|
71
70
|
|
72
71
|
private
|
73
72
|
|
74
|
-
# Apply defaults for base
|
73
|
+
# Apply defaults for base config
|
75
74
|
def configure_defaults
|
76
75
|
self.default_request_format = :html
|
77
76
|
self.default_response_format = :html
|
@@ -86,15 +85,15 @@ module Hanami
|
|
86
85
|
def method_missing(name, *args, &block)
|
87
86
|
if config.respond_to?(name)
|
88
87
|
config.public_send(name, *args, &block)
|
89
|
-
elsif
|
90
|
-
|
88
|
+
elsif base_config.respond_to?(name)
|
89
|
+
base_config.public_send(name, *args, &block)
|
91
90
|
else
|
92
91
|
super
|
93
92
|
end
|
94
93
|
end
|
95
94
|
|
96
95
|
def respond_to_missing?(name, _incude_all = false)
|
97
|
-
config.respond_to?(name) ||
|
96
|
+
config.respond_to?(name) || base_config.respond_to?(name) || super
|
98
97
|
end
|
99
98
|
end
|
100
99
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "dry/configurable"
|
4
|
+
|
5
|
+
module Hanami
|
6
|
+
class Config
|
7
|
+
# NullConfig can serve as a fallback config object when out-of-gem config objects are not
|
8
|
+
# available (specifically, when the hanami-controller, hanami-router or hanami-view gems are not
|
9
|
+
# loaded)
|
10
|
+
class NullConfig
|
11
|
+
include Dry::Configurable
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -4,22 +4,22 @@ require "dry/configurable"
|
|
4
4
|
require_relative "../slice/routing/resolver"
|
5
5
|
|
6
6
|
module Hanami
|
7
|
-
class
|
8
|
-
# Hanami router
|
7
|
+
class Config
|
8
|
+
# Hanami router config
|
9
9
|
#
|
10
10
|
# @since 2.0.0
|
11
11
|
# @api private
|
12
12
|
class Router
|
13
13
|
include Dry::Configurable
|
14
14
|
|
15
|
-
# Base
|
16
|
-
attr_reader :
|
17
|
-
private :
|
15
|
+
# Base config is provided so router config can include the `base_url`
|
16
|
+
attr_reader :base_config
|
17
|
+
private :base_config
|
18
18
|
|
19
19
|
# @api private
|
20
20
|
# @since 2.0.0
|
21
|
-
def initialize(
|
22
|
-
@
|
21
|
+
def initialize(base_config)
|
22
|
+
@base_config = base_config
|
23
23
|
end
|
24
24
|
|
25
25
|
setting :resolver, default: Slice::Routing::Resolver
|
@@ -27,7 +27,7 @@ module Hanami
|
|
27
27
|
# @api private
|
28
28
|
# @since 2.0.0
|
29
29
|
def options
|
30
|
-
{base_url:
|
30
|
+
{base_url: base_config.base_url}
|
31
31
|
end
|
32
32
|
|
33
33
|
private
|
@@ -4,8 +4,8 @@ require "dry/configurable"
|
|
4
4
|
require "hanami/view"
|
5
5
|
|
6
6
|
module Hanami
|
7
|
-
class
|
8
|
-
# Hanami
|
7
|
+
class Config
|
8
|
+
# Hanami views config
|
9
9
|
#
|
10
10
|
# @since 2.0.0
|
11
11
|
class Views
|
@@ -13,20 +13,20 @@ module Hanami
|
|
13
13
|
|
14
14
|
setting :parts_path, default: "views/parts"
|
15
15
|
|
16
|
-
attr_reader :
|
17
|
-
protected :
|
16
|
+
attr_reader :base_config
|
17
|
+
protected :base_config
|
18
18
|
|
19
19
|
def initialize(*)
|
20
20
|
super
|
21
21
|
|
22
|
-
@
|
22
|
+
@base_config = Hanami::View.config.dup
|
23
23
|
|
24
24
|
configure_defaults
|
25
25
|
end
|
26
26
|
|
27
27
|
def initialize_copy(source)
|
28
28
|
super
|
29
|
-
@
|
29
|
+
@base_config = source.base_config.dup
|
30
30
|
end
|
31
31
|
|
32
32
|
# Returns the list of available settings
|
@@ -42,7 +42,7 @@ module Hanami
|
|
42
42
|
def finalize!
|
43
43
|
return self if frozen?
|
44
44
|
|
45
|
-
|
45
|
+
base_config.finalize!
|
46
46
|
|
47
47
|
super
|
48
48
|
end
|
@@ -69,8 +69,8 @@ module Hanami
|
|
69
69
|
|
70
70
|
if config.respond_to?(name)
|
71
71
|
config.public_send(name, *args, &block)
|
72
|
-
elsif
|
73
|
-
|
72
|
+
elsif base_config.respond_to?(name)
|
73
|
+
base_config.public_send(name, *args, &block)
|
74
74
|
else
|
75
75
|
super
|
76
76
|
end
|
@@ -79,7 +79,7 @@ module Hanami
|
|
79
79
|
def respond_to_missing?(name, _include_all = false)
|
80
80
|
return false if NON_FORWARDABLE_METHODS.include?(name)
|
81
81
|
|
82
|
-
config.respond_to?(name) ||
|
82
|
+
config.respond_to?(name) || base_config.respond_to?(name) || super
|
83
83
|
end
|
84
84
|
end
|
85
85
|
end
|
@@ -8,8 +8,8 @@ require "dry/inflector"
|
|
8
8
|
require "pathname"
|
9
9
|
|
10
10
|
require_relative "constants"
|
11
|
-
require_relative "
|
12
|
-
require_relative "
|
11
|
+
require_relative "config/logger"
|
12
|
+
require_relative "config/sessions"
|
13
13
|
require_relative "settings/env_store"
|
14
14
|
require_relative "slice/routing/middleware/stack"
|
15
15
|
|
@@ -17,7 +17,7 @@ module Hanami
|
|
17
17
|
# Hanami app configuration
|
18
18
|
#
|
19
19
|
# @since 2.0.0
|
20
|
-
class
|
20
|
+
class Config
|
21
21
|
include Dry::Configurable
|
22
22
|
|
23
23
|
setting :root, constructor: ->(path) { Pathname(path) if path }
|
@@ -58,7 +58,7 @@ module Hanami
|
|
58
58
|
# @api public
|
59
59
|
attr_reader :env
|
60
60
|
|
61
|
-
# @return [Hanami::
|
61
|
+
# @return [Hanami::Config::Actions]
|
62
62
|
#
|
63
63
|
# @api public
|
64
64
|
attr_reader :actions
|
@@ -71,12 +71,12 @@ module Hanami
|
|
71
71
|
# @api private
|
72
72
|
alias_method :middleware_stack, :middleware
|
73
73
|
|
74
|
-
# @return [Hanami::
|
74
|
+
# @return [Hanami::Config::Router]
|
75
75
|
#
|
76
76
|
# @api public
|
77
77
|
attr_reader :router
|
78
78
|
|
79
|
-
# @return [Hanami::
|
79
|
+
# @return [Hanami::Config::Views]
|
80
80
|
#
|
81
81
|
# @api public
|
82
82
|
attr_reader :views
|
@@ -103,36 +103,36 @@ module Hanami
|
|
103
103
|
self.root = Dir.pwd
|
104
104
|
load_from_env
|
105
105
|
|
106
|
-
config.logger =
|
106
|
+
config.logger = Config::Logger.new(env: env, app_name: app_name)
|
107
107
|
|
108
|
-
# TODO: Make assets
|
109
|
-
require "hanami/assets/
|
110
|
-
@assets = Hanami::Assets::
|
108
|
+
# TODO: Make assets config dependent
|
109
|
+
require "hanami/assets/app_config"
|
110
|
+
@assets = Hanami::Assets::AppConfig.new
|
111
111
|
|
112
112
|
@actions = load_dependent_config("hanami-controller") {
|
113
|
-
require_relative "
|
113
|
+
require_relative "config/actions"
|
114
114
|
Actions.new
|
115
115
|
}
|
116
116
|
|
117
117
|
@router = load_dependent_config("hanami-router") {
|
118
|
-
require_relative "
|
118
|
+
require_relative "config/router"
|
119
119
|
@middleware = Slice::Routing::Middleware::Stack.new
|
120
120
|
Router.new(self)
|
121
121
|
}
|
122
122
|
|
123
123
|
@views = load_dependent_config("hanami-view") {
|
124
|
-
require_relative "
|
124
|
+
require_relative "config/views"
|
125
125
|
Views.new
|
126
126
|
}
|
127
127
|
|
128
128
|
yield self if block_given?
|
129
129
|
end
|
130
130
|
|
131
|
-
# Apply
|
131
|
+
# Apply config for the given environment
|
132
132
|
#
|
133
133
|
# @param env [String] the environment name
|
134
134
|
#
|
135
|
-
# @return [Hanami::
|
135
|
+
# @return [Hanami::Config]
|
136
136
|
#
|
137
137
|
# @api public
|
138
138
|
def environment(env_name, &block)
|
@@ -164,7 +164,7 @@ module Hanami
|
|
164
164
|
@actions = source.actions.dup
|
165
165
|
@middleware = source.middleware.dup
|
166
166
|
@router = source.router.dup.tap do |router|
|
167
|
-
router.instance_variable_set(:@
|
167
|
+
router.instance_variable_set(:@base_config, self)
|
168
168
|
end
|
169
169
|
@views = source.views.dup
|
170
170
|
end
|
@@ -173,7 +173,7 @@ module Hanami
|
|
173
173
|
def finalize!
|
174
174
|
apply_env_config
|
175
175
|
|
176
|
-
# Finalize nested
|
176
|
+
# Finalize nested configs
|
177
177
|
assets.finalize!
|
178
178
|
actions.finalize!
|
179
179
|
views.finalize!
|
@@ -214,8 +214,8 @@ module Hanami
|
|
214
214
|
if Hanami.bundled?(gem_name)
|
215
215
|
yield
|
216
216
|
else
|
217
|
-
require_relative "
|
218
|
-
|
217
|
+
require_relative "config/null_config"
|
218
|
+
NullConfig.new
|
219
219
|
end
|
220
220
|
end
|
221
221
|
|
data/lib/hanami/errors.rb
CHANGED
@@ -47,7 +47,7 @@ module Hanami
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def configure_action(action_class)
|
50
|
-
action_class.
|
50
|
+
action_class.settings.each do |setting|
|
51
51
|
# Configure the action from config on the slice, _unless it has already been configured
|
52
52
|
# by a parent slice_, and re-configuring it for this slice would make no change.
|
53
53
|
#
|
@@ -1,12 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "dry/system/provider/source"
|
4
|
-
|
5
3
|
module Hanami
|
6
4
|
module Providers
|
7
5
|
class Logger < Dry::System::Provider::Source
|
8
6
|
def start
|
9
|
-
register :logger, Hanami.app.
|
7
|
+
register :logger, Hanami.app.config.logger_instance
|
10
8
|
end
|
11
9
|
end
|
12
10
|
end
|
@@ -12,7 +12,7 @@ module Hanami
|
|
12
12
|
# @since 2.0.0
|
13
13
|
# @api private
|
14
14
|
class EnvStore
|
15
|
-
|
15
|
+
NO_ARG = Object.new.freeze
|
16
16
|
|
17
17
|
attr_reader :store, :hanami_env
|
18
18
|
|
@@ -21,9 +21,9 @@ module Hanami
|
|
21
21
|
@hanami_env = hanami_env
|
22
22
|
end
|
23
23
|
|
24
|
-
def fetch(name, default_value =
|
24
|
+
def fetch(name, default_value = NO_ARG, &block)
|
25
25
|
name = name.to_s.upcase
|
26
|
-
args = default_value
|
26
|
+
args = default_value.eql?(NO_ARG) ? [name] : [name, default_value]
|
27
27
|
|
28
28
|
store.fetch(*args, &block)
|
29
29
|
end
|