Sha256: 9acac992fd67a044441c8ef7e1d6ba9b79dba8622f53c5b330d0bd03fcaeb484

Contents?: true

Size: 594 Bytes

Versions: 96

Compression:

Stored size: 594 Bytes

Contents

# frozen_string_literal: true

# Aggregates the key/value pairs in the results of a ResultSet into a hash
# mapping the keys to a hash of each distinct value and how many targets returned
# that value for the key.
Puppet::Functions.create_function(:'aggregate::count') do
  dispatch :aggregate_count do
    param 'ResultSet', :resultset
  end

  def aggregate_count(resultset)
    resultset.each_with_object({}) do |result, agg|
      result.value.each do |key, val|
        agg[key] ||= {}
        agg[key][val.to_s] ||= 0
        agg[key][val.to_s] += 1
      end
      agg
    end
  end
end

Version data entries

96 entries across 96 versions & 1 rubygems

Version Path
bolt-3.16.0 modules/aggregate/lib/puppet/functions/aggregate/count.rb
bolt-3.15.0 modules/aggregate/lib/puppet/functions/aggregate/count.rb
bolt-3.14.1 modules/aggregate/lib/puppet/functions/aggregate/count.rb
bolt-3.13.0 modules/aggregate/lib/puppet/functions/aggregate/count.rb
bolt-3.12.0 modules/aggregate/lib/puppet/functions/aggregate/count.rb
bolt-3.11.0 modules/aggregate/lib/puppet/functions/aggregate/count.rb
bolt-3.10.0 modules/aggregate/lib/puppet/functions/aggregate/count.rb
bolt-3.9.2 modules/aggregate/lib/puppet/functions/aggregate/count.rb
bolt-3.9.1 modules/aggregate/lib/puppet/functions/aggregate/count.rb
bolt-3.9.0 modules/aggregate/lib/puppet/functions/aggregate/count.rb
bolt-3.8.1 modules/aggregate/lib/puppet/functions/aggregate/count.rb
bolt-3.8.0 modules/aggregate/lib/puppet/functions/aggregate/count.rb
bolt-3.7.1 modules/aggregate/lib/puppet/functions/aggregate/count.rb
bolt-3.7.0 modules/aggregate/lib/puppet/functions/aggregate/count.rb
bolt-3.6.1 modules/aggregate/lib/puppet/functions/aggregate/count.rb
bolt-3.6.0 modules/aggregate/lib/puppet/functions/aggregate/count.rb
bolt-3.5.0 modules/aggregate/lib/puppet/functions/aggregate/count.rb
bolt-3.4.0 modules/aggregate/lib/puppet/functions/aggregate/count.rb
bolt-3.3.0 modules/aggregate/lib/puppet/functions/aggregate/count.rb
bolt-3.1.0 modules/aggregate/lib/puppet/functions/aggregate/count.rb