Sha256: f5a2e6456f6c4aaa93aaf7aea40cc6dd3ce94b01632430a58f214cd0db1aa718

Contents?: true

Size: 903 Bytes

Versions: 4

Compression:

Stored size: 903 Bytes

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 set_current_attributes
        installed = run_specinfra(:check_package_is_installed, name)
        @current_attributes[:installed?] = installed

        if installed
          @current_attributes[:version] = run_specinfra(:get_package_version, name).stdout.strip
        end

        if action == :install
          @attributes[:installed?] = true
        end
      end

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
itamae-1.0.0.beta33 lib/itamae/resource/package.rb
itamae-1.0.0.beta32 lib/itamae/resource/package.rb
itamae-1.0.0.beta31 lib/itamae/resource/package.rb
itamae-1.0.0.beta30 lib/itamae/resource/package.rb