Class: RubyConfig::RuntimeBase

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_config/runtime_base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(install_path, tmp_path) ⇒ RuntimeBase

Returns a new instance of RuntimeBase.



7
8
9
10
# File 'lib/ruby_config/runtime_base.rb', line 7

def initialize(install_path, tmp_path)
  @install_path = File.join(install_path, handle)
  @tmp_path = tmp_path
end

Instance Attribute Details

#install_pathObject (readonly)

Returns the value of attribute install_path.



5
6
7
# File 'lib/ruby_config/runtime_base.rb', line 5

def install_path
  @install_path
end

#tmp_pathObject (readonly)

Returns the value of attribute tmp_path.



5
6
7
# File 'lib/ruby_config/runtime_base.rb', line 5

def tmp_path
  @tmp_path
end

Instance Method Details

#additional_library_pathObject

aka site_ruby



99
100
101
# File 'lib/ruby_config/runtime_base.rb', line 99

def additional_library_path
  File.join(ruby_home_path, 'lib', 'ruby', 'site_ruby', major_version)
end

#already_installed?Boolean

Returns:

  • (Boolean)


111
112
113
# File 'lib/ruby_config/runtime_base.rb', line 111

def already_installed?
   Pathname.new(File.join(ruby_bin_path, 'ruby')).exist?
end

#archive_download_urlObject

download url of ruby runtime



42
43
44
# File 'lib/ruby_config/runtime_base.rb', line 42

def archive_download_url
  raise "Not implemented yet!"
end

#archive_file_nameObject

name of ruby runtime archive



37
38
39
# File 'lib/ruby_config/runtime_base.rb', line 37

def archive_file_name
  raise "Not implemented yet!"
end

#archive_pathObject



125
126
127
# File 'lib/ruby_config/runtime_base.rb', line 125

def archive_path
  File.join(@tmp_path, archive_file_name)
end

#create_directory_structureObject



119
120
121
122
123
# File 'lib/ruby_config/runtime_base.rb', line 119

def create_directory_structure
  [@install_path, @tmp_path, ruby_home_path, ruby_bin_path, gem_home_path].each do |path|
    FileUtils.mkdir_p(path)
  end
end

#default_library_pathObject



103
104
105
# File 'lib/ruby_config/runtime_base.rb', line 103

def default_library_path
  File.join(ruby_home_path, 'lib', 'ruby', major_version)
end

#deleteObject



115
116
117
# File 'lib/ruby_config/runtime_base.rb', line 115

def delete
  FileUtils.remove_entry_secure(@install_path)
end

#descriptionObject



51
52
53
# File 'lib/ruby_config/runtime_base.rb', line 51

def description
  raise "Not implemented yet!"
end

#do_installObject



12
13
14
15
# File 'lib/ruby_config/runtime_base.rb', line 12

def do_install
  prepare_install
  install
end

#gem_bin_pathObject



81
82
83
# File 'lib/ruby_config/runtime_base.rb', line 81

def gem_bin_path
  File.join(gem_home_path, 'bin')
end

#gem_executable_pathObject



89
90
91
92
# File 'lib/ruby_config/runtime_base.rb', line 89

def gem_executable_path
  puts "entering RuntimeBase::gem_executable_path.."
  File.join(ruby_bin_path, 'gem')
end

#gem_home_pathObject



77
78
79
# File 'lib/ruby_config/runtime_base.rb', line 77

def gem_home_path
  File.join(@install_path, 'gem')
end

#handleObject

technical name used to select runtime



47
48
49
# File 'lib/ruby_config/runtime_base.rb', line 47

def handle
  raise "Not implemented yet!"
end

#installObject

called after the archive was successfully downloaded to tmp/archive_file_name directory you might want to:

  • extract archive

  • configure && make && make install



21
22
23
# File 'lib/ruby_config/runtime_base.rb', line 21

def install
  raise "Not implemented yet!"
end

#irb_executable_pathObject



94
95
96
# File 'lib/ruby_config/runtime_base.rb', line 94

def irb_executable_path
  File.join(ruby_bin_path, 'irb')
end

#major_versionObject

example: 1.8 or 1.9



62
63
64
# File 'lib/ruby_config/runtime_base.rb', line 62

def major_version
  '1.8'
end

#post_installObject

called after:

  • runtime.install

  • switch to newly installed runtime

  • rubygems installation

you might want to:

  • install additional rubygems

  • set symlinks



33
34
# File 'lib/ruby_config/runtime_base.rb', line 33

def post_install
end

#prepare_installObject



129
130
131
132
# File 'lib/ruby_config/runtime_base.rb', line 129

def prepare_install
  create_directory_structure                  
  download_archive unless archive_exists?  
end

#ruby_bin_pathObject



73
74
75
# File 'lib/ruby_config/runtime_base.rb', line 73

def ruby_bin_path
  File.join(ruby_home_path, 'bin')
end

#ruby_executable_pathObject



85
86
87
# File 'lib/ruby_config/runtime_base.rb', line 85

def ruby_executable_path
  File.join(ruby_bin_path, 'ruby')
end

#ruby_home_pathObject

hash (key: alias name, value: alias bash script) def bash_alias;{};end



69
70
71
# File 'lib/ruby_config/runtime_base.rb', line 69

def ruby_home_path
  File.join(@install_path, 'ruby')
end

#rubygems_installed?Boolean

Returns:

  • (Boolean)


134
135
136
# File 'lib/ruby_config/runtime_base.rb', line 134

def rubygems_installed?
  File.exists?(gem_executable_path)      
end

#runtime_specific_gemsObject

optional Array of gem names of type string



57
58
59
# File 'lib/ruby_config/runtime_base.rb', line 57

def runtime_specific_gems
  []
end

#to_sObject



107
108
109
# File 'lib/ruby_config/runtime_base.rb', line 107

def to_s
  "#{description} [#{handle}]"
end