Class: Puppet::Interface
- Inherits:
-
Object
- Object
- 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, FullDocs, OptionManager, TinyDocs Classes: Action, ActionBuilder, Option, OptionBuilder
Constant Summary
Instance Attribute Summary (collapse)
-
- (Puppet::Util::Autoload) loader
readonly
private
The autoloader instance for the face.
-
- (Symbol) name
readonly
private
The name of the face.
Attributes included from FullDocs
#copyright_owner, #copyright_years
Class Method Summary (collapse)
-
+ (Puppet::Interface) [](name, version)
Retrieves a face by name and version.
-
+ __add_method(name, proc)
private
-
+ (Object) autoloader
deprecated
private
Deprecated.
-
+ (Puppet::Interface) define(name, version, {|| ... })
DSL
Defines a new Face.
-
+ (Puppet::Interface) face?(name, version)
Retrieves a face by name and version.
-
+ register(instance)
private
Register a face.
Instance Method Summary (collapse)
-
- __add_method(name, proc)
private
-
- __invoke_decorations(type, action, passed_args = [], passed_options = {})
private
-
- (Interface) initialize(name, version, &block)
constructor
private
A new instance of Interface.
-
- load_actions
private
Loads all actions defined in other files.
-
- (String) synopsis
private
Returns the synopsis for the face.
Methods included from OptionManager
add_option, display_global_options, get_option, option, option?, options, walk_inheritance_tree
Methods included from ActionManager
action, action?, actions, get_action, get_default_action, script
Methods included from Util
exit_on_fail, #exit_on_fail, which, #which
Methods included from FullDocs
#author=, #authors, #copyright, #munge_copyright_year
Methods included from DocGen
Methods included from TinyDocs
#build_synopsis, #description, #summary
Constructor Details
- (Interface) initialize(name, version, &block) private
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.
A new instance of Interface
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/puppet/interface.rb', line 151 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
- (Puppet::Util::Autoload) loader (readonly, private) private
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 autoloader instance for the face
147 148 149 |
# File 'lib/puppet/interface.rb', line 147 def loader @loader end |
- (Symbol) name (readonly) private
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
138 139 140 |
# File 'lib/puppet/interface.rb', line 138 def name @name end |
Class Method Details
+ (Puppet::Interface) [](name, version)
Retrieves a face by name and version
94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/puppet/interface.rb', line 94 def [](name, version) unless face = Puppet::Interface::FaceCollection[name, version] # REVISIT (#18042) no sense in rechecking if version == :current -- josh if current = 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 |
+ __add_method(name, proc) (private) private
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.
224 225 226 227 |
# File 'lib/puppet/interface.rb', line 224 def self.__add_method(name, proc) define_method(name, proc) instance_method(name) end |
+ (Object) autoloader deprecatedprivate
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.
29 30 31 32 |
# File 'lib/puppet/interface.rb', line 29 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 |
+ (Puppet::Interface) define(name, version, {|| ... }) DSL
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 = 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 |
+ (Puppet::Interface) face?(name, version)
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 |
+ register(instance) private
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
- __add_method(name, proc) (private) private
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.
217 218 219 220 |
# File 'lib/puppet/interface.rb', line 217 def __add_method(name, proc) (name, &proc) method(name).unbind end |
- __invoke_decorations(type, action, passed_args = [], passed_options = {}) (private) private
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.
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
# File 'lib/puppet/interface.rb', line 196 def __invoke_decorations(type, action, passed_args = [], = {}) [:before, :after].member?(type) or fail "unknown decoration type #{type}" # Collect the decoration methods matching our pass. methods = action..select do |name| .has_key? name end.map do |name| action.get_option(name).__decoration_name(type) end methods.reverse! if type == :after # Exceptions here should propagate up; this implements a hook we can use # reasonably for option validation. methods.each do |hook| respond_to? hook and self.__send__(hook, action, passed_args, ) end end |
- load_actions private
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.
173 174 175 |
# File 'lib/puppet/interface.rb', line 173 def load_actions loader.loadall end |
- (String) synopsis private
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 self.name, '<action>' end |