Sha256: 328479f5f2f8aaccabf2f1d0a829a792ae064f95cd31e08313979c2e7836374f

Contents?: true

Size: 1.24 KB

Versions: 17

Compression:

Stored size: 1.24 KB

Contents

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)
        return if !attributes.version && current.installed

        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 current.installed
          run_specinfra(:remove_package, attributes.name, attributes.options)
          updated!
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
itamae-1.14.1 lib/itamae/resource/package.rb
itamae-1.14.0 lib/itamae/resource/package.rb
itamae-1.13.1 lib/itamae/resource/package.rb
itamae-1.13.0 lib/itamae/resource/package.rb
itamae-1.12.6 lib/itamae/resource/package.rb
itamae-1.12.5 lib/itamae/resource/package.rb
itamae-1.12.4 lib/itamae/resource/package.rb
itamae-1.12.3 lib/itamae/resource/package.rb
itamae-1.12.2 lib/itamae/resource/package.rb
itamae-1.12.1 lib/itamae/resource/package.rb
itamae-1.12.0 lib/itamae/resource/package.rb
itamae-1.11.2 lib/itamae/resource/package.rb
itamae-1.11.1 lib/itamae/resource/package.rb
itamae-1.11.0 lib/itamae/resource/package.rb
itamae-1.10.10 lib/itamae/resource/package.rb
itamae-1.10.9 lib/itamae/resource/package.rb
itamae-1.10.8 lib/itamae/resource/package.rb