| 1 |
RAILS_ROOT = File.dirname(__FILE__) + "/../" |
|---|
| 2 |
RAILS_ENV = ENV['RAILS_ENV'] || 'development' |
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
ADDITIONAL_LOAD_PATHS = ["#{RAILS_ROOT}/test/mocks/#{RAILS_ENV}"] |
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
ADDITIONAL_LOAD_PATHS.concat(Dir["#{RAILS_ROOT}/app/models/[_a-z]*"]) |
|---|
| 10 |
ADDITIONAL_LOAD_PATHS.concat(Dir["#{RAILS_ROOT}/components/[_a-z]*"]) |
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
ADDITIONAL_LOAD_PATHS.concat %w( |
|---|
| 14 |
app |
|---|
| 15 |
app/models |
|---|
| 16 |
app/controllers |
|---|
| 17 |
app/helpers |
|---|
| 18 |
app/apis |
|---|
| 19 |
config |
|---|
| 20 |
lib |
|---|
| 21 |
).map { |dir| "#{RAILS_ROOT}/#{dir}" } |
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } |
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
require 'rubygems' |
|---|
| 29 |
require_gem 'activesupport' |
|---|
| 30 |
require_gem 'activerecord' |
|---|
| 31 |
require_gem 'actionpack' |
|---|
| 32 |
require_gem 'actionmailer' |
|---|
| 33 |
require_gem 'actionwebservice' |
|---|
| 34 |
require_gem 'rails' |
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
require_dependency "environments/#{RAILS_ENV}" |
|---|
| 39 |
ActiveRecord::Base.configurations = YAML::load(File.open("#{RAILS_ROOT}/config/database.yml")) |
|---|
| 40 |
if ActiveRecord::Base.configurations[RAILS_ENV] |
|---|
| 41 |
ActiveRecord::Base.establish_connection |
|---|
| 42 |
end |
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
begin |
|---|
| 47 |
RAILS_DEFAULT_LOGGER = Logger.new("#{RAILS_ROOT}/log/#{RAILS_ENV}.log") |
|---|
| 48 |
rescue StandardError |
|---|
| 49 |
RAILS_DEFAULT_LOGGER = Logger.new(STDERR) |
|---|
| 50 |
RAILS_DEFAULT_LOGGER.level = Logger::WARN |
|---|
| 51 |
RAILS_DEFAULT_LOGGER.warn( |
|---|
| 52 |
"Rails Error: Unable to access log file. Please ensure that log/#{RAILS_ENV}.log exists and is chmod 0666. " + |
|---|
| 53 |
"The log level has been raised to WARN and the output directed to STDERR until the problem is fixed." |
|---|
| 54 |
) |
|---|
| 55 |
end |
|---|
| 56 |
|
|---|
| 57 |
[ActiveRecord, ActionController, ActionMailer].each { |mod| mod::Base.logger ||= RAILS_DEFAULT_LOGGER } |
|---|
| 58 |
[ActionController, ActionMailer].each { |mod| mod::Base.template_root ||= "#{RAILS_ROOT}/app/views/" } |
|---|
| 59 |
ActionController::Routing::Routes.reload |
|---|
| 60 |
|
|---|
| 61 |
Controllers = Dependencies::LoadingModule.root( |
|---|
| 62 |
File.join(RAILS_ROOT, 'app', 'controllers'), |
|---|
| 63 |
File.join(RAILS_ROOT, 'components') |
|---|
| 64 |
) |
|---|
| 65 |
|
|---|
| 66 |
|
|---|