Class: Puppet::Confine
Defined Under Namespace
Classes: Any, Exists, False, Feature, True, Variable
Constant Summary
Constants included from Util
Util::AbsolutePathPosix, Util::AbsolutePathWindows, Util::DEFAULT_POSIX_MODE, Util::DEFAULT_WINDOWS_MODE
Constants included from Util::POSIX
Util::POSIX::LOCALE_ENV_VARS, Util::POSIX::USER_ENV_VARS
Constants included from Util::SymbolicFileMode
Util::SymbolicFileMode::SetGIDBit, Util::SymbolicFileMode::SetUIDBit, Util::SymbolicFileMode::StickyBit, Util::SymbolicFileMode::SymbolicMode, Util::SymbolicFileMode::SymbolicSpecialToBit
Class Attribute Summary collapse
-
.name ⇒ Object
Returns the value of attribute name.
Instance Attribute Summary collapse
-
#for_binary ⇒ Object
Mark that this confine is used for testing binary existence.
-
#label ⇒ Object
Used for logging.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Class Method Summary collapse
Instance Method Summary collapse
- #for_binary? ⇒ Boolean
-
#initialize(values) ⇒ Confine
constructor
A new instance of Confine.
-
#message(value) ⇒ Object
Provide a hook for the message when there’s a failure.
-
#reset ⇒ Object
Provide a hook for subclasses.
-
#result ⇒ Object
Collect the results of all of them.
-
#valid? ⇒ Boolean
Test whether our confine matches.
Methods included from Util
absolute_path?, benchmark, chuser, clear_environment, default_env, deterministic_rand, deterministic_rand_int, exit_on_fail, get_env, get_environment, logmethods, merge_environment, path_to_uri, pretty_backtrace, replace_file, safe_posix_fork, set_env, symbolizehash, thinmark, uri_encode, uri_query_encode, uri_to_path, which, withenv, withumask
Methods included from Util::POSIX
#get_posix_field, #gid, #idfield, #methodbyid, #methodbyname, #search_posix_field, #uid
Methods included from Util::SymbolicFileMode
#normalize_symbolic_mode, #symbolic_mode_to_int, #valid_symbolic_mode?
Constructor Details
#initialize(values) ⇒ Confine
Returns a new instance of Confine.
48 49 50 51 |
# File 'lib/puppet/confine.rb', line 48 def initialize(values) values = [values] unless values.is_a?(Array) @values = values end |
Class Attribute Details
.name ⇒ Object
Returns the value of attribute name.
11 12 13 |
# File 'lib/puppet/confine.rb', line 11 def name @name end |
Instance Attribute Details
#for_binary ⇒ Object
Mark that this confine is used for testing binary existence.
40 41 42 |
# File 'lib/puppet/confine.rb', line 40 def for_binary @for_binary end |
#label ⇒ Object
Used for logging.
46 47 48 |
# File 'lib/puppet/confine.rb', line 46 def label @label end |
#values ⇒ Object (readonly)
Returns the value of attribute values.
37 38 39 |
# File 'lib/puppet/confine.rb', line 37 def values @values end |
Class Method Details
.inherited(klass) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/puppet/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 |
.test(name) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/puppet/confine.rb', line 23 def self.test(name) unless @tests[name] begin require "puppet/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 |
Instance Method Details
#for_binary? ⇒ Boolean
41 42 43 |
# File 'lib/puppet/confine.rb', line 41 def for_binary? for_binary end |
#message(value) ⇒ Object
Provide a hook for the message when there’s a failure.
54 55 56 |
# File 'lib/puppet/confine.rb', line 54 def (value) "" end |
#reset ⇒ Object
Provide a hook for subclasses.
78 79 |
# File 'lib/puppet/confine.rb', line 78 def reset end |
#result ⇒ Object
Collect the results of all of them.
59 60 61 |
# File 'lib/puppet/confine.rb', line 59 def result values.collect { |value| pass?(value) } end |