<commit_before>require 'puppet'
require 'yaml'

begin
  require 'hipchat'
rescue LoadError => e
  Puppet.info "You need the `hipchat` gem to use the Hipchat report"
end

Puppet::Reports.register_report(:hipchat) do

  configfile = File.join([File.dirname(Puppet.settings[:config]), "hipchat.yaml"])
  raise(Puppet::ParseError, "Hipchat report config file #{configfile} not readable") unless File.exist?(configfile)
  config = YAML.load_file(configfile)
  HIPCHAT_API = config[:hipchat_api]
  HIPCHAT_ROOM = config[:hipchat_room]
  HIPCHAT_NOTIFY = config[:hipchat_notify]
  desc <<-DESC
  Send notification of failed reports to a Hipchat room.
  DESC

  def process
    if self.status == 'failed'
      Puppet.debug "Sending status for #{self.host} to Hipchat channel #{HIPCHAT_ROOM}"
        msg = "Puppet run for #{self.host} #{self.status} at #{Time.now.asctime}"
        client = HipChat::Client.new(HIPCHAT_API)
        client[HIPCHAT_ROOM].send('Puppet', msg, HIPCHAT_NOTIFY)<commit_msg>Updated Hipchat send command for API change<commit_after>require 'puppet'
require 'yaml'

begin
  require 'hipchat'
rescue LoadError => e
  Puppet.info "You need the `hipchat` gem to use the Hipchat report"
end

Puppet::Reports.register_report(:hipchat) do

  configfile = File.join([File.dirname(Puppet.settings[:config]), "hipchat.yaml"])
  raise(Puppet::ParseError, "Hipchat report config file #{configfile} not readable") unless File.exist?(configfile)
  config = YAML.load_file(configfile)
  HIPCHAT_API = config[:hipchat_api]
  HIPCHAT_ROOM = config[:hipchat_room]
  HIPCHAT_NOTIFY = config[:hipchat_notify]
  desc <<-DESC
  Send notification of failed reports to a Hipchat room.
  DESC

  def process
    if self.status == 'failed'
      Puppet.debug "Sending status for #{self.host} to Hipchat channel #{HIPCHAT_ROOM}"
        msg = "Puppet run for #{self.host} #{self.status} at #{Time.now.asctime}"
        client = HipChat::Client.new(HIPCHAT_API)
        client[HIPCHAT_ROOM].send('Puppet', msg, :notify => HIPCHAT_NOTIFY)
{'fraction_non_alphanumeric': 0.11889491859891466, 'fraction_numerical': 0.0, 'mean_word_length': 4.7126760563380286, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 6, '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': '3840915', 'n_tokens_mistral': 718, 'n_tokens_neox': 699, 'n_words': 174}