Changesets can be listed by changeset number.
The Git repository is here.
Changeset 334
Gullery equivalent of Changeset #312 in Beast.
- Comitted by: rool
- Date: Saturday March 19 17:32:44 2011 (over 13 years ago)
Affected files:
rool/rails/gullery/trunk/config/boot.rb:
prev. | current | |
1 | ||
1 | # Don't change this file! | |
2 | # Configure your app in config/environment.rb and config/environments/*.rb | |
3 | ||
4 | | |
5 | | |
6 | | |
7 | | |
4 | RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT) | |
5 | ||
6 | module Rails | |
7 | class << self | |
8 | def boot! | |
9 | unless booted? | |
10 | preinitialize | |
11 | pick_boot.run | |
12 | end | |
13 | end | |
14 | ||
15 | def booted? | |
16 | defined? Rails::Initializer | |
17 | end | |
18 | ||
19 | def pick_boot | |
20 | (vendor_rails? ? VendorBoot : GemBoot).new | |
21 | end | |
22 | ||
23 | def vendor_rails? | |
24 | File.exist?("#{RAILS_ROOT}/vendor/rails") | |
25 | end | |
26 | ||
27 | def preinitialize | |
28 | load(preinitializer_path) if File.exist?(preinitializer_path) | |
29 | end | |
30 | ||
31 | def preinitializer_path | |
32 | "#{RAILS_ROOT}/config/preinitializer.rb" | |
33 | end | |
end | ||
9 | | |
10 | ||
12 | ||
13 | | |
14 | ||
15 | | |
16 | | |
36 | class Boot | |
37 | def run | |
38 | load_initializer | |
39 | Rails::Initializer.run(:set_load_path) | |
40 | end | |
41 | end | |
42 | ||
43 | class VendorBoot < Boot | |
44 | def load_initializer | |
45 | require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer" | |
46 | Rails::Initializer.run(:install_gem_spec_stubs) | |
47 | Rails::GemDependency.add_frozen_gem_path | |
48 | end | |
49 | end | |
50 | ||
51 | class GemBoot < Boot | |
52 | def load_initializer | |
53 | self.class.load_rubygems | |
54 | load_rails_gem | |
55 | require 'initializer' | |
56 | end | |
57 | ||
58 | def load_rails_gem | |
59 | if version = self.class.gem_version | |
60 | gem 'rails', version | |
61 | else | |
62 | gem 'rails' | |
63 | end | |
64 | rescue Gem::LoadError => load_error | |
65 | if load_error.message =~ /Could not find RubyGem rails/ | |
66 | 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.) | |
67 | exit 1 | |
68 | else | |
69 | raise | |
70 | end | |
71 | end | |
72 | ||
73 | class << self | |
74 | def rubygems_version | |
75 | Gem::RubyGemsVersion rescue nil | |
76 | end | |
77 | ||
78 | def gem_version | |
79 | if defined? RAILS_GEM_VERSION | |
80 | RAILS_GEM_VERSION | |
81 | elsif ENV.include?('RAILS_GEM_VERSION') | |
82 | ENV['RAILS_GEM_VERSION'] | |
83 | else | |
84 | parse_gem_version(read_environment_rb) | |
85 | end | |
86 | end | |
87 | ||
88 | def load_rubygems | |
89 | min_version = '1.3.2' | |
90 | require 'rubygems' | |
91 | unless rubygems_version >= min_version | |
92 | $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.) | |
93 | exit 1 | |
94 | end | |
95 | ||
96 | rescue LoadError | |
97 | $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org) | |
98 | exit 1 | |
99 | end | |
100 | ||
101 | def parse_gem_version(text) | |
102 | $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/ | |
103 | end | |
104 | ||
105 | private | |
106 | def read_environment_rb | |
107 | File.read("#{RAILS_ROOT}/config/environment.rb") | |
108 | end | |
109 | end | |
110 | end | |
end | ||
19 | ||
113 | # All that for this: | |
114 | Rails.boot! |