lib/hanami/config.rb in hanami-2.1.0.beta1 vs lib/hanami/config.rb in hanami-2.1.0.beta2
- old
+ new
@@ -97,10 +97,11 @@
logger
notifications
rack.monitor
routes
settings
+ assets
]
# @!attribute [rw] no_auto_register_paths
# Sets the paths to skip from container auto-registration.
#
@@ -261,10 +262,11 @@
#
# @api private
attr_reader :assets
# @api private
+ # rubocop:disable Metrics/AbcSize
def initialize(app_name:, env:)
@app_name = app_name
@env = env
# Apply default values that are only knowable at initialize-time (vs require-time)
@@ -273,14 +275,10 @@
self.render_detailed_errors = (env != :production)
load_from_env
@logger = Config::Logger.new(env: env, app_name: app_name)
- # TODO: Make assets config dependent
- require "hanami/assets/app_config"
- @assets = Hanami::Assets::AppConfig.new
-
@actions = load_dependent_config("hanami-controller") {
require_relative "config/actions"
Actions.new
}
@@ -293,12 +291,26 @@
@views = load_dependent_config("hanami-view") {
require_relative "config/views"
Views.new
}
+ @assets = load_dependent_config("hanami-assets") {
+ require_relative "config/assets"
+
+ public_dir = root.join("public")
+
+ Hanami::Config::Assets.new(
+ # TODO: check if `sources` are still needed
+ sources: root.join("app", "assets"),
+ destination: public_dir.join("assets"),
+ manifest_path: public_dir.join("assets.json")
+ )
+ }
+
yield self if block_given?
end
+ # rubocop:enable Metrics/AbcSize
# @api private
def initialize_copy(source)
super
@@ -321,10 +333,10 @@
#
# @api private
def finalize!
# Finalize nested configs
assets.finalize!
- actions.finalize!
+ actions.finalize!(self)
views.finalize!
logger.finalize!
router.finalize!
use_body_parser_middleware