Class: Gemi::Installer

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

Instance Method Summary collapse

Constructor Details

#initialize(array = []) ⇒ Installer

Returns a new instance of Installer.



5
6
7
8
9
10
11
# File 'lib/installer.rb', line 5

def initialize(array = [])
  unless array.is_a? Array
    raise UninstalableError.new('Not an array of gems')
  end
  @gems = []
  array.each { |gem| add_gem(gem) }
end

Instance Method Details

#add_gem(new_gem) ⇒ Object



13
14
15
16
17
18
# File 'lib/installer.rb', line 13

def add_gem(new_gem)
  unless new_gem.is_a? Gemi::Gem
    raise UninstalableError.new('Only Gemi::Gem\'s are instalable')
  end
  @gems << new_gem
end

#count_gemsObject



20
21
22
# File 'lib/installer.rb', line 20

def count_gems
  @gems.size
end

#run!Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/installer.rb', line 24

def run!
  @gems.each do |gem|
    if gem.native?
      puts "Skipped #{gem.name} because of native extensions"
    else
      puts gem.to_command
      puts `#{gem.to_command}`
    end
  end
end