Sha256: 15ca316e13e792c1ed9c7928944f316d634c00a5b9910491355b3778661ab6a8

Contents?: true

Size: 1.28 KB

Versions: 20

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true
# Manage a collection of confines, returning a boolean or
# helpful information.
require_relative '../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

20 entries across 20 versions & 1 rubygems

Version Path
puppet-8.3.0 lib/puppet/confine_collection.rb
puppet-8.3.0-x86-mingw32 lib/puppet/confine_collection.rb
puppet-8.3.0-x64-mingw32 lib/puppet/confine_collection.rb
puppet-8.3.0-universal-darwin lib/puppet/confine_collection.rb
puppet-8.3.1 lib/puppet/confine_collection.rb
puppet-8.3.1-x86-mingw32 lib/puppet/confine_collection.rb
puppet-8.3.1-x64-mingw32 lib/puppet/confine_collection.rb
puppet-8.3.1-universal-darwin lib/puppet/confine_collection.rb
puppet-8.2.0 lib/puppet/confine_collection.rb
puppet-8.2.0-x86-mingw32 lib/puppet/confine_collection.rb
puppet-8.2.0-x64-mingw32 lib/puppet/confine_collection.rb
puppet-8.2.0-universal-darwin lib/puppet/confine_collection.rb
puppet-8.1.0 lib/puppet/confine_collection.rb
puppet-8.1.0-x86-mingw32 lib/puppet/confine_collection.rb
puppet-8.1.0-x64-mingw32 lib/puppet/confine_collection.rb
puppet-8.1.0-universal-darwin lib/puppet/confine_collection.rb
puppet-8.0.1 lib/puppet/confine_collection.rb
puppet-8.0.1-x86-mingw32 lib/puppet/confine_collection.rb
puppet-8.0.1-x64-mingw32 lib/puppet/confine_collection.rb
puppet-8.0.1-universal-darwin lib/puppet/confine_collection.rb