<commit_before>require 'puppet/provider/package'

Puppet::Type.type(:package).provide(:chocolatey, :parent => Puppet::Provider::Package) do
  desc "Package management using Chocolatey on Windows"
  confine     :operatingsystem => :windows
  has_feature :installable
  has_feature :uninstallable
  has_feature :upgradeable
  has_feature :versionable
  has_feature :install_options
  has_feature :uninstall_options
  #has_feature :holdable

  def initialize(value={})
    super(value)
    @compiled_choco = nil
  end

  def self.chocolatey_command
    if Puppet::Util::Platform.windows?
      # must determine how to get to params in ruby
      #default_location = $chocolatey::params::install_location || ENV['ALLUSERSPROFILE'] + '\chocolatey'
      chocopath = ENV['ChocolateyInstall'] ||
          ('C:\Chocolatey' if File.directory?('C:\Chocolatey')) ||
          ('C:\ProgramData\chocolatey' if File.directory?('C:\ProgramData\chocolatey')) ||
          ENV['ALLUSERSPROFILE'] + '\chocolatey'

      chocopath += '\bin\choco.exe'
    else
      chocopath = 'choco.exe'
    end

    chocopath
  end

  def self.compiled_choco=(value)
    @compiled_choco = value
  end

  # this ultimately determines if we are on the C# version of choco
  # so commands can be adjusted accordingly
  def self.choco_exe?
    # call `choco -v` one time here and cache the result
    # - new choco will output a single value e.g. `0.9.9`
    # - old choco is going to return the default output e.g. `Please run chocolatey /?`
    if @compiled_choco.nil?
      execpipe(choco_ver_cmd) do |process|
        process.each_line do |line|
          line.chomp!
          if line.empty?; next; end
          if line.match(/Please run chocolatey.*/)
            @compiled_choco = false
          else
            @compiled_choco = true
          end<commit_msg>(maint) combine variable and path as one string<commit_after>require 'puppet/provider/package'

Puppet::Type.type(:package).provide(:chocolatey, :parent => Puppet::Provider::Package) do
  desc "Package management using Chocolatey on Windows"
  confine     :operatingsystem => :windows
  has_feature :installable
  has_feature :uninstallable
  has_feature :upgradeable
  has_feature :versionable
  has_feature :install_options
  has_feature :uninstall_options
  #has_feature :holdable

  def initialize(value={})
    super(value)
    @compiled_choco = nil
  end

  def self.chocolatey_command
    if Puppet::Util::Platform.windows?
      # must determine how to get to params in ruby
      #default_location = $chocolatey::params::install_location || ENV['ALLUSERSPROFILE'] + '\chocolatey'
      chocopath = ENV['ChocolateyInstall'] ||
          ('C:\Chocolatey' if File.directory?('C:\Chocolatey')) ||
          ('C:\ProgramData\chocolatey' if File.directory?('C:\ProgramData\chocolatey')) ||
          "#{ENV['ALLUSERSPROFILE']}\chocolatey"

      chocopath += '\bin\choco.exe'
    else
      chocopath = 'choco.exe'
    end

    chocopath
  end

  def self.compiled_choco=(value)
    @compiled_choco = value
  end

  # this ultimately determines if we are on the C# version of choco
  # so commands can be adjusted accordingly
  def self.choco_exe?
    # call `choco -v` one time here and cache the result
    # - new choco will output a single value e.g. `0.9.9`
    # - old choco is going to return the default output e.g. `Please run chocolatey /?`
    if @compiled_choco.nil?
      execpipe(choco_ver_cmd) do |process|
        process.each_line do |line|
          line.chomp!
          if line.empty?; next; end
          if line.match(/Please run chocolatey.*/)
            @compiled_choco = false
          else
            @compiled_choco = true
          end
{'fraction_non_alphanumeric': 0.10421166306695465, 'fraction_numerical': 0.0016198704103671706, 'mean_word_length': 3.053610503282276, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '5438591', 'n_tokens_mistral': 1186, 'n_tokens_neox': 1146, 'n_words': 307}