<commit_before>require 'itamae'
require_relative '../recipe/sensu.rb'
require 'json'

#
# sensu_client node.name do
#   address node.address
#   subscriptions node.roles + ['all']
#   additional(cluster: node.cluster)
# end

module Itamae
  module Resource
    class SensuClient < File
      define_attribute :action, default: :create
      define_attribute :path, type: String, default_name: false
      define_attribute :hostname, type: String, default_name: true
      define_attribute :address, type: String
      define_attribute :subscription_names, type: Array, defualt: []
      define_attribute :keepalive, type: Hash, default: {}
      define_attribute :additional, type: Hash, default: {}

      def pre_action
        attribuets.path ||= Pathname.new(node.sensu.directory).join('conf.d/client.json').to_s
        attributes.content = client_json_content
        attributes.mode =  '0644'
        attributes.owner = node.sensu.user
        attributes.group = node.sensu.group

        super
      end

      private

      def client_json_content<commit_msg>fix typo...<commit_after>require 'itamae'
require_relative '../recipe/sensu.rb'
require 'json'

module Itamae
  module Resource
    class SensuClient < File
      define_attribute :action, default: :create
      define_attribute :path, type: String, default_name: false
      define_attribute :hostname, type: String, default_name: true
      define_attribute :address, type: String
      define_attribute :subscription_names, type: Array, defualt: []
      define_attribute :keepalive, type: Hash, default: {}
      define_attribute :additional, type: Hash, default: {}

      def pre_action
        attributes.path ||= Pathname.new(node.sensu.directory).join('conf.d/client.json').to_s
        attributes.content = client_json_content
        attributes.mode =  '0644'
        attributes.owner = node.sensu.user
        attributes.group = node.sensu.group

        super
      end

      private

      def client_json_content
{'fraction_non_alphanumeric': 0.09564346519779669, 'fraction_numerical': 0.00400600901352028, 'mean_word_length': 3.197478991596639, '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': '2128335', 'n_tokens_mistral': 595, 'n_tokens_neox': 577, 'n_words': 141}