Class: Radiant::GemBoot

Inherits:
Boot
  • Object
show all
Defined in:
lib/generators-rails2/instance/templates/instance_boot.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Boot

#run

Class Method Details

.gem_versionObject



125
126
127
128
129
130
131
132
133
# File 'lib/generators-rails2/instance/templates/instance_boot.rb', line 125

def gem_version
  if defined? RADIANT_GEM_VERSION
    RADIANT_GEM_VERSION
  elsif ENV.include?('RADIANT_GEM_VERSION')
    ENV['RADIANT_GEM_VERSION']
  else
    parse_gem_version(read_environment_rb)
  end
end

.load_rubygemsObject



135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/generators-rails2/instance/templates/instance_boot.rb', line 135

def load_rubygems
  require 'rubygems'

  unless rubygems_version >= '0.9.4'
    $stderr.puts %(Radiant requires RubyGems >= 0.9.4 (you have #{rubygems_version}). Please `gem update --system` and try again.)
    exit 1
  end

rescue LoadError
  $stderr.puts %(Radiant requires RubyGems >= 0.9.4. Please install RubyGems and try again: http://rubygems.rubyforge.org)
  exit 1
end

.parse_gem_version(text) ⇒ Object



148
149
150
# File 'lib/generators-rails2/instance/templates/instance_boot.rb', line 148

def parse_gem_version(text)
  $1 if text =~ /^[^#]*RADIANT_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
end

.rubygems_versionObject



121
122
123
# File 'lib/generators-rails2/instance/templates/instance_boot.rb', line 121

def rubygems_version
  Gem::RubyGemsVersion rescue nil
end

Instance Method Details

#load_error_messageObject



105
106
107
# File 'lib/generators-rails2/instance/templates/instance_boot.rb', line 105

def load_error_message
 "Please reinstall the Radiant gem with the command 'gem install radiant'."
end

#load_initializerObject



99
100
101
102
103
# File 'lib/generators-rails2/instance/templates/instance_boot.rb', line 99

def load_initializer
  self.class.load_rubygems
  load_radiant_gem
  super
end

#load_radiant_gemObject



109
110
111
112
113
114
115
116
117
118
# File 'lib/generators-rails2/instance/templates/instance_boot.rb', line 109

def load_radiant_gem
  if version = self.class.gem_version
    gem 'radiant', version
  else
    gem 'radiant'
  end
rescue Gem::LoadError => load_error
  $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.)
  exit 1
end