<commit_before>require 'pathname'
Puppet::Type.type(:x509_cert).provide(:openssl) do
  desc 'Manages certificates with OpenSSL'

  commands :openssl => 'openssl'

  def self.dirname (resource)
    resource[:path].dirname
  end

  def exists?
    # TODO: add a "force" parameter to force recreation
    # if existing certificate does not match parameters
    Pathname.exists? "#{resource[:path]}.crt"
  end

  def create
    openssl(
      'req', '-config', "#{resource[:path]}.cnf", '-new', '-x509',
      '-nodes', '-days', resource[:days],
      '-out', "#{resource[:path]}.crt",
      '-keyout', "#{resource[:path]}.key"
    )
  end

  def destroy
    Pathname.delete "#{resource[:path]}.crt"
    Pathname.delete "#{resource[:path]}.key"
  end
end<commit_msg>Use a default for template in the provider<commit_after>require 'pathname'
Puppet::Type.type(:x509_cert).provide(:openssl) do
  desc 'Manages certificates with OpenSSL'

  commands :openssl => 'openssl'

  def self.dirname(resource)
    resource[:path].dirname
  end

  def self.template(resource)
    resource[:template] || "#{resource[:path]}.cnf"
  end

  def exists?
    # TODO: add a "force" parameter to force recreation
    # if existing certificate does not match parameters
    Pathname.exists? "#{resource[:path]}.crt"
  end

  def create
    openssl(
      'req', '-config', "#{self.class.template(resource)}", '-new', '-x509',
      '-nodes', '-days', resource[:days],
      '-out', "#{resource[:path]}.crt",
      '-keyout', "#{resource[:path]}.key"
    )
  end

  def destroy
    Pathname.delete "#{resource[:path]}.crt"
    Pathname.delete "#{resource[:path]}.key"
  end
end
{'fraction_non_alphanumeric': 0.17019987886129617, 'fraction_numerical': 0.0072683222289521504, 'mean_word_length': 3.6535211267605634, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1200993', 'n_tokens_mistral': 553, 'n_tokens_neox': 519, 'n_words': 132}