class Puppet::Interface

@api public

Attributes

name[R]

The name of the face @return [Symbol] @api private

version[R]

The version of the face @return [SemVer]

Public Class Methods

[](name, version) click to toggle source

Retrieves a face by name and version

@param name [Symbol] the name of the face @param version [String] the version of the face

@return [Puppet::Interface] the face

@api public

# 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
autoloader() click to toggle source

@api private @deprecated

# 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
define(name, version, &block) click to toggle source

Defines a new Face. @todo Talk about using Faces DSL inside the block

@param name [Symbol] the name of the face @param version [String] the version of the face (this should

conform to {http://semver.org/ Semantic Versioning})

@overload define(name, version, {|| … }) @return [Puppet::Interface] The created face @api public @dsl Faces

# 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
face?(name, version) click to toggle source

Retrieves a face by name and version. Use `:current` for the version to get the most recent available version.

@param name [Symbol] the name of the face @param version [String, :current] the version of the face

@return [Puppet::Interface] the face

@api public

# File lib/puppet/interface.rb, line 82
def face?(name, version)
  Puppet::Interface::FaceCollection[name, version]
end
faces() click to toggle source

Lists all loaded faces @return [Array<Symbol>] The names of the loaded faces

# File lib/puppet/interface.rb, line 36
def faces
  Puppet::Interface::FaceCollection.faces
end
find_action(name, action, version = :current) click to toggle source

Retrieves an action for a face @param name [Symbol] The face @param action [Symbol] The action name @param version [String, :current] The version of the face @return [Puppet::Interface::Action] The action

# File lib/puppet/interface.rb, line 112
def find_action(name, action, version = :current)
  Puppet::Interface::FaceCollection.get_action_for_face(name, action, version)
end
new(name, version, &block) click to toggle source

@api private

# 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
  @authors  = []
  @license  = 'All Rights Reserved'

  @loader = Puppet::Util::Autoload.new(@name, "puppet/face/#{@name}")
  instance_eval(&block) if block_given?
end
register(instance) click to toggle source

Register a face @param instance [Puppet::Interface] The face @return [void] @api private

# File lib/puppet/interface.rb, line 44
def register(instance)
  Puppet::Interface::FaceCollection.register(instance)
end

Public Instance Methods

load_actions() click to toggle source

Loads all actions defined in other files.

@return [void] @api private

# File lib/puppet/interface.rb, line 173
def load_actions
  loader.loadall
end
synopsis() click to toggle source

Returns the synopsis for the face. This shows basic usage and global options. @return [String] usage synopsis @api private

# File lib/puppet/interface.rb, line 128
def synopsis
  build_synopsis self.name, '<action>'
end
to_s() click to toggle source

Returns a string representation with the face’s name and version @return [String]

# File lib/puppet/interface.rb, line 179
def to_s
  "Puppet::Face[#{name.inspect}, #{version.inspect}]"
end