Sha256: 07d78c10b5200a32b490f94306ca7243990166d4431535ceaf62b86abd46952a

Contents?: true

Size: 1.26 KB

Versions: 96

Compression:

Stored size: 1.26 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
      @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

96 entries across 96 versions & 4 rubygems

Version Path
puppet-parse-0.1.4 lib/vendor/puppet/provider/confine_collection.rb
puppet-parse-0.1.3 lib/vendor/puppet/provider/confine_collection.rb
puppet-parse-0.1.2 lib/vendor/puppet/provider/confine_collection.rb
puppet-parse-0.1.1 lib/vendor/puppet/provider/confine_collection.rb
puppet-2.7.26 lib/puppet/provider/confine_collection.rb
puppet-2.7.25 lib/puppet/provider/confine_collection.rb
puppet-2.7.24 lib/puppet/provider/confine_collection.rb
puppet-3.3.2 lib/puppet/provider/confine_collection.rb
puppet-3.3.1 lib/puppet/provider/confine_collection.rb
puppet-3.3.1.rc3 lib/puppet/provider/confine_collection.rb
puppet-3.3.1.rc2 lib/puppet/provider/confine_collection.rb
puppet-3.3.1.rc1 lib/puppet/provider/confine_collection.rb
puppet-3.3.0 lib/puppet/provider/confine_collection.rb
puppet-3.3.0.rc3 lib/puppet/provider/confine_collection.rb
puppet-3.3.0.rc2 lib/puppet/provider/confine_collection.rb
puppet-3.2.4 lib/puppet/provider/confine_collection.rb
puppet-2.7.23 lib/puppet/provider/confine_collection.rb
puppet-3.2.3 lib/puppet/provider/confine_collection.rb
puppet-3.2.3.rc1 lib/puppet/provider/confine_collection.rb
puppet-3.2.2 lib/puppet/provider/confine_collection.rb