<commit_before>#
# Cookbook Name: monit
# Provider:: check
#

require 'chef/provider/template'
require 'chef/resource/template'

class Chef
  class Provider
    class MonitCheck < Chef::Provider
      def initialize(*args)
        super
      end

      def load_current_resource
        @current_resource ||= Chef::Resource::MonitCheck.new(new_resource.name)
      end

      def action_create
        new_resource.updated_by_last_action(edit_check(:create))
      end

      def action_remove
        new_resource.updated_by_last_action(edit_check(:delete))
      end

      private

      def edit_check(exec_action)
        t = Chef::Resource::Template.new(tpl_name, run_context)
        t.cookbook new_resource.cookbook
        t.path tpl_path
        t.source 'monit.check.erb'
        t.variables monit_check_config
        t.notifies :reload, 'service[monit]', :delayed
        t.run_action exec_action
        t.updated_by_last_action?
      end

      def tpl_name
        "monit_check_#{new_resource.name}"
      end

      def tpl_path
        ::File.join(node['monit']['conf_dir'], "#{new_resource.name}.conf")
      end

      # rubocop: disable AbcSize
      def monit_check_config
        {
          :name => new_resource.name, :check_type => new_resource.check_type,
          :check_id => new_resource.check_id, :id_type => new_resource.id_type,
          :group => new_resource.group, :start_as => new_resource.start_as,
          :start_as_group => new_resource.start_as_group,
          :start => new_resource.start, :stop => new_resource.stop,
          :stop_as => new_resource.stop_as,
          :stop_as => new_resource.stop_as_group,<commit_msg>Fixed incorrect variable map in resource provider.<commit_after>#
# Cookbook Name: monit
# Provider:: check
#

require 'chef/provider/template'
require 'chef/resource/template'

class Chef
  class Provider
    class MonitCheck < Chef::Provider
      def initialize(*args)
        super
      end

      def load_current_resource
        @current_resource ||= Chef::Resource::MonitCheck.new(new_resource.name)
      end

      def action_create
        new_resource.updated_by_last_action(edit_check(:create))
      end

      def action_remove
        new_resource.updated_by_last_action(edit_check(:delete))
      end

      private

      def edit_check(exec_action)
        t = Chef::Resource::Template.new(tpl_name, run_context)
        t.cookbook new_resource.cookbook
        t.path tpl_path
        t.source 'monit.check.erb'
        t.variables monit_check_config
        t.notifies :reload, 'service[monit]', :delayed
        t.run_action exec_action
        t.updated_by_last_action?
      end

      def tpl_name
        "monit_check_#{new_resource.name}"
      end

      def tpl_path
        ::File.join(node['monit']['conf_dir'], "#{new_resource.name}.conf")
      end

      # rubocop: disable AbcSize
      def monit_check_config
        {
          :name => new_resource.name, :check_type => new_resource.check_type,
          :check_id => new_resource.check_id, :id_type => new_resource.id_type,
          :group => new_resource.group, :start_as => new_resource.start_as,
          :start_as_group => new_resource.start_as_group,
          :start => new_resource.start, :stop => new_resource.stop,
          :stop_as => new_resource.stop_as,
          :stop_as_group => new_resource.stop_as_group,
{'fraction_non_alphanumeric': 0.09772660171242988, 'fraction_numerical': 0.0, 'mean_word_length': 2.7149122807017543, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, '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': '908030', 'n_tokens_mistral': 1085, 'n_tokens_neox': 1060, 'n_words': 189}