summaryrefslogtreecommitdiffstats
path: root/lib/puppet/provider/confine/exists.rb
blob: 09f94dfd90d8b7cb19337a01be226b473b2164a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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)
    value && (for_binary? ? which(value) : 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