Class: Hookit::Resource::Package

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

Instance Attribute Summary

Attributes inherited from Base

#dict

Instance Method Summary collapse

Methods inherited from Base

#action, actions, #can_run?, default_action, #default_action, field, #not_if, #only_if

Constructor Details

#initialize(name) ⇒ Package

Returns a new instance of Package.



13
14
15
16
17
# File 'lib/hookit/resource/package.rb', line 13

def initialize(name)
  package_name(name) unless source
  scope :default unless scope
  super
end

Instance Method Details

#install!Object



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/hookit/resource/package.rb', line 26

def install!
  begin
    install_package
  rescue Hookit::Error::UnexpectedExit
    if not registry("pkgsrc.#{scope}.updated")
      update_pkg_db
      registry("pkgsrc.#{scope}.updated", true)
      retry
    else
      raise
    end
  end
end

#run(action) ⇒ Object



19
20
21
22
23
24
# File 'lib/hookit/resource/package.rb', line 19

def run(action)
  case action
  when :install
    install!
  end
end