Class: MultiRails::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/multi_rails/config.rb

Overview

Simple config object

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.rails_requiresObject

Returns the value of attribute rails_requires.



12
13
14
# File 'lib/multi_rails/config.rb', line 12

def rails_requires
  @rails_requires
end

.weird_versionsObject

Returns the value of attribute weird_versions.



12
13
14
# File 'lib/multi_rails/config.rb', line 12

def weird_versions
  @weird_versions
end

Class Method Details

.load_pathObject



31
32
33
# File 'lib/multi_rails/config.rb', line 31

def load_path
  $LOAD_PATH
end

.named_version_lookup(version) ⇒ Object

Raises:



19
20
21
22
23
# File 'lib/multi_rails/config.rb', line 19

def named_version_lookup(version)
  version = @weird_versions[version] || version
  raise MultiRailsError, "Can't find Rails gem version #{version} - available versions are: #{Loader.all_rails_versions.to_sentence})." if !Loader.all_rails_versions.include? version
  version
end

.rails_load_pathObject

Output rails from the load path as a sanity check, to make sure we are really using the version of Rails we think we are



26
27
28
29
# File 'lib/multi_rails/config.rb', line 26

def rails_load_path
  gem_rails_regex = %r[gems/(rails-[\d\.]+)/]
  load_path.grep(gem_rails_regex).first.match(gem_rails_regex)[1] rescue nil
end

.version_lookup(version = nil) ⇒ Object



13
14
15
16
17
# File 'lib/multi_rails/config.rb', line 13

def version_lookup(version = nil)
  return named_version_lookup(version) if version
  return named_version_lookup(ENV["MULTIRAILS_RAILS_VERSION"]) if ENV['MULTIRAILS_RAILS_VERSION']
  Loader.latest_stable_version
end