summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/application/config.rb4
-rw-r--r--lib/puppet/application/configurer.rb6
-rw-r--r--lib/puppet/application/faces.rb (renamed from lib/puppet/application/string.rb)18
-rw-r--r--lib/puppet/application/faces_base.rb (renamed from lib/puppet/application/string_base.rb)24
-rw-r--r--lib/puppet/application/indirection_base.rb4
-rw-r--r--lib/puppet/faces.rb12
-rw-r--r--lib/puppet/faces/catalog.rb (renamed from lib/puppet/string/catalog.rb)6
-rw-r--r--lib/puppet/faces/catalog/select.rb (renamed from lib/puppet/string/catalog/select.rb)2
-rw-r--r--lib/puppet/faces/certificate.rb (renamed from lib/puppet/string/certificate.rb)4
-rw-r--r--lib/puppet/faces/certificate_request.rb4
-rw-r--r--lib/puppet/faces/certificate_revocation_list.rb4
-rw-r--r--lib/puppet/faces/config.rb (renamed from lib/puppet/string/config.rb)4
-rw-r--r--lib/puppet/faces/configurer.rb12
-rw-r--r--lib/puppet/faces/facts.rb (renamed from lib/puppet/string/facts.rb)4
-rw-r--r--lib/puppet/faces/file.rb5
-rw-r--r--lib/puppet/faces/indirector.rb (renamed from lib/puppet/string/indirector.rb)10
-rw-r--r--lib/puppet/faces/key.rb4
-rw-r--r--lib/puppet/faces/node.rb5
-rw-r--r--lib/puppet/faces/report.rb (renamed from lib/puppet/string/report.rb)4
-rw-r--r--lib/puppet/faces/resource.rb4
-rw-r--r--lib/puppet/faces/resource_type.rb4
-rw-r--r--lib/puppet/faces/status.rb4
-rw-r--r--lib/puppet/interface.rb (renamed from lib/puppet/string.rb)56
-rw-r--r--lib/puppet/interface/action.rb (renamed from lib/puppet/string/action.rb)50
-rw-r--r--lib/puppet/interface/action_builder.rb31
-rw-r--r--lib/puppet/interface/action_manager.rb (renamed from lib/puppet/string/action_manager.rb)8
-rw-r--r--lib/puppet/interface/face_collection.rb (renamed from lib/puppet/string/string_collection.rb)42
-rw-r--r--lib/puppet/interface/option.rb (renamed from lib/puppet/string/option.rb)8
-rw-r--r--lib/puppet/interface/option_builder.rb25
-rw-r--r--lib/puppet/interface/option_manager.rb (renamed from lib/puppet/string/option_manager.rb)6
-rw-r--r--lib/puppet/string/action_builder.rb31
-rw-r--r--lib/puppet/string/certificate_request.rb4
-rw-r--r--lib/puppet/string/certificate_revocation_list.rb4
-rw-r--r--lib/puppet/string/configurer.rb12
-rw-r--r--lib/puppet/string/file.rb5
-rw-r--r--lib/puppet/string/key.rb4
-rw-r--r--lib/puppet/string/node.rb5
-rw-r--r--lib/puppet/string/option_builder.rb25
-rw-r--r--lib/puppet/string/resource.rb4
-rw-r--r--lib/puppet/string/resource_type.rb4
-rw-r--r--lib/puppet/string/status.rb4
41 files changed, 245 insertions, 231 deletions
diff --git a/lib/puppet/application/config.rb b/lib/puppet/application/config.rb
index f6559277b..41a46c339 100644
--- a/lib/puppet/application/config.rb
+++ b/lib/puppet/application/config.rb
@@ -1,4 +1,4 @@
-require 'puppet/application/string_base'
+require 'puppet/application/faces_base'
-class Puppet::Application::Config < Puppet::Application::StringBase
+class Puppet::Application::Config < Puppet::Application::FacesBase
end
diff --git a/lib/puppet/application/configurer.rb b/lib/puppet/application/configurer.rb
index be018338f..751e6b4d7 100644
--- a/lib/puppet/application/configurer.rb
+++ b/lib/puppet/application/configurer.rb
@@ -1,5 +1,5 @@
require 'puppet/application'
-require 'puppet/string'
+require 'puppet/faces'
class Puppet::Application::Configurer < Puppet::Application
should_parse_config
@@ -17,7 +17,7 @@ class Puppet::Application::Configurer < Puppet::Application
end
def run_command
- report = Puppet::String[:configurer, '0.0.1'].synchronize(Puppet[:certname])
- Puppet::String[:report, '0.0.1'].submit(report)
+ report = Puppet::Faces[:configurer, '0.0.1'].synchronize(Puppet[:certname])
+ Puppet::Faces[:report, '0.0.1'].submit(report)
end
end
diff --git a/lib/puppet/application/string.rb b/lib/puppet/application/faces.rb
index 0a6a798ce..904a0cccc 100644
--- a/lib/puppet/application/string.rb
+++ b/lib/puppet/application/faces.rb
@@ -1,7 +1,7 @@
require 'puppet/application'
-require 'puppet/string'
+require 'puppet/faces'
-class Puppet::Application::String < Puppet::Application
+class Puppet::Application::Faces < Puppet::Application
should_parse_config
run_mode :agent
@@ -18,7 +18,7 @@ class Puppet::Application::String < Puppet::Application
if arguments.empty?
arguments = %w{terminuses actions}
end
- strings.each do |name|
+ faces.each do |name|
str = "#{name}:\n"
if arguments.include?("terminuses")
begin
@@ -68,12 +68,12 @@ class Puppet::Application::String < Puppet::Application
end
unless respond_to?(verb)
- raise "Command '#{verb}' not found for 'string'"
+ raise "Command '#{verb}' not found for 'faces'"
end
end
- def strings
- Puppet::String.strings
+ def faces
+ Puppet::Faces.faces
end
def terminus_classes(indirection)
@@ -81,9 +81,9 @@ class Puppet::Application::String < Puppet::Application
end
def actions(indirection)
- return [] unless string = Puppet::String[indirection, '0.0.1']
- string.load_actions
- return string.actions.sort { |a, b| a.to_s <=> b.to_s }
+ return [] unless faces = Puppet::Faces[indirection, '0.0.1']
+ faces.load_actions
+ return faces.actions.sort { |a, b| a.to_s <=> b.to_s }
end
def load_applications
diff --git a/lib/puppet/application/string_base.rb b/lib/puppet/application/faces_base.rb
index 09d02c079..6d66ee8a1 100644
--- a/lib/puppet/application/string_base.rb
+++ b/lib/puppet/application/faces_base.rb
@@ -1,7 +1,7 @@
require 'puppet/application'
-require 'puppet/string'
+require 'puppet/faces'
-class Puppet::Application::StringBase < Puppet::Application
+class Puppet::Application::FacesBase < Puppet::Application
should_parse_config
run_mode :agent
@@ -24,7 +24,7 @@ class Puppet::Application::StringBase < Puppet::Application
end
- attr_accessor :string, :action, :type, :arguments, :format
+ attr_accessor :face, :action, :type, :arguments, :format
attr_writer :exit_code
# This allows you to set the exit code if you don't want to just exit
@@ -47,7 +47,7 @@ class Puppet::Application::StringBase < Puppet::Application
def preinit
super
trap(:INT) do
- $stderr.puts "Cancelling String"
+ $stderr.puts "Cancelling Face"
exit(0)
end
@@ -57,8 +57,8 @@ class Puppet::Application::StringBase < Puppet::Application
# TODO: These should be configurable versions, through a global
# '--version' option, but we don't implement that yet... --daniel 2011-03-29
@type = self.class.name.to_s.sub(/.+:/, '').downcase.to_sym
- @string = Puppet::String[@type, :current]
- @format = @string.default_format
+ @face = Puppet::Faces[@type, :current]
+ @format = @face.default_format
# Now, walk the command line and identify the action. We skip over
# arguments based on introspecting the action and all, and find the first
@@ -68,11 +68,11 @@ class Puppet::Application::StringBase < Puppet::Application
until @action or (index += 1) >= command_line.args.length do
item = command_line.args[index]
if item =~ /^-/ then
- option = @string.options.find do |name|
+ option = @face.options.find do |name|
item =~ /^-+#{name.to_s.gsub(/[-_]/, '[-_]')}(?:[ =].*)?$/
end
if option then
- option = @string.get_option(option)
+ option = @face.get_option(option)
# If we have an inline argument, just carry on. We don't need to
# care about optional vs mandatory in that case because we do a real
# parse later, and that will totally take care of raising the error
@@ -91,9 +91,9 @@ class Puppet::Application::StringBase < Puppet::Application
raise ArgumentError, "Unknown option #{item.sub(/=.*$/, '').inspect}"
end
else
- action = @string.get_action(item.to_sym)
+ action = @face.get_action(item.to_sym)
if action.nil? then
- raise ArgumentError, "#{@string} does not have an #{item.inspect} action!"
+ raise ArgumentError, "#{@face} does not have an #{item.inspect} action!"
end
@action = action
end
@@ -129,7 +129,7 @@ class Puppet::Application::StringBase < Puppet::Application
# Note: because of our definition of where the action is set, we end up
# with it *always* being the first word of the remaining set of command
# line arguments. So, strip that off when we construct the arguments to
- # pass down to the string action. --daniel 2011-04-04
+ # pass down to the face action. --daniel 2011-04-04
@arguments.delete_at(0)
# We copy all of the app options to the end of the call; This allows each
@@ -142,7 +142,7 @@ class Puppet::Application::StringBase < Puppet::Application
def main
# Call the method associated with the provided action (e.g., 'find').
- if result = @string.send(@action.name, *arguments)
+ if result = @face.send(@action.name, *arguments)
puts render(result)
end
exit(exit_code)
diff --git a/lib/puppet/application/indirection_base.rb b/lib/puppet/application/indirection_base.rb
index cfa1ea529..7455ebedf 100644
--- a/lib/puppet/application/indirection_base.rb
+++ b/lib/puppet/application/indirection_base.rb
@@ -1,4 +1,4 @@
-require 'puppet/application/string_base'
+require 'puppet/application/faces_base'
-class Puppet::Application::IndirectionBase < Puppet::Application::StringBase
+class Puppet::Application::IndirectionBase < Puppet::Application::FacesBase
end
diff --git a/lib/puppet/faces.rb b/lib/puppet/faces.rb
new file mode 100644
index 000000000..947eecf24
--- /dev/null
+++ b/lib/puppet/faces.rb
@@ -0,0 +1,12 @@
+# The public name of this feature is 'faces', but we have hidden all the
+# plumbing over in the 'interfaces' namespace to make clear the distinction
+# between the two.
+#
+# This file exists to ensure that the public name is usable without revealing
+# the details of the implementation; you really only need go look at anything
+# under Interfaces if you are looking to extend the implementation.
+#
+# It isn't hidden to gratuitously hide things, just to make it easier to
+# separate out the interests people will have. --daniel 2011-04-07
+require 'puppet/interface'
+Puppet::Faces = Puppet::Interface
diff --git a/lib/puppet/string/catalog.rb b/lib/puppet/faces/catalog.rb
index 441c7ee7d..2e2168ac4 100644
--- a/lib/puppet/string/catalog.rb
+++ b/lib/puppet/faces/catalog.rb
@@ -1,6 +1,6 @@
-require 'puppet/string/indirector'
+require 'puppet/faces/indirector'
-Puppet::String::Indirector.define(:catalog, '0.0.1') do
+Puppet::Faces::Indirector.define(:catalog, '0.0.1') do
action(:apply) do
when_invoked do |catalog, options|
report = Puppet::Transaction::Report.new("apply")
@@ -28,7 +28,7 @@ Puppet::String::Indirector.define(:catalog, '0.0.1') do
facts_to_upload = {:facts_format => :b64_zlib_yaml, :facts => CGI.escape(facts.render(:b64_zlib_yaml))}
catalog = nil
retrieval_duration = thinmark do
- catalog = Puppet::String[:catalog, '0.0.1'].find(certname, facts_to_upload)
+ catalog = Puppet::Faces[:catalog, '0.0.1'].find(certname, facts_to_upload)
end
catalog = catalog.to_ral
catalog.finalize
diff --git a/lib/puppet/string/catalog/select.rb b/lib/puppet/faces/catalog/select.rb
index 11670e2e7..e29d19970 100644
--- a/lib/puppet/string/catalog/select.rb
+++ b/lib/puppet/faces/catalog/select.rb
@@ -1,5 +1,5 @@
# Select and show a list of resources of a given type.
-Puppet::String.define(:catalog, '0.0.1') do
+Puppet::Faces.define(:catalog, '0.0.1') do
action :select do
when_invoked do |host, type, options|
catalog = Puppet::Resource::Catalog.indirection.find(host)
diff --git a/lib/puppet/string/certificate.rb b/lib/puppet/faces/certificate.rb
index e8773ae2e..b10bee579 100644
--- a/lib/puppet/string/certificate.rb
+++ b/lib/puppet/faces/certificate.rb
@@ -1,7 +1,7 @@
-require 'puppet/string/indirector'
+require 'puppet/faces/indirector'
require 'puppet/ssl/host'
-Puppet::String::Indirector.define(:certificate, '0.0.1') do
+Puppet::Faces::Indirector.define(:certificate, '0.0.1') do
# REVISIT: This should use a pre-invoke hook to run the common code that
# needs to happen before we invoke any action; that would be much nicer than
# the "please repeat yourself" stuff found in here right now.
diff --git a/lib/puppet/faces/certificate_request.rb b/lib/puppet/faces/certificate_request.rb
new file mode 100644
index 000000000..5e91bdb7f
--- /dev/null
+++ b/lib/puppet/faces/certificate_request.rb
@@ -0,0 +1,4 @@
+require 'puppet/faces/indirector'
+
+Puppet::Faces::Indirector.define(:certificate_request, '0.0.1') do
+end
diff --git a/lib/puppet/faces/certificate_revocation_list.rb b/lib/puppet/faces/certificate_revocation_list.rb
new file mode 100644
index 000000000..2f2d72874
--- /dev/null
+++ b/lib/puppet/faces/certificate_revocation_list.rb
@@ -0,0 +1,4 @@
+require 'puppet/faces/indirector'
+
+Puppet::Faces::Indirector.define(:certificate_revocation_list, '0.0.1') do
+end
diff --git a/lib/puppet/string/config.rb b/lib/puppet/faces/config.rb
index 8a9417148..647bf5052 100644
--- a/lib/puppet/string/config.rb
+++ b/lib/puppet/faces/config.rb
@@ -1,6 +1,6 @@
-require 'puppet/string'
+require 'puppet/faces'
-Puppet::String.define(:config, '0.0.1') do
+Puppet::Faces.define(:config, '0.0.1') do
action(:print) do
when_invoked do |*args|
options = args.pop
diff --git a/lib/puppet/faces/configurer.rb b/lib/puppet/faces/configurer.rb
new file mode 100644
index 000000000..d40987697
--- /dev/null
+++ b/lib/puppet/faces/configurer.rb
@@ -0,0 +1,12 @@
+require 'puppet/faces'
+
+Puppet::Faces.define(:configurer, '0.0.1') do
+ action(:synchronize) do
+ when_invoked do |certname, options|
+ facts = Puppet::Faces[:facts, '0.0.1'].find(certname)
+ catalog = Puppet::Faces[:catalog, '0.0.1'].download(certname, facts)
+ report = Puppet::Faces[:catalog, '0.0.1'].apply(catalog)
+ report
+ end
+ end
+end
diff --git a/lib/puppet/string/facts.rb b/lib/puppet/faces/facts.rb
index 6bd9904b0..33eacef38 100644
--- a/lib/puppet/string/facts.rb
+++ b/lib/puppet/faces/facts.rb
@@ -1,7 +1,7 @@
-require 'puppet/string/indirector'
+require 'puppet/faces/indirector'
require 'puppet/node/facts'
-Puppet::String::Indirector.define(:facts, '0.0.1') do
+Puppet::Faces::Indirector.define(:facts, '0.0.1') do
set_default_format :yaml
# Upload our facts to the server
diff --git a/lib/puppet/faces/file.rb b/lib/puppet/faces/file.rb
new file mode 100644
index 000000000..e8ad18c17
--- /dev/null
+++ b/lib/puppet/faces/file.rb
@@ -0,0 +1,5 @@
+require 'puppet/faces/indirector'
+
+Puppet::Faces::Indirector.define(:file, '0.0.1') do
+ set_indirection_name :file_bucket_file
+end
diff --git a/lib/puppet/string/indirector.rb b/lib/puppet/faces/indirector.rb
index 0c7d043bb..f72260017 100644
--- a/lib/puppet/string/indirector.rb
+++ b/lib/puppet/faces/indirector.rb
@@ -1,7 +1,7 @@
require 'puppet'
-require 'puppet/string'
+require 'puppet/faces'
-class Puppet::String::Indirector < Puppet::String
+class Puppet::Faces::Indirector < Puppet::Faces
option "--terminus TERMINUS" do
desc "REVISIT: You can select a terminus, which has some bigger effect
that we should describe in this file somehow."
@@ -68,13 +68,13 @@ that we should describe in this file somehow."
@indirection_name || name.to_sym
end
- # Here's your opportunity to override the indirection name. By default
- # it will be the same name as the string.
+ # Here's your opportunity to override the indirection name. By default it
+ # will be the same name as the face.
def set_indirection_name(name)
@indirection_name = name
end
- # Return an indirection associated with an string, if one exists
+ # Return an indirection associated with a face, if one exists;
# One usually does.
def indirection
unless @indirection
diff --git a/lib/puppet/faces/key.rb b/lib/puppet/faces/key.rb
new file mode 100644
index 000000000..7b6ad52ac
--- /dev/null
+++ b/lib/puppet/faces/key.rb
@@ -0,0 +1,4 @@
+require 'puppet/faces/indirector'
+
+Puppet::Faces::Indirector.define(:key, '0.0.1') do
+end
diff --git a/lib/puppet/faces/node.rb b/lib/puppet/faces/node.rb
new file mode 100644
index 000000000..7eed0df91
--- /dev/null
+++ b/lib/puppet/faces/node.rb
@@ -0,0 +1,5 @@
+require 'puppet/faces/indirector'
+
+Puppet::Faces::Indirector.define(:node, '0.0.1') do
+ set_default_format :yaml
+end
diff --git a/lib/puppet/string/report.rb b/lib/puppet/faces/report.rb
index da3ca8504..23a518981 100644
--- a/lib/puppet/string/report.rb
+++ b/lib/puppet/faces/report.rb
@@ -1,6 +1,6 @@
-require 'puppet/string/indirector'
+require 'puppet/faces/indirector'
-Puppet::String::Indirector.define(:report, '0.0.1') do
+Puppet::Faces::Indirector.define(:report, '0.0.1') do
action(:submit) do
when_invoked do |report, options|
begin
diff --git a/lib/puppet/faces/resource.rb b/lib/puppet/faces/resource.rb
new file mode 100644
index 000000000..60b0d94db
--- /dev/null
+++ b/lib/puppet/faces/resource.rb
@@ -0,0 +1,4 @@
+require 'puppet/faces/indirector'
+
+Puppet::Faces::Indirector.define(:resource, '0.0.1') do
+end
diff --git a/lib/puppet/faces/resource_type.rb b/lib/puppet/faces/resource_type.rb
new file mode 100644
index 000000000..4321d65e7
--- /dev/null
+++ b/lib/puppet/faces/resource_type.rb
@@ -0,0 +1,4 @@
+require 'puppet/faces/indirector'
+
+Puppet::Faces::Indirector.define(:resource_type, '0.0.1') do
+end
diff --git a/lib/puppet/faces/status.rb b/lib/puppet/faces/status.rb
new file mode 100644
index 000000000..e035f281f
--- /dev/null
+++ b/lib/puppet/faces/status.rb
@@ -0,0 +1,4 @@
+require 'puppet/faces/indirector'
+
+Puppet::Faces::Indirector.define(:status, '0.0.1') do
+end
diff --git a/lib/puppet/string.rb b/lib/puppet/interface.rb
index 517cf4506..70484adfc 100644
--- a/lib/puppet/string.rb
+++ b/lib/puppet/interface.rb
@@ -1,16 +1,16 @@
require 'puppet'
require 'puppet/util/autoload'
-class Puppet::String
- require 'puppet/string/string_collection'
+class Puppet::Interface
+ require 'puppet/interface/face_collection'
- require 'puppet/string/action_manager'
- include Puppet::String::ActionManager
- extend Puppet::String::ActionManager
+ require 'puppet/interface/action_manager'
+ include Puppet::Interface::ActionManager
+ extend Puppet::Interface::ActionManager
- require 'puppet/string/option_manager'
- include Puppet::String::OptionManager
- extend Puppet::String::OptionManager
+ require 'puppet/interface/option_manager'
+ include Puppet::Interface::OptionManager
+ extend Puppet::Interface::OptionManager
include Puppet::Util
@@ -19,33 +19,35 @@ class Puppet::String
# list of directories to search.
# Can't we utilize an external autoloader, or simply use the $LOAD_PATH? -pvb
def autoloader
- @autoloader ||= Puppet::Util::Autoload.new(:application, "puppet/string")
+ @autoloader ||= Puppet::Util::Autoload.new(:application, "puppet/faces")
end
- def strings
- Puppet::String::StringCollection.strings
+ def faces
+ Puppet::Interface::FaceCollection.faces
end
- def string?(name, version)
- Puppet::String::StringCollection.string?(name, version)
+ def face?(name, version)
+ Puppet::Interface::FaceCollection.face?(name, version)
end
def register(instance)
- Puppet::String::StringCollection.register(instance)
+ Puppet::Interface::FaceCollection.register(instance)
end
def define(name, version, &block)
- if string?(name, version)
- string = Puppet::String::StringCollection[name, version]
+ if face?(name, version)
+ face = Puppet::Interface::FaceCollection[name, version]
else
- string = self.new(name, version)
- Puppet::String::StringCollection.register(string)
- string.load_actions
+ 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
- string.instance_eval(&block) if block_given?
+ face.instance_eval(&block) if block_given?
- return string
+ return face
end
alias :[] :define
@@ -61,11 +63,11 @@ class Puppet::String
attr_reader :name
def initialize(name, version, &block)
- unless Puppet::String::StringCollection.validate_version(version)
- raise ArgumentError, "Cannot create string #{name.inspect} with invalid version number '#{version}'!"
+ unless Puppet::Interface::FaceCollection.validate_version(version)
+ raise ArgumentError, "Cannot create face #{name.inspect} with invalid version number '#{version}'!"
end
- @name = Puppet::String::StringCollection.underscorize(name)
+ @name = Puppet::Interface::FaceCollection.underscorize(name)
@version = version
@default_format = :pson
@@ -74,11 +76,11 @@ class Puppet::String
# Try to find actions defined in other files.
def load_actions
- path = "puppet/string/#{name}"
+ path = "puppet/faces/#{name}"
loaded = []
[path, "#{name}@#{version}/#{path}"].each do |path|
- Puppet::String.autoloader.search_directories.each do |dir|
+ Puppet::Interface.autoloader.search_directories.each do |dir|
fdir = ::File.join(dir, path)
next unless FileTest.directory?(fdir)
@@ -99,6 +101,6 @@ class Puppet::String
end
def to_s
- "Puppet::String[#{name.inspect}, #{version.inspect}]"
+ "Puppet::Faces[#{name.inspect}, #{version.inspect}]"
end
end
diff --git a/lib/puppet/string/action.rb b/lib/puppet/interface/action.rb
index 0f5032ffb..e4a37a1f7 100644
--- a/lib/puppet/string/action.rb
+++ b/lib/puppet/interface/action.rb
@@ -1,28 +1,26 @@
# -*- coding: utf-8 -*-
-require 'puppet/string'
-require 'puppet/string/option'
+require 'puppet/interface'
+require 'puppet/interface/option'
-class Puppet::String::Action
- attr_reader :name
-
- def to_s
- "#{@string}##{@name}"
- end
-
- def initialize(string, name, attrs = {})
+class Puppet::Interface::Action
+ def initialize(face, name, attrs = {})
raise "#{name.inspect} is an invalid action name" unless name.to_s =~ /^[a-z]\w*$/
- @string = string
+ @face = face
@name = name.to_sym
@options = {}
attrs.each do |k, v| send("#{k}=", v) end
end
+ attr_reader :name
+ def to_s() "#{@face}##{@name}" end
+
+
# Initially, this was defined to allow the @action.invoke pattern, which is
# a very natural way to invoke behaviour given our introspection
- # capabilities. Heck, our initial plan was to have the string delegate to
+ # capabilities. Heck, our initial plan was to have the faces delegate to
# the action object for invocation and all.
#
- # It turns out that we have a binding problem to solve: @string was bound to
+ # It turns out that we have a binding problem to solve: @face was bound to
# the parent class, not the subclass instance, and we don't pass the
# appropriate context or change the binding enough to make this work.
#
@@ -33,13 +31,13 @@ class Puppet::String::Action
# So, we are pulling this method for now, and will return it to life when we
# have the time to resolve the problem. For now, you should replace...
#
- # @action = @string.get_action(name)
+ # @action = @face.get_action(name)
# @action.invoke(arg1, arg2, arg3)
#
# ...with...
#
- # @action = @string.get_action(name)
- # @string.send(@action.name, arg1, arg2, arg3)
+ # @action = @face.get_action(name)
+ # @face.send(@action.name, arg1, arg2, arg3)
#
# I understand that is somewhat cumbersome, but it functions as desired.
# --daniel 2011-03-31
@@ -48,7 +46,7 @@ class Puppet::String::Action
# documentation, for the benefit of the reader.
#
# def invoke(*args, &block)
- # @string.send(name, *args, &block)
+ # @face.send(name, *args, &block)
# end
def when_invoked=(block)
@@ -82,12 +80,12 @@ class Puppet::String::Action
self.__send__(#{internal_name.inspect}, *args)
end"
- if @string.is_a?(Class)
- @string.class_eval do eval wrapper, nil, file, line end
- @string.define_method(internal_name, &block)
+ if @face.is_a?(Class)
+ @face.class_eval do eval wrapper, nil, file, line end
+ @face.define_method(internal_name, &block)
else
- @string.instance_eval do eval wrapper, nil, file, line end
- @string.meta_def(internal_name, &block)
+ @face.instance_eval do eval wrapper, nil, file, line end
+ @face.meta_def(internal_name, &block)
end
end
@@ -95,8 +93,8 @@ class Puppet::String::Action
option.aliases.each do |name|
if conflict = get_option(name) then
raise ArgumentError, "Option #{option} conflicts with existing option #{conflict}"
- elsif conflict = @string.get_option(name) then
- raise ArgumentError, "Option #{option} conflicts with existing option #{conflict} on #{@string}"
+ elsif conflict = @face.get_option(name) then
+ raise ArgumentError, "Option #{option} conflicts with existing option #{conflict} on #{@face}"
end
end
@@ -112,10 +110,10 @@ class Puppet::String::Action
end
def options
- (@options.keys + @string.options).sort
+ (@options.keys + @face.options).sort
end
def get_option(name)
- @options[name.to_sym] || @string.get_option(name)
+ @options[name.to_sym] || @face.get_option(name)
end
end
diff --git a/lib/puppet/interface/action_builder.rb b/lib/puppet/interface/action_builder.rb
new file mode 100644
index 000000000..b08c3d023
--- /dev/null
+++ b/lib/puppet/interface/action_builder.rb
@@ -0,0 +1,31 @@
+require 'puppet/interface'
+require 'puppet/interface/action'
+
+class Puppet::Interface::ActionBuilder
+ attr_reader :action
+
+ def self.build(face, name, &block)
+ raise "Action #{name.inspect} must specify a block" unless block
+ new(face, name, &block).action
+ end
+
+ private
+ def initialize(face, name, &block)
+ @face = face
+ @action = Puppet::Interface::Action.new(face, name)
+ instance_eval(&block)
+ end
+
+ # Ideally the method we're defining here would be added to the action, and a
+ # method on the face would defer to it, but we can't get scope correct, so
+ # we stick with this. --daniel 2011-03-24
+ def when_invoked(&block)
+ raise "when_invoked on an ActionBuilder with no corresponding Action" unless @action
+ @action.when_invoked = block
+ end
+
+ def option(*declaration, &block)
+ option = Puppet::Interface::OptionBuilder.build(@action, *declaration, &block)
+ @action.add_option(option)
+ end
+end
diff --git a/lib/puppet/string/action_manager.rb b/lib/puppet/interface/action_manager.rb
index 9f0aa7582..bb0e5bf57 100644
--- a/lib/puppet/string/action_manager.rb
+++ b/lib/puppet/interface/action_manager.rb
@@ -1,12 +1,12 @@
-require 'puppet/string/action_builder'
+require 'puppet/interface/action_builder'
-module Puppet::String::ActionManager
+module Puppet::Interface::ActionManager
# Declare that this app can take a specific action, and provide
# the code to do so.
def action(name, &block)
@actions ||= {}
raise "Action #{name} already defined for #{self}" if action?(name)
- action = Puppet::String::ActionBuilder.build(self, name, &block)
+ action = Puppet::Interface::ActionBuilder.build(self, name, &block)
@actions[action.name] = action
end
@@ -15,7 +15,7 @@ module Puppet::String::ActionManager
def script(name, &block)
@actions ||= {}
raise "Action #{name} already defined for #{self}" if action?(name)
- @actions[name] = Puppet::String::Action.new(self, name, :when_invoked => block)
+ @actions[name] = Puppet::Interface::Action.new(self, name, :when_invoked => block)
end
def actions
diff --git a/lib/puppet/string/string_collection.rb b/lib/puppet/interface/face_collection.rb
index ecd99359d..9f7a499c2 100644
--- a/lib/puppet/string/string_collection.rb
+++ b/lib/puppet/interface/face_collection.rb
@@ -1,18 +1,20 @@
# -*- coding: utf-8 -*-
-require 'puppet/string'
+require 'puppet/interface'
-module Puppet::String::StringCollection
+module Puppet::Interface::FaceCollection
SEMVER_VERSION = /^(\d+)\.(\d+)\.(\d+)([A-Za-z][0-9A-Za-z-]*|)$/
- @strings = Hash.new { |hash, key| hash[key] = {} }
+ @faces = Hash.new { |hash, key| hash[key] = {} }
- def self.strings
+ def self.faces
unless @loaded
@loaded = true
$LOAD_PATH.each do |dir|
next unless FileTest.directory?(dir)
Dir.chdir(dir) do
- Dir.glob("puppet/string/v*/*.rb").collect { |f| f.sub(/\.rb/, '') }.each do |file|
+ # REVISIT: This is wrong!!!! We don't name files like that ever,
+ # so we should no longer match things like this. Damnit!!! --daniel 2011-04-07
+ Dir.glob("puppet/faces/v*/*.rb").collect { |f| f.sub(/\.rb/, '') }.each do |file|
iname = file.sub(/\.rb/, '')
begin
require iname
@@ -24,14 +26,14 @@ module Puppet::String::StringCollection
end
end
end
- return @strings.keys
+ return @faces.keys
end
def self.validate_version(version)
!!(SEMVER_VERSION =~ version.to_s)
end
- def self.cmp_versions(a, b)
+ def self.cmp_semver(a, b)
a, b = [a, b].map do |x|
parts = SEMVER_VERSION.match(x).to_a[1..4]
parts[0..2] = parts[0..2].map { |e| e.to_i }
@@ -48,12 +50,12 @@ module Puppet::String::StringCollection
end
def self.[](name, version)
- @strings[underscorize(name)][version] if string?(name, version)
+ @faces[underscorize(name)][version] if face?(name, version)
end
- def self.string?(name, version)
+ def self.face?(name, version)
name = underscorize(name)
- return true if @strings[name].has_key?(version)
+ return true if @faces[name].has_key?(version)
# We always load the current version file; the common case is that we have
# the expected version and any compatibility versions in the same file,
@@ -62,14 +64,14 @@ module Puppet::String::StringCollection
# We use require to avoid executing the code multiple times, like any
# other Ruby library that we might want to use. --daniel 2011-04-06
begin
- require "puppet/string/#{name}"
+ require "puppet/faces/#{name}"
# If we wanted :current, we need to index to find that; direct version
# requests just work™ as they go. --daniel 2011-04-06
if version == :current then
# We need to find current out of this. This is the largest version
# number that doesn't have a dedicated on-disk file present; those
- # represent "experimental" versions of strings, which we don't fully
+ # represent "experimental" versions of faces, which we don't fully
# support yet.
#
# We walk the versions from highest to lowest and take the first version
@@ -92,30 +94,30 @@ module Puppet::String::StringCollection
# versions here and return the last item in that set.
#
# --daniel 2011-04-06
- latest_ver = @strings[name].keys.sort {|a, b| cmp_versions(a, b) }.last
- @strings[name][:current] = @strings[name][latest_ver]
+ latest_ver = @faces[name].keys.sort {|a, b| cmp_semver(a, b) }.last
+ @faces[name][:current] = @faces[name][latest_ver]
end
rescue LoadError => e
- raise unless e.message =~ %r{-- puppet/string/#{name}$}
+ raise unless e.message =~ %r{-- puppet/faces/#{name}$}
# ...guess we didn't find the file; return a much better problem.
end
- # Now, either we have the version in our set of strings, or we didn't find
+ # Now, either we have the version in our set of faces, or we didn't find
# the version they were looking for. In the future we will support
# loading versioned stuff from some look-aside part of the Ruby load path,
# but we don't need that right now.
#
# So, this comment is a place-holder for that. --daniel 2011-04-06
- return !! @strings[name].has_key?(version)
+ return !! @faces[name].has_key?(version)
end
- def self.register(string)
- @strings[underscorize(string.name)][string.version] = string
+ def self.register(face)
+ @faces[underscorize(face.name)][face.version] = face
end
def self.underscorize(name)
unless name.to_s =~ /^[-_a-z]+$/i then
- raise ArgumentError, "#{name.inspect} (#{name.class}) is not a valid string name"
+ raise ArgumentError, "#{name.inspect} (#{name.class}) is not a valid face name"
end
name.to_s.downcase.split(/[-_]/).join('_').to_sym
diff --git a/lib/puppet/string/option.rb b/lib/puppet/interface/option.rb
index 352f7e5ef..ccc2fbba7 100644
--- a/lib/puppet/string/option.rb
+++ b/lib/puppet/interface/option.rb
@@ -1,6 +1,6 @@
-require 'puppet/string'
+require 'puppet/interface'
-class Puppet::String::Option
+class Puppet::Interface::Option
attr_reader :parent
attr_reader :name
attr_reader :aliases
@@ -65,8 +65,8 @@ class Puppet::String::Option
end
# to_s and optparse_to_name are roughly mirrored, because they are used to
- # transform strings to name symbols, and vice-versa. This isn't a full
- # bidirectional transformation though.
+ # transform options to name symbols, and vice-versa. This isn't a full
+ # bidirectional transformation though. --daniel 2011-04-07
def to_s
@name.to_s.tr('_', '-')
end
diff --git a/lib/puppet/interface/option_builder.rb b/lib/puppet/interface/option_builder.rb
new file mode 100644
index 000000000..83a1906b0
--- /dev/null
+++ b/lib/puppet/interface/option_builder.rb
@@ -0,0 +1,25 @@
+require 'puppet/interface/option'
+
+class Puppet::Interface::OptionBuilder
+ attr_reader :option
+
+ def self.build(face, *declaration, &block)
+ new(face, *declaration, &block).option
+ end
+
+ private
+ def initialize(face, *declaration, &block)
+ @face = face
+ @option = Puppet::Interface::Option.new(face, *declaration)
+ block and instance_eval(&block)
+ @option
+ end
+
+ # Metaprogram the simple DSL from the option class.
+ Puppet::Interface::Option.instance_methods.grep(/=$/).each do |setter|
+ next if setter =~ /^=/ # special case, darn it...
+
+ dsl = setter.sub(/=$/, '')
+ define_method(dsl) do |value| @option.send(setter, value) end
+ end
+end
diff --git a/lib/puppet/string/option_manager.rb b/lib/puppet/interface/option_manager.rb
index f952ad4f0..56df9760f 100644
--- a/lib/puppet/string/option_manager.rb
+++ b/lib/puppet/interface/option_manager.rb
@@ -1,10 +1,10 @@
-require 'puppet/string/option_builder'
+require 'puppet/interface/option_builder'
-module Puppet::String::OptionManager
+module Puppet::Interface::OptionManager
# Declare that this app can take a specific option, and provide
# the code to do so.
def option(*declaration, &block)
- add_option Puppet::String::OptionBuilder.build(self, *declaration, &block)
+ add_option Puppet::Interface::OptionBuilder.build(self, *declaration, &block)
end
def add_option(option)
diff --git a/lib/puppet/string/action_builder.rb b/lib/puppet/string/action_builder.rb
deleted file mode 100644
index e7c03273b..000000000
--- a/lib/puppet/string/action_builder.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-require 'puppet/string'
-require 'puppet/string/action'
-
-class Puppet::String::ActionBuilder
- attr_reader :action
-
- def self.build(string, name, &block)
- raise "Action #{name.inspect} must specify a block" unless block
- new(string, name, &block).action
- end
-
- private
- def initialize(string, name, &block)
- @string = string
- @action = Puppet::String::Action.new(string, name)
- instance_eval(&block)
- end
-
- # Ideally the method we're defining here would be added to the action, and a
- # method on the string would defer to it, but we can't get scope correct,
- # so we stick with this. --daniel 2011-03-24
- def when_invoked(&block)
- raise "when_invoked on an ActionBuilder with no corresponding Action" unless @action
- @action.when_invoked = block
- end
-
- def option(*declaration, &block)
- option = Puppet::String::OptionBuilder.build(@action, *declaration, &block)
- @action.add_option(option)
- end
-end
diff --git a/lib/puppet/string/certificate_request.rb b/lib/puppet/string/certificate_request.rb
deleted file mode 100644
index 218b40b98..000000000
--- a/lib/puppet/string/certificate_request.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'puppet/string/indirector'
-
-Puppet::String::Indirector.define(:certificate_request, '0.0.1') do
-end
diff --git a/lib/puppet/string/certificate_revocation_list.rb b/lib/puppet/string/certificate_revocation_list.rb
deleted file mode 100644
index 9731b4f2d..000000000
--- a/lib/puppet/string/certificate_revocation_list.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'puppet/string/indirector'
-
-Puppet::String::Indirector.define(:certificate_revocation_list, '0.0.1') do
-end
diff --git a/lib/puppet/string/configurer.rb b/lib/puppet/string/configurer.rb
deleted file mode 100644
index 257f97e90..000000000
--- a/lib/puppet/string/configurer.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-require 'puppet/string'
-
-Puppet::String.define(:configurer, '0.0.1') do
- action(:synchronize) do
- when_invoked do |certname, options|
- facts = Puppet::String[:facts, '0.0.1'].find(certname)
- catalog = Puppet::String[:catalog, '0.0.1'].download(certname, facts)
- report = Puppet::String[:catalog, '0.0.1'].apply(catalog)
- report
- end
- end
-end
diff --git a/lib/puppet/string/file.rb b/lib/puppet/string/file.rb
deleted file mode 100644
index cc5737f28..000000000
--- a/lib/puppet/string/file.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-require 'puppet/string/indirector'
-
-Puppet::String::Indirector.define(:file, '0.0.1') do
- set_indirection_name :file_bucket_file
-end
diff --git a/lib/puppet/string/key.rb b/lib/puppet/string/key.rb
deleted file mode 100644
index 95aceade5..000000000
--- a/lib/puppet/string/key.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'puppet/string/indirector'
-
-Puppet::String::Indirector.define(:key, '0.0.1') do
-end
diff --git a/lib/puppet/string/node.rb b/lib/puppet/string/node.rb
deleted file mode 100644
index bc31a2cf3..000000000
--- a/lib/puppet/string/node.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-require 'puppet/string/indirector'
-
-Puppet::String::Indirector.define(:node, '0.0.1') do
- set_default_format :yaml
-end
diff --git a/lib/puppet/string/option_builder.rb b/lib/puppet/string/option_builder.rb
deleted file mode 100644
index da0d213fb..000000000
--- a/lib/puppet/string/option_builder.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-require 'puppet/string/option'
-
-class Puppet::String::OptionBuilder
- attr_reader :option
-
- def self.build(string, *declaration, &block)
- new(string, *declaration, &block).option
- end
-
- private
- def initialize(string, *declaration, &block)
- @string = string
- @option = Puppet::String::Option.new(string, *declaration)
- block and instance_eval(&block)
- @option
- end
-
- # Metaprogram the simple DSL from the option class.
- Puppet::String::Option.instance_methods.grep(/=$/).each do |setter|
- next if setter =~ /^=/ # special case, darn it...
-
- dsl = setter.sub(/=$/, '')
- define_method(dsl) do |value| @option.send(setter, value) end
- end
-end
diff --git a/lib/puppet/string/resource.rb b/lib/puppet/string/resource.rb
deleted file mode 100644
index 9838be0fa..000000000
--- a/lib/puppet/string/resource.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'puppet/string/indirector'
-
-Puppet::String::Indirector.define(:resource, '0.0.1') do
-end
diff --git a/lib/puppet/string/resource_type.rb b/lib/puppet/string/resource_type.rb
deleted file mode 100644
index 8ca31ea6c..000000000
--- a/lib/puppet/string/resource_type.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'puppet/string/indirector'
-
-Puppet::String::Indirector.define(:resource_type, '0.0.1') do
-end
diff --git a/lib/puppet/string/status.rb b/lib/puppet/string/status.rb
deleted file mode 100644
index 41de2bb99..000000000
--- a/lib/puppet/string/status.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'puppet/string/indirector'
-
-Puppet::String::Indirector.define(:status, '0.0.1') do
-end