Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 373
- Log:
Initial import of Radiant 0.9.1, which is now packaged as a gem. This is an
import of the tagged 0.9.1 source checked out from GitHub, which isn't quite
the same as the gem distribution - but it doesn't seem to be available in an
archived form and the installed gem already has modifications, so this is
the closest I can get.
- Author:
- rool
- Date:
- Mon Mar 21 13:40:05 +0000 2011
- Size:
- 3821 Bytes
1 | # Don't change this file! |
2 | # Configure your app in config/environment.rb and config/environments/*.rb |
3 | |
4 | RAILS_ROOT = File.expand_path("#{File.dirname(__FILE__)}/..") unless defined?(RAILS_ROOT) |
5 | |
6 | module Rails |
7 | class << self |
8 | def vendor_rails? |
9 | File.exist?("#{RAILS_ROOT}/vendor/rails") |
10 | end |
11 | end |
12 | end |
13 | |
14 | module Radiant |
15 | class << self |
16 | def boot! |
17 | unless booted? |
18 | preinitialize |
19 | pick_boot.run |
20 | end |
21 | end |
22 | |
23 | def booted? |
24 | defined? Radiant::Initializer |
25 | end |
26 | |
27 | def pick_boot |
28 | case |
29 | when app? |
30 | AppBoot.new |
31 | when vendor? |
32 | VendorBoot.new |
33 | else |
34 | GemBoot.new |
35 | end |
36 | end |
37 | |
38 | def vendor? |
39 | File.exist?("#{RAILS_ROOT}/vendor/radiant") |
40 | end |
41 | |
42 | def app? |
43 | File.exist?("#{RAILS_ROOT}/lib/radiant.rb") |
44 | end |
45 | |
46 | def preinitialize |
47 | load(preinitializer_path) if File.exist?(preinitializer_path) |
48 | end |
49 | |
50 | def loaded_via_gem? |
51 | pick_boot.is_a? GemBoot |
52 | end |
53 | |
54 | def preinitializer_path |
55 | "#{RAILS_ROOT}/config/preinitializer.rb" |
56 | end |
57 | end |
58 | |
59 | class Boot |
60 | def run |
61 | load_initializer |
62 | end |
63 | |
64 | def load_initializer |
65 | begin |
66 | require 'radiant' |
67 | require 'radiant/initializer' |
68 | rescue LoadError => e |
69 | $stderr.puts %(Radiant could not be initialized. #{load_error_message}) |
70 | exit 1 |
71 | end |
72 | Radiant::Initializer.run(:set_load_path) |
73 | end |
74 | end |
75 | |
76 | class VendorBoot < Boot |
77 | def load_initializer |
78 | $LOAD_PATH.unshift "#{RAILS_ROOT}/vendor/radiant/lib" |
79 | super |
80 | end |
81 | |
82 | def load_error_message |
83 | "Please verify that vendor/radiant contains a complete copy of the Radiant sources." |
84 | end |
85 | end |
86 | |
87 | class AppBoot < Boot |
88 | def load_initializer |
89 | $LOAD_PATH.unshift "#{RAILS_ROOT}/lib" |
90 | super |
91 | end |
92 | |
93 | def load_error_message |
94 | "Please verify that you have a complete copy of the Radiant sources." |
95 | end |
96 | end |
97 | |
98 | class GemBoot < Boot |
99 | def load_initializer |
100 | self.class.load_rubygems |
101 | load_radiant_gem |
102 | super |
103 | end |
104 | |
105 | def load_error_message |
106 | "Please reinstall the Radiant gem with the command 'gem install radiant'." |
107 | end |
108 | |
109 | def load_radiant_gem |
110 | if version = self.class.gem_version |
111 | gem 'radiant', version |
112 | else |
113 | gem 'radiant' |
114 | end |
115 | rescue Gem::LoadError => load_error |
116 | $stderr.puts %(Missing the Radiant #{version} gem. Please `gem install -v=#{version} radiant`, update your RADIANT_GEM_VERSION setting in config/environment.rb for the Radiant version you do have installed, or comment out RADIANT_GEM_VERSION to use the latest version installed.) |
117 | exit 1 |
118 | end |
119 | |
120 | class << self |
121 | def rubygems_version |
122 | Gem::RubyGemsVersion rescue nil |
123 | end |
124 | |
125 | def gem_version |
126 | if defined? RADIANT_GEM_VERSION |
127 | RADIANT_GEM_VERSION |
128 | elsif ENV.include?('RADIANT_GEM_VERSION') |
129 | ENV['RADIANT_GEM_VERSION'] |
130 | else |
131 | parse_gem_version(read_environment_rb) |
132 | end |
133 | end |
134 | |
135 | def load_rubygems |
136 | require 'rubygems' |
137 | |
138 | min_version = '1.3.1' |
139 | unless rubygems_version >= min_version |
140 | $stderr.puts %(Radiant requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.) |
141 | exit 1 |
142 | end |
143 | |
144 | rescue LoadError |
145 | $stderr.puts %(Radiant requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org) |
146 | exit 1 |
147 | end |
148 | |
149 | def parse_gem_version(text) |
150 | $1 if text =~ /^[^#]*RADIANT_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/ |
151 | end |
152 | |
153 | private |
154 | def read_environment_rb |
155 | File.read("#{RAILS_ROOT}/config/environment.rb") |
156 | end |
157 | end |
158 | end |
159 | end |
160 | |
161 | # All that for this: |
162 | Radiant.boot! |