lib/ruby-app/environment.rb in ruby-app-0.1 vs lib/ruby-app/environment.rb in ruby-app-0.1.1
- old
+ new
@@ -26,10 +26,15 @@
# AS dependencies
require 'active_support/dependencies'
require 'active_support/core_ext/numeric/time'
require 'active_support/core_ext/object/blank'
+# load application app
+require File.join(App.root, %w{lib application})
+
+App.logger.info "Loading #{App.name}[#{App.env}] ..."
+
# default config from app
require File.join(App.root, %w{config config})
# configs from app for env
begin
@@ -39,33 +44,27 @@
end
# unshift lib app
$:.unshift(File.join(App.root, 'lib'))
+ActiveSupport::Dependencies::autoload_paths << File.join(App.root, 'lib')
+
# unshift dirs app
dirs = Dir[File.join(App.root, %w{app *})]
-dirs.each{|a| $:.unshift(a) }
+dirs.each do |a|
+ $:.unshift(a)
+ ActiveSupport::Dependencies::autoload_paths << a
+end
- #[:controllers, :models, :commands].each do |a|
- # ActiveSupport::Dependencies::autoload_paths << "#{App.root}/app/#{a}"
- #end
-
-ActiveSupport::Dependencies::autoload_paths << File.join(App.root, 'lib')
-
-#App.logger.info "started #{App.name} with env #{App.env}"
-
-# load application app
-require File.join(App.root, %w{lib application})
-
# load initializers app
Dir["#{App.root}/config/initializers/*.rb"].each{ |x| load(x) }
# first load models app
Dir["#{App.root}/app/models/*.rb"].each{ |x| require x }
# later controllers app
Dir["#{App.root}/app/controllers/*.rb"].each{ |x| require x }
-# later all app
+# later all app from app
dirs.each do |dir|
Dir["#{dir}/*.rb"].each{ |x| require x }
end