<commit_before>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

      def install_action
        unless run_specinfra(:check_package_is_installed, name, version)
          run_specinfra(:install_package, name, version)<commit_msg>Show diff of package resource.<commit_after>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

      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
        unless run_specinfra(:check_package_is_installed, name, version)
          run_specinfra(:install_package, name, version)
{'fraction_non_alphanumeric': 0.07148659626320066, 'fraction_numerical': 0.0, 'mean_word_length': 3.4, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2621637', 'n_tokens_mistral': 338, 'n_tokens_neox': 320, 'n_words': 87}