Class: InfinityTest::Dependencies

Inherits:
Object
  • Object
show all
Defined in:
lib/infinity_test/dependencies.rb

Constant Summary collapse

RVM_HOME_DIRECTORY =
File.expand_path("~/.rvm/lib")
RVM_SYSTEM_WIDE_DIRECTORY =
"/usr/local/rvm/lib"
RVM_LIBRARY_DIRECTORY =
File.expand_path("~/.rvm/lib")

Class Method Summary collapse

Class Method Details



60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/infinity_test/dependencies.rb', line 60

def print_info_about_rvm
  puts
  puts "It appears that you have not installed the RVM library in #{RVM_HOME_DIRECTORY} or in #{RVM_SYSTEM_WIDE_DIRECTORY} or RVM is very old.\n"
  puts "The RVM is installed?"
  puts "If not, please see http://rvm.beginrescueend.com/rvm/install/"
  puts "If so, try to run:"
  puts "\t rvm update --head (or if you're using the head of rvm try: rvm get head)"
  puts "\nIf the error continues, please create an issue in http://github.com/tomas-stefano/infinity_test"
  puts 'Thanks :)'
  puts
  exit        
end

.require_home_rvmObject

Try to require the rvm in home folder If not suceed raise a LoadError Try to see if the user has the RVM 1.0 or higher for the RVM Ruby API If not raise a NameError



24
25
26
27
# File 'lib/infinity_test/dependencies.rb', line 24

def require_home_rvm
  $LOAD_PATH.unshift(RVM_HOME_DIRECTORY) unless $LOAD_PATH.include?(RVM_HOME_DIRECTORY)
  require_rvm_ruby_api
end

.require_rvmObject



42
43
44
45
46
47
48
# File 'lib/infinity_test/dependencies.rb', line 42

def require_rvm
  begin
    require_home_rvm
  rescue LoadError, NameError
    try_to_require_system_wide
  end
end

.require_rvm_ruby_apiObject



13
14
15
16
# File 'lib/infinity_test/dependencies.rb', line 13

def require_rvm_ruby_api
  require 'rvm'
  RVM::Environment
end

.require_rvm_system_wideObject



29
30
31
32
# File 'lib/infinity_test/dependencies.rb', line 29

def require_rvm_system_wide
  $LOAD_PATH.unshift(RVM_SYSTEM_WIDE_DIRECTORY) unless $LOAD_PATH.include?(RVM_SYSTEM_WIDE_DIRECTORY)
  require_rvm_ruby_api
end

.require_without_rubygems(options) ⇒ Object



50
51
52
53
54
55
56
57
58
# File 'lib/infinity_test/dependencies.rb', line 50

def require_without_rubygems(options)
  gem_name = options[:gem]
  begin
    require gem_name
  rescue LoadError
    require 'rubygems'
    require gem_name
  end
end

.try_to_require_system_wideObject



34
35
36
37
38
39
40
# File 'lib/infinity_test/dependencies.rb', line 34

def try_to_require_system_wide
  begin
    require_rvm_system_wide
  rescue LoadError, NameError
    print_info_about_rvm
  end        
end