Sha256: 94e7be446c5832fcf41a3eb5dc093c9a95b213b7e750d85c7cd1fb8e53078585

Contents?: true

Size: 1.34 KB

Versions: 2

Compression:

Stored size: 1.34 KB

Contents

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

class Puppet::Provider::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::Provider::Confine.test(test)
                @confines << klass.new(values)
                @confines[-1].for_binary = true if for_binary
            else
                confine = Puppet::Provider::Confine.test(:variable).new(values)
                confine.name = test
                @confines << confine
            end
        end
    end

    def initialize
        @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

2 entries across 2 versions & 1 rubygems

Version Path
puppet-0.24.5 lib/puppet/provider/confine_collection.rb
puppet-0.24.6 lib/puppet/provider/confine_collection.rb