<commit_before>require 'base64'
require 'tempfile'

Puppet::Type.type(:openldap_database).provide(:olc) do

  # TODO: Use ruby bindings (can't find one that support IPC)

  defaultfor :osfamily => :debian, :osfamily => :redhat

  commands :slapcat => 'slapcat', :ldapmodify => 'ldapmodify'

  mk_resource_methods

  def self.instances
    databases = slapcat(
      '-b',
      'cn=config',
      '-H',
      'ldap:///???(&(objectClass=olcDatabaseConfig)(|(objectClass=olcBdbConfig)(objectClass=olcHdbConfig)))'
    )
    databases.split("\n\n").collect do |paragraph|
      suffix = nil
      index = nil
      backend = nil
      directory = nil
      rootdn = nil
      rootpw = nil
      suffix = nil
      paragraph.split("\n").collect do |line|
        case line
        when /^olcDatabase: /
          index, backend = line.match(/^olcDatabase: \{(\d+)\}(bdb|hdb)$/).captures
        when /^olcDbDirectory: /
          directory = line.split(' ')[1]
        when /^olcRootDN: /
          rootdn = line.split(' ')[1]
        when /^olcRootPW:: /
          rootpw = Base64.decode64(line.split(' ')[1])
        when /^olcSuffix: /
          suffix = line.split(' ')[1]
        end
      end
      new(
        :ensure    => :present,
        :name      => suffix,<commit_msg>Update olc.rb<commit_after>require 'base64'
require 'tempfile'

Puppet::Type.type(:openldap_database).provide(:olc) do

  # TODO: Use ruby bindings (can't find one that support IPC)

  defaultfor :osfamily => :debian, :osfamily => :redhat

  commands :slapcat => 'slapcat', :ldapmodify => 'ldapmodify'

  mk_resource_methods

  def self.instances
    databases = slapcat(
      '-b',
      'cn=config',
      '-H',
      'ldap:///???(&(objectClass=olcDatabaseConfig)(|(objectClass=olcBdbConfig)(objectClass=olcHdbConfig)))'
    )
    databases.split("\n\n").collect do |paragraph|
      suffix = nil
      index = nil
      backend = nil
      directory = nil
      rootdn = nil
      rootpw = nil
      paragraph.split("\n").collect do |line|
        case line
        when /^olcDatabase: /
          index, backend = line.match(/^olcDatabase: \{(\d+)\}(bdb|hdb)$/).captures
        when /^olcDbDirectory: /
          directory = line.split(' ')[1]
        when /^olcRootDN: /
          rootdn = line.split(' ')[1]
        when /^olcRootPW:: /
          rootpw = Base64.decode64(line.split(' ')[1])
        when /^olcSuffix: /
          suffix = line.split(' ')[1]
        end
      end
      new(
        :ensure    => :present,
        :name      => suffix,
{'fraction_non_alphanumeric': 0.1543914927136668, 'fraction_numerical': 0.007877116975187082, 'mean_word_length': 2.2480818414322252, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '1779244', 'n_tokens_mistral': 876, 'n_tokens_neox': 841, 'n_words': 178}