To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / .svn / pristine / da / da30f481208d9237a3f64922ab33dc92a83a4114.svn-base @ 1297:0a574315af3e
History | View | Annotate | Download (2.9 KB)
| 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 |
if load_error.message =~ /Could not find RubyGem rails/ |
| 71 |
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.)
|
| 72 |
exit 1 |
| 73 |
else |
| 74 |
raise |
| 75 |
end |
| 76 |
end |
| 77 |
|
| 78 |
class << self |
| 79 |
def rubygems_version |
| 80 |
Gem::RubyGemsVersion rescue nil |
| 81 |
end |
| 82 |
|
| 83 |
def gem_version |
| 84 |
if defined? RAILS_GEM_VERSION |
| 85 |
RAILS_GEM_VERSION |
| 86 |
elsif ENV.include?('RAILS_GEM_VERSION')
|
| 87 |
ENV['RAILS_GEM_VERSION'] |
| 88 |
else |
| 89 |
parse_gem_version(read_environment_rb) |
| 90 |
end |
| 91 |
end |
| 92 |
|
| 93 |
def load_rubygems |
| 94 |
min_version = '1.3.2' |
| 95 |
require 'rubygems' |
| 96 |
unless rubygems_version >= min_version |
| 97 |
$stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
|
| 98 |
exit 1 |
| 99 |
end |
| 100 |
|
| 101 |
rescue LoadError |
| 102 |
$stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
|
| 103 |
exit 1 |
| 104 |
end |
| 105 |
|
| 106 |
def parse_gem_version(text) |
| 107 |
$1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/ |
| 108 |
end |
| 109 |
|
| 110 |
private |
| 111 |
def read_environment_rb |
| 112 |
File.read("#{RAILS_ROOT}/config/environment.rb")
|
| 113 |
end |
| 114 |
end |
| 115 |
end |
| 116 |
end |
| 117 |
|
| 118 |
# All that for this: |
| 119 |
Rails.boot! |