<commit_before>require 'itamae'

module Itamae
  module Resource
    class Service < Base
      define_attribute :action, default: :nothing
      define_attribute :name, type: String, default_name: true

      def set_current_attributes
        @current_attributes[:running?] = run_specinfra(:check_service_is_running, name)

        actions = [action].flatten
        if actions.include?(:start)
          @attributes[:running?] = true
        elsif actions.include?(:stop)
          @attributes[:running?] = false
        elsif actions.include?(:restart)
          @attributes[:running?] = true
        end
      end

      def start_action
        run_specinfra(:start_service, name)
      end

      def stop_action
        run_specinfra(:stop_service, name)
      end

      def restart_action<commit_msg>Show whether the service is enabled or not.<commit_after>require 'itamae'

module Itamae
  module Resource
    class Service < Base
      define_attribute :action, default: :nothing
      define_attribute :name, type: String, default_name: true

      def set_current_attributes
        @current_attributes[:running?] = run_specinfra(:check_service_is_running, name)
        @current_attributes[:enabled?] = run_specinfra(:check_service_is_enabled, name)

        actions = [action].flatten
        if actions.include?(:start)
          @attributes[:running?] = true
        elsif actions.include?(:stop)
          @attributes[:running?] = false
        elsif actions.include?(:restart)
          @attributes[:running?] = true
        end

        if actions.include?(:enable)
          @attributes[:enabled?] = true
        elsif actions.include?(:disable)
          @attributes[:enabled?] = false
        end
      end

      def start_action
        run_specinfra(:start_service, name)
      end

      def stop_action
        run_specinfra(:stop_service, name)
      end

      def restart_action
{'fraction_non_alphanumeric': 0.0905759162303665, 'fraction_numerical': 0.0, 'mean_word_length': 2.6679462571976966, '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': '5261725', 'n_tokens_mistral': 540, 'n_tokens_neox': 519, 'n_words': 122}