# class Puppet::Provider::Confine

### Attributes

name[RW]
for_binary[RW]

Mark that this confine is used for testing binary existence.

label[RW]

Used for logging.

values[R]

### Public Class Methods

inherited(klass) click to toggle source

    # File lib/puppet/provider/confine.rb, line 14
    def self.inherited(klass)
      name = klass.to_s.split("::").pop.downcase.to_sym
      raise "Test #{name} is already defined" if @tests.include?(name)

      klass.name = name

      @tests[name] = klass
    end

new(values) click to toggle source

    # File lib/puppet/provider/confine.rb, line 48
    def initialize(values)
      values = [values] unless values.is_a?(Array)
      @values = values
    end

test(name) click to toggle source

    # File lib/puppet/provider/confine.rb, line 23
    def self.test(name)
      unless @tests[name]
        begin
          require "puppet/provider/confine/#{name}"
        rescue LoadError => detail
          unless detail.to_s =~ /No such file|cannot load such file/i
            warn "Could not load confine test '#{name}': #{detail}"
          end
          # Could not find file
        end
      end
      @tests[name]
    end

### Public Instance Methods

for_binary?() click to toggle source

    # File lib/puppet/provider/confine.rb, line 41
    def for_binary?
      for_binary
    end

message(value) click to toggle source

Provide a hook for the message when there’s a failure.

    # File lib/puppet/provider/confine.rb, line 54
    def message(value)
      ""
    end

reset() click to toggle source

Provide a hook for subclasses.

    # File lib/puppet/provider/confine.rb, line 78
    def reset
    end

result() click to toggle source

Collect the results of all of them.

    # File lib/puppet/provider/confine.rb, line 59
    def result
      values.collect { |value| pass?(value) }
    end

valid?() click to toggle source

Test whether our confine matches.

    # File lib/puppet/provider/confine.rb, line 64
    def valid?
      values.each do |value|
        unless pass?(value)
          Puppet.debug(label + ": " + message(value))
          return false
        end
      end

      return true
    ensure
      reset
    end