Class: RubyConfig::Installer

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

Constant Summary collapse

RUBY_CONFIG_GEM_NAME =
'fdietz-ruby-config'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ruby_config_path) ⇒ Installer

Returns a new instance of Installer.



11
12
13
14
15
16
# File 'lib/ruby_config/installer.rb', line 11

def initialize(ruby_config_path)
  @ruby_config_path = ruby_config_path
  @rubygems = RubyConfig::Rubygems.new(ruby_config_path)
  
  ensure_config_directory_exists
end

Instance Attribute Details

#rubygemsObject (readonly)

Returns the value of attribute rubygems.



9
10
11
# File 'lib/ruby_config/installer.rb', line 9

def rubygems
  @rubygems
end

Instance Method Details

#install(runtime) ⇒ Object



18
19
20
21
22
23
# File 'lib/ruby_config/installer.rb', line 18

def install(runtime)       
  runtime.do_install 

  # TODO: only cleanup runtime-specific files
  cleanup_tmp_dir
end

#post_install(runtime) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/ruby_config/installer.rb', line 25

def post_install(runtime)
  @rubygems.install(runtime) unless runtime.rubygems_installed?

  runtime.post_install

  # TODO: check gem installation 
  begin
    # install thyself
    @rubygems.gem_install(RUBY_CONFIG_GEM_NAME, runtime)
  rescue Exception => e
    puts "Error when trying to install fdietz-ruby-config gem: #{e.message}"
  end
  
  begin
    runtime.runtime_specific_gems.each { |gem| @rubygems.gem_install(gem, runtime)  }
  rescue Exception => e
    puts "Error when trying to install #{runtime.runtime_specific_gems.join(',')} gems: #{e.message}"
  end
end

#runtime_install_pathObject



45
46
47
# File 'lib/ruby_config/installer.rb', line 45

def runtime_install_path
  File.join(@ruby_config_path, 'runtimes')
end

#tmp_pathObject



49
50
51
# File 'lib/ruby_config/installer.rb', line 49

def tmp_path
  File.join(@ruby_config_path, 'tmp')
end