Class: Puppet::Parameter::Path
- Inherits:
-
Puppet::Parameter
- Object
- Puppet::Parameter
- Puppet::Parameter::Path
- Defined in:
- lib/puppet/parameter/path.rb
Instance Attribute Summary
Attributes inherited from Puppet::Parameter
Attributes included from Util::Docs
Attributes included from Util::Cacher::Expirer
Class Method Summary collapse
Instance Method Summary collapse
-
#unsafe_munge(paths) ⇒ Object
Likewise, this might be overridden, but by default…
-
#unsafe_validate(paths) ⇒ Object
This will be overridden if someone uses the validate option, which is why it just delegates to the other, useful, method.
- #validate_path(paths) ⇒ Object
Methods inherited from Puppet::Parameter
aliasvalue, defaultto, desc, #devfail, doc, #expirer, #fail, #initialize, initvars, isnamevar, isnamevar?, isrequired, #log, #metaparam?, #munge, munge, #name, newvalues, nodefault, #noop, #pathbuilder, #provider, proxymethods, #remove, required?, #tags, #to_s, unmunge, #unmunge, validate, #validate, #value, #value=
Methods included from Util::Docs
#desc, #dochook, #doctable, #nodoc?, #pad, scrub
Methods included from Util
activerecord_version, benchmark, chuser, classproxy, #execfail, #execpipe, execute, logmethods, memory, proxy, recmkdir, secure_open, symbolize, symbolizehash, symbolizehash!, synchronize_on, thinmark, #threadlock, which, withumask
Methods included from Util::POSIX
#get_posix_field, #gid, #idfield, #methodbyid, #methodbyname, #search_posix_field, #uid
Methods included from Util::Cacher
Methods included from Util::Cacher::Expirer
#dependent_data_expired?, #expire
Methods included from Util::MethodHelper
#requiredopts, #set_options, #symbolize_options
Methods included from Util::Logging
Methods included from Util::LogPaths
Methods included from Util::Errors
#adderrorcontext, #devfail, #error_context, #exceptwrap, #fail
Constructor Details
This class inherits a constructor from Puppet::Parameter
Class Method Details
.accept_arrays(bool = true) ⇒ Object
4 5 6 |
# File 'lib/puppet/parameter/path.rb', line 4 def self.accept_arrays(bool = true) @accept_arrays = !!bool end |
.arrays? ⇒ Boolean
7 8 9 |
# File 'lib/puppet/parameter/path.rb', line 7 def self.arrays? @accept_arrays end |
Instance Method Details
#unsafe_munge(paths) ⇒ Object
Likewise, this might be overridden, but by default…
36 37 38 39 40 41 |
# File 'lib/puppet/parameter/path.rb', line 36 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 |
#unsafe_validate(paths) ⇒ Object
This will be overridden if someone uses the validate option, which is why it just delegates to the other, useful, method.
31 32 33 |
# File 'lib/puppet/parameter/path.rb', line 31 def unsafe_validate(paths) validate_path(paths) end |
#validate_path(paths) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/puppet/parameter/path.rb', line 11 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 # We *always* support Unix path separators, as Win32 does now too. absolute = "[/#{::Regexp.quote(::File::SEPARATOR)}]" win32 = Puppet.features.microsoft_windows? Array(paths).each do |path| next if path =~ %r{^#{absolute}} next if win32 and path =~ %r{^(?:[a-zA-Z]:)?#{absolute}} fail("#{name} must be a fully qualified path") end paths end |