cap tasks to deal with websocket
[shapado:shapado.git] / lib / shapado / scripting / easy_loader.rb
1 ENV["SHAPADO_NO_CHECK_CONFIG"] = "1"
2
3 Dir.chdir(File.dirname(__FILE__)) do
4   require 'bundler/setup'
5   Bundler.setup
6 end
7
8 Dir.chdir(Bundler.root.to_s)
9
10 require 'rails'
11 require 'action_mailer/railtie'
12 require 'action_controller'
13 require 'action_view'
14 require "#{Bundler.root}/lib/shapado/scripting/application"
15
16 require 'mongoid'
17 require 'mongoid_ext'
18 require 'devise'
19 require 'devise/rails'
20 require 'state_machine'
21 require 'magent'
22 require 'haml'
23 require 'haml/template'
24 require 'sass'
25
26 Rails.logger = Logger.new("#{Rails.root}/log/#{File.basename($0).parameterize.to_s}.log")
27
28 Dir.chdir(Rails.root.to_s) do
29   $:.unshift ::File.expand_path("app/helpers")
30   $:.unshift ::File.expand_path("lib")
31
32   Mongoid.load!("./config/mongoid.yml")
33   Magent.setup(YAML.load_file(Rails.root.join('config', 'magent.yml')),
34                   Rails.env, {})
35
36   MongoidExt.init
37
38   # initializers
39   require './vendor/plugins/i18n_action_mailer/lib/i18n_action_mailer'
40   require './config/initializers/00_config'
41   require './config/initializers/01_locales'
42   require './config/initializers/constants'
43   require './config/initializers/devise'
44
45   ActiveSupport::Dependencies.mechanism = :require
46   ActiveSupport::Dependencies.autoload_paths << ::File.expand_path("lib")
47
48   Dir.glob("app/models/**/*.rb") do |model_path|
49     dirname = ::File.dirname(::File.expand_path(model_path))
50     ActiveSupport::Dependencies.autoload_paths << dirname if !ActiveSupport::Dependencies.autoload_paths.include?(dirname)
51
52     ::File.basename(model_path, ".rb").classify.constantize
53   end
54
55   if ENV["SHAPADO_LOAD_ROUTES"]
56     puts ">> Loading routes..."
57     Devise.warden_config = Warden::Config.new
58     Rails.application.routes_reloader.paths << Rails.root+"config/routes.rb"
59     Rails.application.routes_reloader.execute_if_updated
60     Rails.application.reload_routes!
61   end
62 end