<commit_before>require 'puppet/provider/package'
Puppet::Type.type(:package).provide :pkgng, :parent => Puppet::Provider::Package do
  desc "A PKGng provider for FreeBSD."

  commands :pkg => "/usr/local/sbin/pkg"

  confine :operatingsystem => :freebsd

  def self.instances
    inst = Array.new
    package = Hash.new
    cmd = ['info', '-a']
    pkg_list = pkg(*cmd).lines

    pkg_list.each do |pkgs|
      pkgs = pkgs.split
      pkg_info = pkgs[0].split('-')
      pkg = {
        :ensure   => pkg_info.pop,
        :name     => pkg_info.join('-'),
        :provider => self.name
      }
      inst << new(pkg)
    end
    inst
  end

  def install
    should = @resource.should(:ensure)
    cmd = ['install', '-qy', @resource[:name]]
    pkg(*cmd)
  end

  def uninstall
    cmd = ['remove', '-qy', @resource[:name]]
    pkg(*cmd)
  end

  def query
    hash = Hash.new
    #cmd = ["query", "'%v'", @resource[:name]]
    cmd = ["info", "-q", @resource[:name]]
    begin
      hash[:ensure] = pkg(*cmd)
      hash
    rescue
      hash[:ensure] = :purged
      hash
    end
  end

end
<commit_msg>setting as default provider for pkgng enabled servers<commit_after>require 'puppet/provider/package'
Puppet::Type.type(:package).provide :pkgng, :parent => Puppet::Provider::Package do
  desc "A PKGng provider for FreeBSD."

  commands :pkg => "/usr/local/sbin/pkg"

  confine :operatingsystem => :freebsd
  defaultfor :operatingsystem => :freebsd if $pkgng_enabled

  def self.instances
    inst = Array.new
    package = Hash.new
    cmd = ['info', '-a']
    pkg_list = pkg(*cmd).lines

    pkg_list.each do |pkgs|
      pkgs = pkgs.split
      pkg_info = pkgs[0].split('-')
      pkg = {
        :ensure   => pkg_info.pop,
        :name     => pkg_info.join('-'),
        :provider => self.name
      }
      inst << new(pkg)
    end
    inst
  end

  def install
    should = @resource.should(:ensure)
    cmd = ['install', '-qy', @resource[:name]]
    pkg(*cmd)
  end

  def uninstall
    cmd = ['remove', '-qy', @resource[:name]]
    pkg(*cmd)
  end

  def query
    hash = Hash.new
    #cmd = ["query", "'%v'", @resource[:name]]
    cmd = ["info", "-q", @resource[:name]]
    begin
      hash[:ensure] = pkg(*cmd)
      hash
    rescue
      hash[:ensure] = :purged
      hash
    end
  end

end

{'fraction_non_alphanumeric': 0.1608846487424111, 'fraction_numerical': 0.0008673026886383347, 'mean_word_length': 2.443283582089552, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 16, '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': '6327697', 'n_tokens_mistral': 836, 'n_tokens_neox': 791, 'n_words': 192}