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-4.0.0 modules/aggregate/lib/puppet/functions/aggregate/count.rb
bolt-3.29.0 modules/aggregate/lib/puppet/functions/aggregate/count.rb
bolt-3.28.0 modules/aggregate/lib/puppet/functions/aggregate/count.rb
bolt-3.27.4 modules/aggregate/lib/puppet/functions/aggregate/count.rb
bolt-3.27.2 modules/aggregate/lib/puppet/functions/aggregate/count.rb
bolt-3.27.1 modules/aggregate/lib/puppet/functions/aggregate/count.rb
bolt-3.26.2 modules/aggregate/lib/puppet/functions/aggregate/count.rb
bolt-3.26.1 modules/aggregate/lib/puppet/functions/aggregate/count.rb
bolt-3.25.0 modules/aggregate/lib/puppet/functions/aggregate/count.rb
bolt-3.24.0 modules/aggregate/lib/puppet/functions/aggregate/count.rb
bolt-3.23.1 modules/aggregate/lib/puppet/functions/aggregate/count.rb
bolt-3.23.0 modules/aggregate/lib/puppet/functions/aggregate/count.rb
bolt-3.22.1 modules/aggregate/lib/puppet/functions/aggregate/count.rb
bolt-3.22.0 modules/aggregate/lib/puppet/functions/aggregate/count.rb
bolt-3.21.0 modules/aggregate/lib/puppet/functions/aggregate/count.rb
bolt-3.20.0 modules/aggregate/lib/puppet/functions/aggregate/count.rb
bolt-3.19.0 modules/aggregate/lib/puppet/functions/aggregate/count.rb
bolt-3.18.0 modules/aggregate/lib/puppet/functions/aggregate/count.rb
bolt-3.17.0 modules/aggregate/lib/puppet/functions/aggregate/count.rb
bolt-3.16.1 modules/aggregate/lib/puppet/functions/aggregate/count.rb