lib/lotus/loader.rb in lotusrb-0.5.0 vs lib/lotus/loader.rb in lotusrb-0.6.0
- old
+ new
@@ -29,10 +29,11 @@
load_configuration!
configure_frameworks!
load_configuration_load_paths!
load_rack!
load_frameworks!
+ load_initializers!
end
end
private
attr_reader :application, :configuration
@@ -43,10 +44,11 @@
def configure_frameworks!
_configure_model_framework! if defined?(Lotus::Model)
_configure_controller_framework!
_configure_view_framework!
+ _configure_assets_framework!
_configure_logger!
end
def _configure_controller_framework!
config = configuration
@@ -95,10 +97,38 @@
namespace.const_set('View', view)
end
end
+ def _configure_assets_framework!
+ config = configuration
+
+ unless application_module.const_defined?('Assets')
+ assets = Lotus::Assets.duplicate(namespace) do
+ root config.root
+
+ scheme config.scheme
+ host config.host
+ port config.port
+
+ public_directory Lotus.public_directory
+ prefix Utils::PathPrefix.new('/assets').join(config.path_prefix)
+
+ manifest Lotus.public_directory.join('assets.json')
+ compile true
+
+ config.assets.__apply(self)
+ end
+
+ assets.configure do
+ cdn host != config.host
+ end
+
+ application_module.const_set('Assets', assets)
+ end
+ end
+
def _configure_model_framework!
config = configuration
if _lotus_model_loaded? && !application_module.const_defined?('Model')
model = Lotus::Model.duplicate(application_module) do
adapter(config.adapter) if config.adapter
@@ -120,19 +150,26 @@
end
end
def load_frameworks!
_load_view_framework!
+ _load_assets_framework!
_load_model_framework!
end
def _load_view_framework!
namespace.module_eval %{
#{ namespace }::View.load!
}
end
+ def _load_assets_framework!
+ application_module.module_eval %{
+ #{ application_module }::Assets.load!
+ }
+ end
+
def _load_model_framework!
return unless _load_model_framework?
application_module.module_eval %{
#{ application_module }::Model.load!
@@ -208,8 +245,14 @@
)
end
def namespace
configuration.namespace || application_module
+ end
+
+ def load_initializers!
+ Dir["#{configuration.root}/config/initializers/**/*.rb"].each do |file|
+ require file
+ end
end
end
end