Class: Rails::GemBoot

Inherits:
Boot show all
Defined in:
lib/ontomde-core/inspector/rails/config/boot.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Boot

#run

Class Method Details

.gem_versionObject



73
74
75
76
77
78
79
80
81
# File 'lib/ontomde-core/inspector/rails/config/boot.rb', line 73

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

.load_rubygemsObject



83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/ontomde-core/inspector/rails/config/boot.rb', line 83

def load_rubygems
  require 'rubygems'

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

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

.parse_gem_version(text) ⇒ Object



96
97
98
# File 'lib/ontomde-core/inspector/rails/config/boot.rb', line 96

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

.rubygems_versionObject



69
70
71
# File 'lib/ontomde-core/inspector/rails/config/boot.rb', line 69

def rubygems_version
  Gem::RubyGemsVersion if defined? Gem::RubyGemsVersion
end

Instance Method Details

#load_initializerObject



51
52
53
54
55
# File 'lib/ontomde-core/inspector/rails/config/boot.rb', line 51

def load_initializer
  self.class.load_rubygems
  load_rails_gem
  require 'initializer'
end

#load_rails_gemObject



57
58
59
60
61
62
63
64
65
66
# File 'lib/ontomde-core/inspector/rails/config/boot.rb', line 57

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