Class: Itamae::Plugin::Resource::Opam

Inherits:
Resource::Base
  • Object
show all
Defined in:
lib/itamae/plugin/resource/opam.rb

Instance Method Summary collapse

Instance Method Details

#action_install(action_options) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/itamae/plugin/resource/opam.rb', line 31

def action_install(action_options)
  if current.installed
    if attributes.version && current.version != attributes.version
      action!
      updated!
    end
  else
    action!
    updated!
  end
end

#action_uninstall(action_options) ⇒ Object



49
50
51
52
# File 'lib/itamae/plugin/resource/opam.rb', line 49

def action_uninstall(action_options)
  action!
  updated!
end

#action_upgrade(action_options) ⇒ Object



43
44
45
46
47
# File 'lib/itamae/plugin/resource/opam.rb', line 43

def action_upgrade(action_options)
  return if current.installed && attributes.version && attributes.version == current.version
  action!
  updated!
end

#pre_actionObject



12
13
14
15
16
17
18
19
# File 'lib/itamae/plugin/resource/opam.rb', line 12

def pre_action
  case @current_action
  when :install
    attributes.installed = true
  when :uninstall
    attributes.installed = false
  end
end

#set_current_attributesObject



21
22
23
24
25
26
27
28
29
# File 'lib/itamae/plugin/resource/opam.rb', line 21

def set_current_attributes
  installed = installed_opams.find{|opam| opam[:name] == attributes.package_name }
  current.installed = !!installed

  if current.installed
    version  = installed[:version]
    current.version = version if version != attributes.version
  end
end