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::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
Instance Attribute Summary collapse
-
#name ⇒ Symbol
readonly
private
The name of the face.
-
#version ⇒ SemVer
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.
- .autoloader ⇒ Object deprecated private Deprecated.
-
.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
-
#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
Returns a string representation with the face’s name and version.
Methods included from ActionManager
action, action?, actions, get_action, get_default_action, script
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?, activerecord_version, benchmark, binread, chuser, classproxy, deterministic_rand, execfail, execpipe, execute, exit_on_fail, logmethods, memory, path_to_uri, pretty_backtrace, proxy, replace_file, safe_posix_fork, symbolizehash, thinmark, 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?
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.
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/puppet/interface.rb', line 158 def initialize(name, version, &block) unless SemVer.valid?(version) raise ArgumentError, "Cannot create face #{name.inspect} with invalid version number '#{version}'!" end @name = Puppet::Interface::FaceCollection.underscorize(name) @version = SemVer.new(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 = [] @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
145 146 147 |
# File 'lib/puppet/interface.rb', line 145 def name @name end |
#version ⇒ SemVer (readonly)
The version of the face
149 150 151 |
# File 'lib/puppet/interface.rb', line 149 def version @version end |
Class Method Details
.[](name, version) ⇒ Puppet::Interface
Retrieves a face by name and version
101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/puppet/interface.rb', line 101 def [](name, version) unless face = Puppet::Interface::FaceCollection[name, version] # 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.to_s}" end end face end |
.autoloader ⇒ Object
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.
36 37 38 39 |
# File 'lib/puppet/interface.rb', line 36 def autoloader Puppet.deprecation_warning("Puppet::Interface.autoloader is deprecated; please use Puppet::Interface#loader instead") @autoloader ||= Puppet::Util::Autoload.new(:application, "puppet/face") end |
.define(name, version, {|| ... }) ⇒ Puppet::Interface
Talk about using Faces DSL inside the block
Defines a new Face.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/puppet/interface.rb', line 65 def define(name, version, &block) face = Puppet::Interface::FaceCollection[name, version] if face.nil? then face = self.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? return 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.
89 90 91 |
# File 'lib/puppet/interface.rb', line 89 def face?(name, version) Puppet::Interface::FaceCollection[name, version] end |
.faces ⇒ Array<Symbol>
Lists all loaded faces
43 44 45 |
# File 'lib/puppet/interface.rb', line 43 def faces Puppet::Interface::FaceCollection.faces end |
.find_action(name, action, version = :current) ⇒ Puppet::Interface::Action
Retrieves an action for a face
119 120 121 |
# File 'lib/puppet/interface.rb', line 119 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
51 52 53 |
# File 'lib/puppet/interface.rb', line 51 def register(instance) Puppet::Interface::FaceCollection.register(instance) end |
Instance Method Details
#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.
180 181 182 |
# File 'lib/puppet/interface.rb', line 180 def load_actions loader.loadall 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.
135 136 137 |
# File 'lib/puppet/interface.rb', line 135 def synopsis build_synopsis self.name, '<action>' end |
#to_s ⇒ String
Returns a string representation with the face’s name and version
186 187 188 |
# File 'lib/puppet/interface.rb', line 186 def to_s "Puppet::Face[#{name.inspect}, #{version.inspect}]" end |