Class: Puppet::Interface
- Extended by:
- ActionManager, OptionManager
- Includes:
- ActionManager, FullDocs, OptionManager, Util
- Defined in:
- lib/puppet/interface.rb,
lib/puppet/interface/documentation.rb
Defined Under Namespace
Modules: ActionManager, DocGen, FaceCollection, FullDocs, OptionManager, TinyDocs Classes: Action, ActionBuilder, Option, OptionBuilder
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
Instance Attribute Summary collapse
-
#name ⇒ Symbol
readonly
private
The name of the face.
-
#version ⇒ SemanticPuppet::Version
readonly
The version of the face.
Attributes included from FullDocs
#copyright_owner, #copyright_years
Class Method Summary collapse
-
.[](name, version) ⇒ Puppet::Interface
Retrieves a face by name and version.
-
.define(name, version, { ... }) ⇒ Puppet::Interface
Defines a new Face.
-
.face?(name, version) ⇒ Puppet::Interface
Retrieves a face by name and version.
-
.faces ⇒ Array<Symbol>
Lists all loaded faces.
-
.find_action(name, action, version = :current) ⇒ Puppet::Interface::Action
Retrieves an action for a face.
-
.register(instance) ⇒ void
private
Register a face.
Instance Method Summary collapse
- #deprecate ⇒ void
- #deprecated? ⇒ Boolean
-
#initialize(name, version, &block) ⇒ Interface
constructor
private
A new instance of Interface.
-
#load_actions ⇒ void
private
Loads all actions defined in other files.
-
#synopsis ⇒ String
private
Returns the synopsis for the face.
-
#to_s ⇒ String
(also: #inspect)
Returns a string representation with the face’s name and version.
Methods included from ActionManager
action, action?, actions, deactivate_action, get_action, get_default_action
Methods included from OptionManager
add_option, all_display_global_options, display_global_options, get_option, option, option?, options, walk_inheritance_tree
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?
Methods included from FullDocs
#author, #author=, #authors, #copyright, #examples, #license, #munge_copyright_year, #notes, #short_description
Methods included from DocGen
Methods included from TinyDocs
#build_synopsis, #description, #summary
Constructor Details
#initialize(name, version, &block) ⇒ Interface
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Interface.
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/puppet/interface.rb', line 150 def initialize(name, version, &block) unless SemanticPuppet::Version.valid?(version) raise ArgumentError, _("Cannot create face %{name} with invalid version number '%{version}'!") % { name: name.inspect, version: version } end @name = Puppet::Interface::FaceCollection.underscorize(name) @version = SemanticPuppet::Version.parse(version) # The few bits of documentation we actually demand. The default license # is a favour to our end users; if you happen to get that in a core face # report it as a bug, please. --daniel 2011-04-26 @authors = [] @license = 'All Rights Reserved' @loader = Puppet::Util::Autoload.new(@name, "puppet/face/#{@name}") instance_eval(&block) if block_given? end |
Instance Attribute Details
#name ⇒ Symbol (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The name of the face
137 138 139 |
# File 'lib/puppet/interface.rb', line 137 def name @name end |
#version ⇒ SemanticPuppet::Version (readonly)
The version of the face
141 142 143 |
# File 'lib/puppet/interface.rb', line 141 def version @version end |
Class Method Details
.[](name, version) ⇒ Puppet::Interface
Retrieves a face by name and version
94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/puppet/interface.rb', line 94 def [](name, version) face = Puppet::Interface::FaceCollection[name, version] unless face # REVISIT (#18042) no sense in rechecking if version == :current -- josh if Puppet::Interface::FaceCollection[name, :current] raise Puppet::Error, "Could not find version #{version} of #{name}" else raise Puppet::Error, "Could not find Puppet Face #{name}" end end face end |
.define(name, version, { ... }) ⇒ Puppet::Interface
Talk about using Faces DSL inside the block
Defines a new Face.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/puppet/interface.rb', line 58 def define(name, version, &block) face = Puppet::Interface::FaceCollection[name, version] if face.nil? then face = new(name, version) Puppet::Interface::FaceCollection.register(face) # REVISIT: Shouldn't this be delayed until *after* we evaluate the # current block, not done before? --daniel 2011-04-07 face.load_actions end face.instance_eval(&block) if block_given? face end |
.face?(name, version) ⇒ Puppet::Interface
Retrieves a face by name and version. Use ‘:current` for the version to get the most recent available version.
82 83 84 |
# File 'lib/puppet/interface.rb', line 82 def face?(name, version) Puppet::Interface::FaceCollection[name, version] end |
.faces ⇒ Array<Symbol>
Lists all loaded faces
36 37 38 |
# File 'lib/puppet/interface.rb', line 36 def faces Puppet::Interface::FaceCollection.faces end |
.find_action(name, action, version = :current) ⇒ Puppet::Interface::Action
Retrieves an action for a face
113 114 115 |
# File 'lib/puppet/interface.rb', line 113 def find_action(name, action, version = :current) Puppet::Interface::FaceCollection.get_action_for_face(name, action, version) end |
.register(instance) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Register a face
44 45 46 |
# File 'lib/puppet/interface.rb', line 44 def register(instance) Puppet::Interface::FaceCollection.register(instance) end |
Instance Method Details
#deprecate ⇒ void
This method returns an undefined value.
184 185 186 |
# File 'lib/puppet/interface.rb', line 184 def deprecate @deprecated = true end |
#deprecated? ⇒ Boolean
189 190 191 |
# File 'lib/puppet/interface.rb', line 189 def deprecated? @deprecated end |
#load_actions ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Loads all actions defined in other files.
172 173 174 |
# File 'lib/puppet/interface.rb', line 172 def load_actions loader.loadall(Puppet.lookup(:current_environment)) end |
#synopsis ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the synopsis for the face. This shows basic usage and global options.
128 129 130 |
# File 'lib/puppet/interface.rb', line 128 def synopsis build_synopsis name, '<action>' end |
#to_s ⇒ String Also known as: inspect
Returns a string representation with the face’s name and version
178 179 180 |
# File 'lib/puppet/interface.rb', line 178 def to_s "Puppet::Face[#{name.inspect}, #{version.inspect}]" end |