Sha256: 5b9189efdae25dc8a7b1deb8ce2a4b22526102a142b4743779a9da4e46e67a30

Contents?: true

Size: 1.22 KB

Versions: 485

Compression:

Stored size: 1.22 KB

Contents

# Manage a collection of confines, returning a boolean or
# helpful information.
require 'puppet/confine'

class Puppet::ConfineCollection
  def confine(hash)
    if hash.include?(:for_binary)
      for_binary = true
      hash.delete(:for_binary)
    else
      for_binary = false
    end
    hash.each do |test, values|
      if klass = Puppet::Confine.test(test)
        @confines << klass.new(values)
        @confines[-1].for_binary = true if for_binary
      else
        confine = Puppet::Confine.test(:variable).new(values)
        confine.name = test
        @confines << confine
      end
      @confines[-1].label = self.label
    end
  end

  attr_reader :label
  def initialize(label)
    @label = label
    @confines = []
  end

  # Return a hash of the whole confine set, used for the Provider
  # reference.
  def summary
    confines = Hash.new { |hash, key| hash[key] = [] }
    @confines.each { |confine| confines[confine.class] << confine }
    result = {}
    confines.each do |klass, list|
      value = klass.summarize(list)
      next if (value.respond_to?(:length) and value.length == 0) or (value == 0)
      result[klass.name] = value

    end
    result
  end

  def valid?
    ! @confines.detect { |c| ! c.valid? }
  end
end

Version data entries

485 entries across 485 versions & 3 rubygems

Version Path
puppet-5.5.22 lib/puppet/confine_collection.rb
puppet-5.5.22-x86-mingw32 lib/puppet/confine_collection.rb
puppet-5.5.22-x64-mingw32 lib/puppet/confine_collection.rb
puppet-5.5.22-universal-darwin lib/puppet/confine_collection.rb
puppet-5.5.21 lib/puppet/confine_collection.rb
puppet-5.5.21-x86-mingw32 lib/puppet/confine_collection.rb
puppet-5.5.21-x64-mingw32 lib/puppet/confine_collection.rb
puppet-5.5.21-universal-darwin lib/puppet/confine_collection.rb
puppet-5.5.20 lib/puppet/confine_collection.rb
puppet-5.5.20-x86-mingw32 lib/puppet/confine_collection.rb
puppet-5.5.20-x64-mingw32 lib/puppet/confine_collection.rb
puppet-5.5.20-universal-darwin lib/puppet/confine_collection.rb
puppet-5.5.19 lib/puppet/confine_collection.rb
puppet-5.5.19-x86-mingw32 lib/puppet/confine_collection.rb
puppet-5.5.19-x64-mingw32 lib/puppet/confine_collection.rb
puppet-5.5.19-universal-darwin lib/puppet/confine_collection.rb
puppet-5.5.18 lib/puppet/confine_collection.rb
puppet-5.5.18-x86-mingw32 lib/puppet/confine_collection.rb
puppet-6.4.5 lib/puppet/confine_collection.rb
puppet-5.5.18-x64-mingw32 lib/puppet/confine_collection.rb