Sha256: 3b0e81bfcac638b87bdc82dfbeca865264662324be1b67b77b7c13e6159a2cb2

Contents?: true

Size: 1.24 KB

Versions: 75

Compression:

Stored size: 1.24 KB

Contents

require 'itamae'

module Itamae
  module Resource
    class Package < Base
      define_attribute :action, default: :install
      define_attribute :name, type: String, default_name: true
      define_attribute :version, type: String
      define_attribute :options, type: String

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

      def set_current_attributes
        current.installed = run_specinfra(:check_package_is_installed, attributes.name)

        if current.installed
          current.version = run_specinfra(:get_package_version, attributes.name).stdout.strip
        end
      end

      def action_install(action_options)
        unless run_specinfra(:check_package_is_installed, attributes.name, attributes.version)
          run_specinfra(:install_package, attributes.name, attributes.version, attributes.options)
          updated!
        end
      end

      def action_remove(action_options)
        if run_specinfra(:check_package_is_installed, attributes.name, nil)
          run_specinfra(:remove_package, attributes.name, attributes.options)
          updated!
        end
      end
    end
  end
end

Version data entries

75 entries across 75 versions & 2 rubygems

Version Path
itamae-1.2.6 lib/itamae/resource/package.rb
itamae-1.2.5 lib/itamae/resource/package.rb
itamae-1.2.4 lib/itamae/resource/package.rb
itamae-1.2.3 lib/itamae/resource/package.rb
itamae-1.2.2 lib/itamae/resource/package.rb
itamae-1.2.0 lib/itamae/resource/package.rb
itamae-1.1.26 lib/itamae/resource/package.rb
itamae-1.1.25 lib/itamae/resource/package.rb
itamae-1.1.24 lib/itamae/resource/package.rb
itamae-1.1.23 lib/itamae/resource/package.rb
itamae-1.1.22 lib/itamae/resource/package.rb
itamae-1.1.21 lib/itamae/resource/package.rb
itamae-1.1.20 lib/itamae/resource/package.rb
itamae-1.1.19 lib/itamae/resource/package.rb
itamae-1.1.18 lib/itamae/resource/package.rb