<commit_before>#
# Author:: <NAME> (<<EMAIL>>)
# Copyright:: Copyright (c) 2008 OpsCode, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

require File.join(File.dirname(__FILE__), "..", "mixin", "command")

class Chef
  class Provider
    class Service < Chef::Provider

      include Chef::Mixin::Command

      def initialize(node, new_resource)
        super(node, new_resource)
        @enabled = nil
      end

      def action_enable
        unless @current_resource.enabled
          Chef::Log.debug("#{@new_resource}: attempting to enable")
          status = enable_service(@new_resource.service_name)
          if status
            Chef::Log.info("#{@new_resource}: enabled succesfully")
          end
        else
          Chef::Log.debug("#{@new_resource}: not enabling, already enabled")
        end
      end

      def action_disable
        if @current_resource.enabled
          Chef::Log.debug("#{@new_resource}: attempting to disable")
          status = disable_service(@new_resource.service_name)
          if status
            Chef::Log.info("#{@new_resource}: disabled succesfully")
          end
        else
          Chef::Log.debug("#{@new_resource}: not disabling, already disabled")
        end
      end

      def action_start
        unless @current_resource.running
          Chef::Log.debug("#{@new_resource}: attempting to start")
          status = start_service(@new_resource.service_name)
          if status
            Chef::Log.info("Started service #{@new_resource} succesfully")
          end
        else
          Chef::Log.debug("#{@new_resource}: not starting, already running")
        end 
      end

      def action_stop
        if @current_resource.running
          Chef::Log.debug("#{@new_resource}: attempting to stop")
          status = stop_service(@new_resource.service_name)
          if status
            Chef::Log.info("#{@new_resource}: stopped succesfully")
          end
        else
          Chef::Log.debug("#{@new_resource}: not stopping, already stopped")
        end 
      end
      
      def action_restart
          if @current_resource.running
            Chef::Log.debug("#{@new_resource}: attempting to restart")
            status = restart_service(@new_resource.service_name)
            if status
              Chef::Log.info("#{@new_resource}: restarted succesfully")
            end
          end
        end
      end

      def action_reload
        unless @new_resource.supports[:reload] or @new_resource.reload_command
          raise Chef::Exception::UnsupportedAction, "#{self.to_s} does not support :reload"
        else
          if @current_resource.running
            Chef::Log.debug("#{@new_resource}: attempting to reload")
            status = reload_service(@new_resource.service_name)
            if status
              Chef::Log.info("#{@new_resource}: reloaded succesfully")
            end<commit_msg>Fixing a spurious end statement<commit_after>#
# Author:: <NAME> (<<EMAIL>>)
# Copyright:: Copyright (c) 2008 OpsCode, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

require File.join(File.dirname(__FILE__), "..", "mixin", "command")

class Chef
  class Provider
    class Service < Chef::Provider

      include Chef::Mixin::Command

      def initialize(node, new_resource)
        super(node, new_resource)
        @enabled = nil
      end

      def action_enable
        unless @current_resource.enabled
          Chef::Log.debug("#{@new_resource}: attempting to enable")
          status = enable_service(@new_resource.service_name)
          if status
            Chef::Log.info("#{@new_resource}: enabled succesfully")
          end
        else
          Chef::Log.debug("#{@new_resource}: not enabling, already enabled")
        end
      end

      def action_disable
        if @current_resource.enabled
          Chef::Log.debug("#{@new_resource}: attempting to disable")
          status = disable_service(@new_resource.service_name)
          if status
            Chef::Log.info("#{@new_resource}: disabled succesfully")
          end
        else
          Chef::Log.debug("#{@new_resource}: not disabling, already disabled")
        end
      end

      def action_start
        unless @current_resource.running
          Chef::Log.debug("#{@new_resource}: attempting to start")
          status = start_service(@new_resource.service_name)
          if status
            Chef::Log.info("Started service #{@new_resource} succesfully")
          end
        else
          Chef::Log.debug("#{@new_resource}: not starting, already running")
        end 
      end

      def action_stop
        if @current_resource.running
          Chef::Log.debug("#{@new_resource}: attempting to stop")
          status = stop_service(@new_resource.service_name)
          if status
            Chef::Log.info("#{@new_resource}: stopped succesfully")
          end
        else
          Chef::Log.debug("#{@new_resource}: not stopping, already stopped")
        end 
      end
      
      def action_restart
        if @current_resource.running
          Chef::Log.debug("#{@new_resource}: attempting to restart")
          status = restart_service(@new_resource.service_name)
          if status
            Chef::Log.info("#{@new_resource}: restarted succesfully")
          end
        end
      end

      def action_reload
        unless @new_resource.supports[:reload] or @new_resource.reload_command
          raise Chef::Exception::UnsupportedAction, "#{self.to_s} does not support :reload"
        else
          if @current_resource.running
            Chef::Log.debug("#{@new_resource}: attempting to reload")
            status = reload_service(@new_resource.service_name)
            if status
              Chef::Log.info("#{@new_resource}: reloaded succesfully")
            end
{'fraction_non_alphanumeric': 0.10205856770078284, 'fraction_numerical': 0.0028993911278631487, 'mean_word_length': 2.5127291242362526, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6180462', 'n_tokens_mistral': 1866, 'n_tokens_neox': 1818, 'n_words': 518}