summaryrefslogtreecommitdiffstats
path: root/lib/puppet/provider/confine/exists.rb
blob: 27c404acb8a63c04fb31da458accfc6e8930e884 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
require 'puppet/provider/confine'

class Puppet::Provider::Confine::Exists < Puppet::Provider::Confine
    def self.summarize(confines)
        confines.inject([]) { |total, confine| total + confine.summary }
    end

    def pass?(value)
        if for_binary?
            return false unless value = binary(value)
        end
        value and FileTest.exist?(value)
    end

    def message(value)
        "file #{value} does not exist"
    end

    def summary
        result.zip(values).inject([]) { |array, args| val, f = args; array << f unless val; array }
    end
end