Class: BriskBills::GemBoot

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Boot

#run

Class Method Details

.gem_versionObject



130
131
132
133
134
135
136
137
138
# File 'lib/generators/instance/templates/instance_boot.rb', line 130

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

.load_rubygemsObject



140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/generators/instance/templates/instance_boot.rb', line 140

def load_rubygems
  require 'rubygems'

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

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

.parse_gem_version(text) ⇒ Object



153
154
155
# File 'lib/generators/instance/templates/instance_boot.rb', line 153

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

.rubygems_versionObject



126
127
128
# File 'lib/generators/instance/templates/instance_boot.rb', line 126

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

Instance Method Details

#load_briskbills_gemObject



114
115
116
117
118
119
120
121
122
123
# File 'lib/generators/instance/templates/instance_boot.rb', line 114

def load_briskbills_gem
  if version = self.class.gem_version
    gem 'brisk-bills', version
  else
    gem 'brisk-bills'
  end
rescue Gem::LoadError => load_error
  $stderr.puts %(Missing the BriskBills #{version} gem. Please `gem install -v=#{version} rails`, update your BRISKBILLS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out BRISKBILLS_GEM_VERSION to use the latest version installed.)
  exit 1
end

#load_error_messageObject



110
111
112
# File 'lib/generators/instance/templates/instance_boot.rb', line 110

def load_error_message
 "Please reinstall the BriskBills gem with the command 'gem install brisk-bills'."
end

#load_initializerObject



103
104
105
106
107
108
# File 'lib/generators/instance/templates/instance_boot.rb', line 103

def load_initializer
  self.class.load_rubygems
  load_briskbills_gem
  # require 'initializer'
  super
end