Class: Resource::Gem

Inherits:
Base
  • Object
show all
Defined in:
lib/resource/gem.rb

Instance Method Summary collapse

Methods inherited from Base

inherited, #not_if, #set_base_defaults, #should_skip?, #unix_mode

Methods included from ClassAttr

included

Methods included from BlockAttr

included

Constructor Details

#initialize(name, &block) ⇒ Gem

Returns a new instance of Gem.



7
8
9
10
11
12
# File 'lib/resource/gem.rb', line 7

def initialize name, &block
  set_base_defaults
  @owner = 'root'
  @name = name
  self.instance_eval(&block)
end

Instance Method Details

#runObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/resource/gem.rb', line 14

def run
  command = []
  command << "gem install #{@name}"
  command << "--source #{@source}" if @source
  command << "--version #{@version}" if @version
  Execution.block 'Installing gem', @name, @owner do |b|
    b.always_run @always_run
    b.run(command * ' ')
  end
end