Class: Puppet::Confine
- Includes:
- Util
- Defined in:
- lib/puppet/confine/boolean.rb,
lib/puppet/confine.rb
Overview
Common module for the Boolean confines. It currently contains just enough code to implement PUP-9336.
Defined Under Namespace
Modules: Boolean Classes: Any, Exists, False, Feature, True, Variable
Constant Summary
Constants included from Util
Util::ALNUM, Util::ALPHA, Util::AbsolutePathPosix, Util::AbsolutePathWindows, Util::DEFAULT_POSIX_MODE, Util::DEFAULT_WINDOWS_MODE, Util::ESCAPED, Util::HEX, Util::HttpProxy, Util::PUPPET_STACK_INSERTION_FRAME, Util::RESERVED, Util::RFC_3986_URI_REGEX, Util::UNRESERVED, Util::UNSAFE
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, create_erb, default_env, deterministic_rand, deterministic_rand_int, exit_on_fail, format_backtrace_array, format_puppetstack_frame, get_env, get_environment, logmethods, merge_environment, path_to_uri, pretty_backtrace, replace_file, resolve_stackframe, rfc2396_escape, safe_posix_fork, set_env, skip_external_facts, symbolizehash, thinmark, uri_encode, uri_query_encode, uri_to_path, uri_unescape, which, withenv, withumask
Methods included from Util::POSIX
#get_posix_field, #gid, groups_of, #idfield, #methodbyid, #methodbyname, #search_posix_field, #uid
Methods included from Util::SymbolicFileMode
#display_mode, #normalize_symbolic_mode, #symbolic_mode_to_int, #valid_symbolic_mode?
Constructor Details
#initialize(values) ⇒ Confine
Returns a new instance of Confine.
54 55 56 57 |
# File 'lib/puppet/confine.rb', line 54 def initialize(values) values = [values] unless values.is_a?(Array) @values = values end |
Class Attribute Details
.name ⇒ Object
Returns the value of attribute name.
13 14 15 |
# File 'lib/puppet/confine.rb', line 13 def name @name end |
Instance Attribute Details
#for_binary ⇒ Object
Mark that this confine is used for testing binary existence.
45 46 47 |
# File 'lib/puppet/confine.rb', line 45 def for_binary @for_binary end |
#label ⇒ Object
Used for logging.
52 53 54 |
# File 'lib/puppet/confine.rb', line 52 def label @label end |
#values ⇒ Object (readonly)
Returns the value of attribute values.
42 43 44 |
# File 'lib/puppet/confine.rb', line 42 def values @values end |
Class Method Details
.inherited(klass) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/puppet/confine.rb', line 16 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
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/puppet/confine.rb', line 25 def self.test(name) unless @tests.include?(name) begin require "puppet/confine/#{name}" rescue LoadError => detail unless detail.to_s =~ /No such file|cannot load such file/i Puppet.warning("Could not load confine test '#{name}': #{detail}") end # Could not find file unless Puppet[:always_retry_plugins] @tests[name] = nil end end end @tests[name] end |
Instance Method Details
#for_binary? ⇒ Boolean
47 48 49 |
# File 'lib/puppet/confine.rb', line 47 def for_binary? for_binary end |
#message(value) ⇒ Object
Provide a hook for the message when there’s a failure.
60 61 62 |
# File 'lib/puppet/confine.rb', line 60 def (value) "" end |
#reset ⇒ Object
Provide a hook for subclasses.
84 85 |
# File 'lib/puppet/confine.rb', line 84 def reset end |
#result ⇒ Object
Collect the results of all of them.
65 66 67 |
# File 'lib/puppet/confine.rb', line 65 def result values.collect { |value| pass?(value) } end |