|
1
|
# Don't change this file!
|
|
2
|
# Configure your app in config/environment.rb and config/environments/*.rb
|
|
3
|
|
|
4
|
if RUBY_VERSION >= '1.9'
|
|
5
|
require 'yaml'
|
|
6
|
YAML::ENGINE.yamler = 'syck'
|
|
7
|
end
|
|
8
|
|
|
9
|
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
|
|
10
|
|
|
11
|
module Rails
|
|
12
|
class << self
|
|
13
|
def boot!
|
|
14
|
unless booted?
|
|
15
|
preinitialize
|
|
16
|
pick_boot.run
|
|
17
|
end
|
|
18
|
end
|
|
19
|
|
|
20
|
def booted?
|
|
21
|
defined? Rails::Initializer
|
|
22
|
end
|
|
23
|
|
|
24
|
def pick_boot
|
|
25
|
(vendor_rails? ? VendorBoot : GemBoot).new
|
|
26
|
end
|
|
27
|
|
|
28
|
def vendor_rails?
|
|
29
|
File.exist?("#{RAILS_ROOT}/vendor/rails")
|
|
30
|
end
|
|
31
|
|
|
32
|
def preinitialize
|
|
33
|
load(preinitializer_path) if File.exist?(preinitializer_path)
|
|
34
|
end
|
|
35
|
|
|
36
|
def preinitializer_path
|
|
37
|
"#{RAILS_ROOT}/config/preinitializer.rb"
|
|
38
|
end
|
|
39
|
end
|
|
40
|
|
|
41
|
class Boot
|
|
42
|
def run
|
|
43
|
load_initializer
|
|
44
|
Rails::Initializer.run(:set_load_path)
|
|
45
|
end
|
|
46
|
end
|
|
47
|
|
|
48
|
class VendorBoot < Boot
|
|
49
|
def load_initializer
|
|
50
|
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
|
|
51
|
Rails::Initializer.run(:install_gem_spec_stubs)
|
|
52
|
Rails::GemDependency.add_frozen_gem_path
|
|
53
|
end
|
|
54
|
end
|
|
55
|
|
|
56
|
class GemBoot < Boot
|
|
57
|
def load_initializer
|
|
58
|
self.class.load_rubygems
|
|
59
|
load_rails_gem
|
|
60
|
require 'initializer'
|
|
61
|
end
|
|
62
|
|
|
63
|
def load_rails_gem
|
|
64
|
if version = self.class.gem_version
|
|
65
|
gem 'rails', version
|
|
66
|
else
|
|
67
|
gem 'rails'
|
|
68
|
end
|
|
69
|
rescue Gem::LoadError => load_error
|
|
70
|
$stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
|
|
71
|
exit 1
|
|
72
|
end
|
|
73
|
|
|
74
|
class << self
|
|
75
|
def rubygems_version
|
|
76
|
Gem::RubyGemsVersion rescue nil
|
|
77
|
end
|
|
78
|
|
|
79
|
def gem_version
|
|
80
|
if defined? RAILS_GEM_VERSION
|
|
81
|
RAILS_GEM_VERSION
|
|
82
|
elsif ENV.include?('RAILS_GEM_VERSION')
|
|
83
|
ENV['RAILS_GEM_VERSION']
|
|
84
|
else
|
|
85
|
parse_gem_version(read_environment_rb)
|
|
86
|
end
|
|
87
|
end
|
|
88
|
|
|
89
|
def load_rubygems
|
|
90
|
min_version = '1.3.2'
|
|
91
|
require 'rubygems'
|
|
92
|
unless rubygems_version >= min_version
|
|
93
|
$stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
|
|
94
|
exit 1
|
|
95
|
end
|
|
96
|
|
|
97
|
rescue LoadError
|
|
98
|
$stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
|
|
99
|
exit 1
|
|
100
|
end
|
|
101
|
|
|
102
|
def parse_gem_version(text)
|
|
103
|
$1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
|
|
104
|
end
|
|
105
|
|
|
106
|
private
|
|
107
|
def read_environment_rb
|
|
108
|
File.read("#{RAILS_ROOT}/config/environment.rb")
|
|
109
|
end
|
|
110
|
end
|
|
111
|
end
|
|
112
|
end
|
|
113
|
|
|
114
|
# TODO: Workaround for #7013 to be removed for 1.2.0
|
|
115
|
# Loads i18n 0.4.2 before Rails loads any more recent gem
|
|
116
|
# 0.5.0 is not compatible with the old interpolation syntax
|
|
117
|
# Plugins will have to migrate to the new syntax for 1.2.0
|
|
118
|
require 'rubygems'
|
|
119
|
begin
|
|
120
|
gem 'i18n', '0.4.2'
|
|
121
|
rescue Gem::LoadError => load_error
|
|
122
|
$stderr.puts %(Missing the i18n 0.4.2 gem. Please `gem install -v=0.4.2 i18n`)
|
|
123
|
exit 1
|
|
124
|
end
|
|
125
|
|
|
126
|
# All that for this:
|
|
127
|
Rails.boot!
|