Sha256: 0eec20516b6dfc1de2edb18f7c3975cae6e11cb17b4771e2a22ca098c065c251

Contents?: true

Size: 1.24 KB

Versions: 148

Compression:

Stored size: 1.24 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|
      klass = Puppet::Confine.test(test)
      if klass
        @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

148 entries across 148 versions & 1 rubygems

Version Path
puppet-6.29.0 lib/puppet/confine_collection.rb
puppet-6.29.0-x86-mingw32 lib/puppet/confine_collection.rb
puppet-6.29.0-x64-mingw32 lib/puppet/confine_collection.rb
puppet-6.29.0-universal-darwin lib/puppet/confine_collection.rb
puppet-6.28.0 lib/puppet/confine_collection.rb
puppet-6.28.0-x86-mingw32 lib/puppet/confine_collection.rb
puppet-6.28.0-x64-mingw32 lib/puppet/confine_collection.rb
puppet-6.28.0-universal-darwin lib/puppet/confine_collection.rb
puppet-6.27.0 lib/puppet/confine_collection.rb
puppet-6.27.0-x86-mingw32 lib/puppet/confine_collection.rb
puppet-6.27.0-x64-mingw32 lib/puppet/confine_collection.rb
puppet-6.27.0-universal-darwin lib/puppet/confine_collection.rb
puppet-6.26.0 lib/puppet/confine_collection.rb
puppet-6.26.0-x86-mingw32 lib/puppet/confine_collection.rb
puppet-6.26.0-x64-mingw32 lib/puppet/confine_collection.rb
puppet-6.26.0-universal-darwin lib/puppet/confine_collection.rb
puppet-6.25.1 lib/puppet/confine_collection.rb
puppet-6.25.1-x86-mingw32 lib/puppet/confine_collection.rb
puppet-6.25.1-x64-mingw32 lib/puppet/confine_collection.rb
puppet-6.25.1-universal-darwin lib/puppet/confine_collection.rb