<commit_before># Encoding: utf-8
# Report /etc/login.defs configuration

Ohai.plugin(:Login) do
  depends 'etc'
  provides 'etc/login.defs'

  def parse_login_defs
    defs = {}
    f = File.open('/etc/login.defs')
    f.each_line do |line|
      line = strip_comments(line)
      unless line.strip.empty?
        line = line.split(' ')
        defs[line[0]] = line[1..-1].join(' ')
      end
    end
    f.close
    defs
  end

  def strip_comments(text)
    re = Regexp.union(['#'])
    if index = (text =~ re)
      return text[0, index].rstrip
    else
      return text
    end
  end

  collect_data(:linux) do
    defs = parse_login_defs
    etc['login.defs'] = defs unless defs.empty?
  end
end<commit_msg>Rebase<commit_after># Encoding: utf-8
# Report /etc/login.defs configuration

Ohai.plugin(:Login) do
  depends 'etc'
  provides 'etc/login.defs'

  def parse_login_defs
    defs = {}
    f = File.open('/etc/login.defs')
    f.each_line do |line|
      line = strip_comments(line)
      unless line.strip.empty?
        line = line.split(' ')
        defs[line[0]] = line[1..-1].join(' ')
      end
    end
    f.close
    defs
  end

  def strip_comments(text)
    re = Regexp.union(['#'])
    if index = (text =~ re)
      return text[0, index].rstrip
    else
      return text
    end
  end

  collect_data(:linux) do
    defs = parse_login_defs
    unless defs.empty?
      etc Mash.new unless etc
      etc['login.defs'] = defs unless defs.empty?
    end
  end
end
{'fraction_non_alphanumeric': 0.13022941970310392, 'fraction_numerical': 0.006747638326585695, 'mean_word_length': 2.3251121076233185, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6389593', 'n_tokens_mistral': 546, 'n_tokens_neox': 543, 'n_words': 124}