Sha256: 3b2df2740f7b04a31d9b162e987e19c00d87921b0988e067970c33f8ef27db46

Contents?: true

Size: 912 Bytes

Versions: 37

Compression:

Stored size: 912 Bytes

Contents

require 'puppet/parameter'

class Puppet::Parameter::Path < Puppet::Parameter
  def self.accept_arrays(bool = true)
    @accept_arrays = !!bool
  end
  def self.arrays?
    @accept_arrays
  end

  def validate_path(paths)
    if paths.is_a?(Array) and ! self.class.arrays? then
      fail "#{name} only accepts a single path, not an array of paths"
    end

    fail("#{name} must be a fully qualified path") unless Array(paths).all? {|path| absolute_path?(path)}

    paths
  end

  # This will be overridden if someone uses the validate option, which is why
  # it just delegates to the other, useful, method.
  def unsafe_validate(paths)
    validate_path(paths)
  end

  # Likewise, this might be overridden, but by default...
  def unsafe_munge(paths)
    if paths.is_a?(Array) and ! self.class.arrays? then
      fail "#{name} only accepts a single path, not an array of paths"
    end
    paths
  end
end

Version data entries

37 entries across 37 versions & 3 rubygems

Version Path
puppet-parse-0.1.4 lib/vendor/puppet/parameter/path.rb
puppet-parse-0.1.3 lib/vendor/puppet/parameter/path.rb
puppet-parse-0.1.2 lib/vendor/puppet/parameter/path.rb
puppet-parse-0.1.1 lib/vendor/puppet/parameter/path.rb
puppet-2.7.26 lib/puppet/parameter/path.rb
puppet-2.7.25 lib/puppet/parameter/path.rb
puppet-2.7.24 lib/puppet/parameter/path.rb
puppet-2.7.23 lib/puppet/parameter/path.rb
puppet-2.7.22 lib/puppet/parameter/path.rb
puppet-parse-0.1.0 lib/vendor/puppet/parameter/path.rb
puppet-parse-0.0.6 lib/vendor/puppet/parameter/path.rb
puppet-2.7.21 lib/puppet/parameter/path.rb
puppet-parse-0.0.5 lib/vendor/puppet/parameter/path.rb
puppet-parse-0.0.4 lib/vendor/puppet/parameter/path.rb
puppet-3.0.2 lib/puppet/parameter/path.rb
puppet-3.0.2.rc3 lib/puppet/parameter/path.rb
puppet-3.0.2.rc2 lib/puppet/parameter/path.rb
puppet-3.0.2.rc1 lib/puppet/parameter/path.rb
puppet-parse-0.0.2 lib/vendor/puppet/parameter/path.rb
puppet-2.7.20 lib/puppet/parameter/path.rb