[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, experimental, updated. debian/2.6.8-1-844-g7ec39d5
Daniel Pittman
daniel at puppetlabs.com
Tue May 10 08:08:53 UTC 2011
The following commit has been merged in the experimental branch:
commit b859baa04737644e40002f511c5941d002a956e3
Author: Daniel Pittman <daniel at puppetlabs.com>
Date: Sat Mar 26 00:12:17 2011 -0700
MAINT: the API is officially named "string" as of this moment.
Now that we have settled on the final public name for the API,
"Puppet::String", mass-rename and mass-edit all the files to follow.
Reviewed-By: Randall Hansen <randall at puppetlabs.com>
diff --git a/lib/puppet/application/config.rb b/lib/puppet/application/config.rb
index 90c5f53..f655927 100644
--- a/lib/puppet/application/config.rb
+++ b/lib/puppet/application/config.rb
@@ -1,4 +1,4 @@
-require 'puppet/application/interface_base'
+require 'puppet/application/string_base'
-class Puppet::Application::Config < Puppet::Application::InterfaceBase
+class Puppet::Application::Config < Puppet::Application::StringBase
end
diff --git a/lib/puppet/application/configurer.rb b/lib/puppet/application/configurer.rb
index 5c9af37..b440098 100644
--- a/lib/puppet/application/configurer.rb
+++ b/lib/puppet/application/configurer.rb
@@ -1,5 +1,5 @@
require 'puppet/application'
-require 'puppet/interface'
+require 'puppet/string'
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::Interface[:configurer, '0.0.1'].synchronize(Puppet[:certname])
- Puppet::Interface[:report, '0.0.1'].submit(report)
+ report = Puppet::String[:configurer, '0.0.1'].synchronize(Puppet[:certname])
+ Puppet::String[:report, '0.0.1'].submit(report)
end
end
diff --git a/lib/puppet/application/indirection_base.rb b/lib/puppet/application/indirection_base.rb
index 7d1c851..da61f40 100644
--- a/lib/puppet/application/indirection_base.rb
+++ b/lib/puppet/application/indirection_base.rb
@@ -1,6 +1,6 @@
-require 'puppet/application/interface_base'
+require 'puppet/application/string_base'
-class Puppet::Application::IndirectionBase < Puppet::Application::InterfaceBase
+class Puppet::Application::IndirectionBase < Puppet::Application::StringBase
option("--terminus TERMINUS") do |arg|
@terminus = arg
end
@@ -10,10 +10,10 @@ class Puppet::Application::IndirectionBase < Puppet::Application::InterfaceBase
def setup
super
- if interface.respond_to?(:indirection)
- raise "Could not find data type #{type} for application #{self.class.name}" unless interface.indirection
+ if string.respond_to?(:indirection)
+ raise "Could not find data type #{type} for application #{self.class.name}" unless string.indirection
- interface.set_terminus(terminus) if terminus
+ string.set_terminus(terminus) if terminus
end
end
end
diff --git a/lib/puppet/application/interface.rb b/lib/puppet/application/string.rb
similarity index 83%
rename from lib/puppet/application/interface.rb
rename to lib/puppet/application/string.rb
index f447dc3..aa369e6 100644
--- a/lib/puppet/application/interface.rb
+++ b/lib/puppet/application/string.rb
@@ -1,7 +1,7 @@
require 'puppet/application'
-require 'puppet/interface'
+require 'puppet/string'
-class Puppet::Application::Interface < Puppet::Application
+class Puppet::Application::String < Puppet::Application
should_parse_config
run_mode :agent
@@ -18,7 +18,7 @@ class Puppet::Application::Interface < Puppet::Application
if arguments.empty?
arguments = %w{terminuses actions}
end
- interfaces.each do |name|
+ strings.each do |name|
str = "#{name}:\n"
if arguments.include?("terminuses")
begin
@@ -68,12 +68,12 @@ class Puppet::Application::Interface < Puppet::Application
end
unless respond_to?(verb)
- raise "Command '#{verb}' not found for 'interface'"
+ raise "Command '#{verb}' not found for 'string'"
end
end
- def interfaces
- Puppet::Interface.interfaces
+ def strings
+ Puppet::String.strings
end
def terminus_classes(indirection)
@@ -81,9 +81,9 @@ class Puppet::Application::Interface < Puppet::Application
end
def actions(indirection)
- return [] unless interface = Puppet::Interface[indirection, '0.0.1']
- interface.load_actions
- return interface.actions.sort { |a,b| a.to_s <=> b.to_s }
+ return [] unless string = Puppet::String[indirection, '0.0.1']
+ string.load_actions
+ return string.actions.sort { |a,b| a.to_s <=> b.to_s }
end
def load_applications
diff --git a/lib/puppet/application/interface_base.rb b/lib/puppet/application/string_base.rb
similarity index 71%
rename from lib/puppet/application/interface_base.rb
rename to lib/puppet/application/string_base.rb
index 841f3ca..5b70159 100644
--- a/lib/puppet/application/interface_base.rb
+++ b/lib/puppet/application/string_base.rb
@@ -1,14 +1,14 @@
require 'puppet/application'
-require 'puppet/interface'
+require 'puppet/string'
-class Puppet::Application::InterfaceBase < Puppet::Application
+class Puppet::Application::StringBase < Puppet::Application
should_parse_config
run_mode :agent
def preinit
super
trap(:INT) do
- $stderr.puts "Cancelling Interface"
+ $stderr.puts "Cancelling String"
exit(0)
end
end
@@ -32,7 +32,7 @@ class Puppet::Application::InterfaceBase < Puppet::Application
end
- attr_accessor :interface, :type, :verb, :arguments, :format
+ attr_accessor :string, :type, :verb, :arguments, :format
attr_writer :exit_code
# This allows you to set the exit code if you don't want to just exit
@@ -43,7 +43,7 @@ class Puppet::Application::InterfaceBase < Puppet::Application
def main
# Call the method associated with the provided action (e.g., 'find').
- if result = interface.send(verb, *arguments)
+ if result = string.send(verb, *arguments)
puts render(result)
end
exit(exit_code)
@@ -72,25 +72,25 @@ class Puppet::Application::InterfaceBase < Puppet::Application
@type = self.class.name.to_s.sub(/.+:/, '').downcase.to_sym
# TODO: These should be configurable versions.
- unless Puppet::Interface.interface?(@type, :latest)
- raise "Could not find any version of interface '#{@type}'"
+ unless Puppet::String.string?(@type, :latest)
+ raise "Could not find any version of string '#{@type}'"
end
- @interface = Puppet::Interface[@type, :latest]
- @format ||= @interface.default_format
+ @string = Puppet::String[@type, :latest]
+ @format ||= @string.default_format
- # We copy all of the app options to the interface.
+ # We copy all of the app options to the string.
# This allows each action to read in the options.
- @interface.options = options
+ @string.options = options
validate
end
def validate
unless verb
- raise "You must specify #{interface.actions.join(", ")} as a verb; 'save' probably does not work right now"
+ raise "You must specify #{string.actions.join(", ")} as a verb; 'save' probably does not work right now"
end
- unless interface.action?(verb)
+ unless string.action?(verb)
raise "Command '#{verb}' not found for #{type}"
end
end
diff --git a/lib/puppet/interface/action.rb b/lib/puppet/interface/action.rb
deleted file mode 100644
index 1a5730d..0000000
--- a/lib/puppet/interface/action.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-require 'puppet/interface'
-
-class Puppet::Interface::Action
- attr_reader :name
-
- def initialize(interface, name, attrs = {})
- name = name.to_s
- raise "'#{name}' is an invalid action name" unless name =~ /^[a-z]\w*$/
-
- @interface = interface
- @name = name
- attrs.each do |k,v| send("#{k}=", v) end
- end
-
- def invoke(*args, &block)
- @interface.method(name).call(*args,&block)
- end
-
- def invoke=(block)
- if @interface.is_a?(Class)
- @interface.define_method(@name, &block)
- else
- @interface.meta_def(@name, &block)
- end
- end
-end
diff --git a/lib/puppet/interface/v0.0.1/certificate_request.rb b/lib/puppet/interface/v0.0.1/certificate_request.rb
deleted file mode 100644
index e5ed1b5..0000000
--- a/lib/puppet/interface/v0.0.1/certificate_request.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'puppet/interface/indirector'
-
-Puppet::Interface::Indirector.define(:certificate_request, '0.0.1') do
-end
diff --git a/lib/puppet/interface/v0.0.1/certificate_revocation_list.rb b/lib/puppet/interface/v0.0.1/certificate_revocation_list.rb
deleted file mode 100644
index f6d8a3d..0000000
--- a/lib/puppet/interface/v0.0.1/certificate_revocation_list.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'puppet/interface/indirector'
-
-Puppet::Interface::Indirector.define(:certificate_revocation_list, '0.0.1') do
-end
diff --git a/lib/puppet/interface/v0.0.1/configurer.rb b/lib/puppet/interface/v0.0.1/configurer.rb
deleted file mode 100644
index 38536b6..0000000
--- a/lib/puppet/interface/v0.0.1/configurer.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-require 'puppet/interface'
-
-Puppet::Interface.define(:configurer, '0.0.1') do
- action(:synchronize) do
- invoke do |certname|
- facts = Puppet::Interface[:facts, '0.0.1'].find(certname)
- catalog = Puppet::Interface[:catalog, '0.0.1'].download(certname, facts)
- report = Puppet::Interface[:catalog, '0.0.1'].apply(catalog)
- report
- end
- end
-end
diff --git a/lib/puppet/interface/v0.0.1/file.rb b/lib/puppet/interface/v0.0.1/file.rb
deleted file mode 100644
index 91904e8..0000000
--- a/lib/puppet/interface/v0.0.1/file.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-require 'puppet/interface/indirector'
-
-Puppet::Interface::Indirector.define(:file, '0.0.1') do
- set_indirection_name :file_bucket_file
-end
diff --git a/lib/puppet/interface/v0.0.1/key.rb b/lib/puppet/interface/v0.0.1/key.rb
deleted file mode 100644
index fbc9b67..0000000
--- a/lib/puppet/interface/v0.0.1/key.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'puppet/interface/indirector'
-
-Puppet::Interface::Indirector.define(:key, '0.0.1') do
-end
diff --git a/lib/puppet/interface/v0.0.1/node.rb b/lib/puppet/interface/v0.0.1/node.rb
deleted file mode 100644
index 4ecec14..0000000
--- a/lib/puppet/interface/v0.0.1/node.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-require 'puppet/interface/indirector'
-
-Puppet::Interface::Indirector.define(:node, '0.0.1') do
- set_default_format :yaml
-end
diff --git a/lib/puppet/interface/v0.0.1/resource.rb b/lib/puppet/interface/v0.0.1/resource.rb
deleted file mode 100644
index 1a6f3b6..0000000
--- a/lib/puppet/interface/v0.0.1/resource.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'puppet/interface/indirector'
-
-Puppet::Interface::Indirector.define(:resource, '0.0.1') do
-end
diff --git a/lib/puppet/interface/v0.0.1/resource_type.rb b/lib/puppet/interface/v0.0.1/resource_type.rb
deleted file mode 100644
index 6f5547c..0000000
--- a/lib/puppet/interface/v0.0.1/resource_type.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'puppet/interface/indirector'
-
-Puppet::Interface::Indirector.define(:resource_type, '0.0.1') do
-end
diff --git a/lib/puppet/interface/v0.0.1/status.rb b/lib/puppet/interface/v0.0.1/status.rb
deleted file mode 100644
index 7f4b56a..0000000
--- a/lib/puppet/interface/v0.0.1/status.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'puppet/interface/indirector'
-
-Puppet::Interface::Indirector.define(:status, '0.0.1') do
-end
diff --git a/lib/puppet/interface.rb b/lib/puppet/string.rb
similarity index 55%
rename from lib/puppet/interface.rb
rename to lib/puppet/string.rb
index a667c6b..b5f7b90 100644
--- a/lib/puppet/interface.rb
+++ b/lib/puppet/string.rb
@@ -1,12 +1,12 @@
require 'puppet'
require 'puppet/util/autoload'
-class Puppet::Interface
- require 'puppet/interface/action_manager'
- require 'puppet/interface/interface_collection'
+class Puppet::String
+ require 'puppet/string/action_manager'
+ require 'puppet/string/string_collection'
- include Puppet::Interface::ActionManager
- extend Puppet::Interface::ActionManager
+ include Puppet::String::ActionManager
+ extend Puppet::String::ActionManager
include Puppet::Util
@@ -15,33 +15,33 @@ class Puppet::Interface
# 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/interface")
+ @autoloader ||= Puppet::Util::Autoload.new(:application, "puppet/string")
end
- def interfaces
- Puppet::Interface::InterfaceCollection.interfaces
+ def strings
+ Puppet::String::StringCollection.strings
end
- def interface?(name, version)
- Puppet::Interface::InterfaceCollection.interface?(name, version)
+ def string?(name, version)
+ Puppet::String::StringCollection.string?(name, version)
end
def register(instance)
- Puppet::Interface::InterfaceCollection.register(instance)
+ Puppet::String::StringCollection.register(instance)
end
def define(name, version, &block)
- if interface?(name, version)
- interface = Puppet::Interface::InterfaceCollection[name, version]
+ if string?(name, version)
+ string = Puppet::String::StringCollection[name, version]
else
- interface = self.new(name, version)
- Puppet::Interface::InterfaceCollection.register(interface)
- interface.load_actions
+ string = self.new(name, version)
+ Puppet::String::StringCollection.register(string)
+ string.load_actions
end
- interface.instance_eval(&block) if block_given?
+ string.instance_eval(&block) if block_given?
- return interface
+ return string
end
alias :[] :define
@@ -57,11 +57,11 @@ class Puppet::Interface
attr_reader :name
def initialize(name, version, &block)
- unless Puppet::Interface::InterfaceCollection.validate_version(version)
- raise ArgumentError, "Cannot create interface with invalid version number '#{version}'!"
+ unless Puppet::String::StringCollection.validate_version(version)
+ raise ArgumentError, "Cannot create string with invalid version number '#{version}'!"
end
- @name = Puppet::Interface::InterfaceCollection.underscorize(name)
+ @name = Puppet::String::StringCollection.underscorize(name)
@version = version
@default_format = :pson
@@ -70,10 +70,10 @@ class Puppet::Interface
# Try to find actions defined in other files.
def load_actions
- path = "puppet/interface/v#{version}/#{name}"
+ path = "puppet/string/v#{version}/#{name}"
loaded = []
- Puppet::Interface.autoloader.search_directories.each do |dir|
+ Puppet::String.autoloader.search_directories.each do |dir|
fdir = ::File.join(dir, path)
next unless FileTest.directory?(fdir)
@@ -93,6 +93,6 @@ class Puppet::Interface
end
def to_s
- "Puppet::Interface[#{name.inspect}, #{version.inspect}]"
+ "Puppet::String[#{name.inspect}, #{version.inspect}]"
end
end
diff --git a/lib/puppet/string/action.rb b/lib/puppet/string/action.rb
new file mode 100644
index 0000000..4db9e97
--- /dev/null
+++ b/lib/puppet/string/action.rb
@@ -0,0 +1,26 @@
+require 'puppet/string'
+
+class Puppet::String::Action
+ attr_reader :name
+
+ def initialize(string, name, attrs = {})
+ name = name.to_s
+ raise "'#{name}' is an invalid action name" unless name =~ /^[a-z]\w*$/
+
+ @string = string
+ @name = name
+ attrs.each do |k,v| send("#{k}=", v) end
+ end
+
+ def invoke(*args, &block)
+ @string.method(name).call(*args,&block)
+ end
+
+ def invoke=(block)
+ if @string.is_a?(Class)
+ @string.define_method(@name, &block)
+ else
+ @string.meta_def(@name, &block)
+ end
+ end
+end
diff --git a/lib/puppet/interface/action_builder.rb b/lib/puppet/string/action_builder.rb
similarity index 52%
rename from lib/puppet/interface/action_builder.rb
rename to lib/puppet/string/action_builder.rb
index e389ea3..b3db511 100644
--- a/lib/puppet/interface/action_builder.rb
+++ b/lib/puppet/string/action_builder.rb
@@ -1,24 +1,24 @@
-require 'puppet/interface'
-require 'puppet/interface/action'
+require 'puppet/string'
+require 'puppet/string/action'
-class Puppet::Interface::ActionBuilder
+class Puppet::String::ActionBuilder
attr_reader :action
- def self.build(interface, name, &block)
+ def self.build(string, name, &block)
name = name.to_s
raise "Action '#{name}' must specify a block" unless block
- builder = new(interface, name, &block)
+ builder = new(string, name, &block)
builder.action
end
- def initialize(interface, name, &block)
- @interface = interface
- @action = Puppet::Interface::Action.new(interface, name)
+ 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 interface would defer to it, but we can't get scope correct,
+ # 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 invoke(&block)
raise "Invoke called on an ActionBuilder with no corresponding Action" unless @action
diff --git a/lib/puppet/interface/action_manager.rb b/lib/puppet/string/action_manager.rb
similarity index 80%
rename from lib/puppet/interface/action_manager.rb
rename to lib/puppet/string/action_manager.rb
index 8b2944b..c29dbf4 100644
--- a/lib/puppet/interface/action_manager.rb
+++ b/lib/puppet/string/action_manager.rb
@@ -1,6 +1,6 @@
-require 'puppet/interface/action_builder'
+require 'puppet/string/action_builder'
-module Puppet::Interface::ActionManager
+module Puppet::String::ActionManager
# Declare that this app can take a specific action, and provide
# the code to do so.
def action(name, &block)
@@ -9,7 +9,7 @@ module Puppet::Interface::ActionManager
raise "Action #{name} already defined for #{self}" if action?(name)
- action = Puppet::Interface::ActionBuilder.build(self, name, &block)
+ action = Puppet::String::ActionBuilder.build(self, name, &block)
@actions[name] = action
end
@@ -20,7 +20,7 @@ module Puppet::Interface::ActionManager
@actions ||= {}
name = name.to_s.downcase.to_sym
raise "Action #{name} already defined for #{self}" if action?(name)
- @actions[name] = Puppet::Interface::Action.new(self, name, :invoke => block)
+ @actions[name] = Puppet::String::Action.new(self, name, :invoke => block)
end
def actions
diff --git a/lib/puppet/interface/indirector.rb b/lib/puppet/string/indirector.rb
similarity index 90%
rename from lib/puppet/interface/indirector.rb
rename to lib/puppet/string/indirector.rb
index 485af47..15984e3 100644
--- a/lib/puppet/interface/indirector.rb
+++ b/lib/puppet/string/indirector.rb
@@ -1,7 +1,7 @@
require 'puppet'
-require 'puppet/interface'
+require 'puppet/string'
-class Puppet::Interface::Indirector < Puppet::Interface
+class Puppet::String::Indirector < Puppet::String
def self.indirections
Puppet::Indirector::Indirection.instances.collect { |t| t.to_s }.sort
end
@@ -44,12 +44,12 @@ class Puppet::Interface::Indirector < Puppet::Interface
end
# Here's your opportunity to override the indirection name. By default
- # it will be the same name as the interface.
+ # it will be the same name as the string.
def set_indirection_name(name)
@indirection_name = name
end
- # Return an indirection associated with an interface, if one exists
+ # Return an indirection associated with an string, if one exists
# One usually does.
def indirection
unless @indirection
diff --git a/lib/puppet/interface/interface_collection.rb b/lib/puppet/string/string_collection.rb
similarity index 71%
rename from lib/puppet/interface/interface_collection.rb
rename to lib/puppet/string/string_collection.rb
index 92e2933..e9cba7f 100644
--- a/lib/puppet/interface/interface_collection.rb
+++ b/lib/puppet/string/string_collection.rb
@@ -1,17 +1,17 @@
-require 'puppet/interface'
+require 'puppet/string'
-module Puppet::Interface::InterfaceCollection
+module Puppet::String::StringCollection
SEMVER_VERSION = /^(\d+)\.(\d+)\.(\d+)([A-Za-z][0-9A-Za-z-]*|)$/
- @interfaces = Hash.new { |hash, key| hash[key] = {} }
+ @strings = Hash.new { |hash, key| hash[key] = {} }
- def self.interfaces
+ def self.strings
unless @loaded
@loaded = true
$LOAD_PATH.each do |dir|
next unless FileTest.directory?(dir)
Dir.chdir(dir) do
- Dir.glob("puppet/interface/v*/*.rb").collect { |f| f.sub(/\.rb/, '') }.each do |file|
+ Dir.glob("puppet/string/v*/*.rb").collect { |f| f.sub(/\.rb/, '') }.each do |file|
iname = file.sub(/\.rb/, '')
begin
require iname
@@ -23,14 +23,14 @@ module Puppet::Interface::InterfaceCollection
end
end
end
- return @interfaces.keys
+ return @strings.keys
end
def self.versions(name)
versions = []
$LOAD_PATH.each do |dir|
next unless FileTest.directory?(dir)
- v_dir = File.join dir, %w[puppet interface v*]
+ v_dir = File.join dir, %w[puppet string v*]
Dir.glob(File.join v_dir, "#{name}{.rb,/*.rb}").each do |f|
v = f.sub(%r[.*/v([^/]+?)/#{name}(?:(?:/[^/]+)?.rb)$], '\1')
if validate_version(v)
@@ -66,31 +66,31 @@ module Puppet::Interface::InterfaceCollection
def self.[](name, version)
version = versions(name).last if version == :latest
unless version.nil?
- @interfaces[underscorize(name)][version] if interface?(name, version)
+ @strings[underscorize(name)][version] if string?(name, version)
end
end
- def self.interface?(name, version)
+ def self.string?(name, version)
version = versions(name).last if version == :latest
return false if version.nil?
name = underscorize(name)
- unless @interfaces.has_key?(name) && @interfaces[name].has_key?(version)
- require "puppet/interface/v#{version}/#{name}"
+ unless @strings.has_key?(name) && @strings[name].has_key?(version)
+ require "puppet/string/v#{version}/#{name}"
end
- return @interfaces.has_key?(name) && @interfaces[name].has_key?(version)
+ return @strings.has_key?(name) && @strings[name].has_key?(version)
rescue LoadError
return false
end
- def self.register(interface)
- @interfaces[underscorize(interface.name)][interface.version] = interface
+ def self.register(string)
+ @strings[underscorize(string.name)][string.version] = string
end
def self.underscorize(name)
unless name.to_s =~ /^[-_a-z]+$/i then
- raise ArgumentError, "#{name.inspect} (#{name.class}) is not a valid interface name"
+ raise ArgumentError, "#{name.inspect} (#{name.class}) is not a valid string name"
end
name.to_s.downcase.split(/[-_]/).join('_').to_sym
diff --git a/lib/puppet/interface/v0.0.1/catalog.rb b/lib/puppet/string/v0.0.1/catalog.rb
similarity index 84%
rename from lib/puppet/interface/v0.0.1/catalog.rb
rename to lib/puppet/string/v0.0.1/catalog.rb
index 7d61528..0ddd831 100644
--- a/lib/puppet/interface/v0.0.1/catalog.rb
+++ b/lib/puppet/string/v0.0.1/catalog.rb
@@ -1,6 +1,6 @@
-require 'puppet/interface/indirector'
+require 'puppet/string/indirector'
-Puppet::Interface::Indirector.define(:catalog, '0.0.1') do
+Puppet::String::Indirector.define(:catalog, '0.0.1') do
action(:apply) do
invoke do |catalog|
report = Puppet::Transaction::Report.new("apply")
@@ -28,7 +28,7 @@ Puppet::Interface::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::Interface[:catalog, '0.0.1'].find(certname, facts_to_upload)
+ catalog = Puppet::String[:catalog, '0.0.1'].find(certname, facts_to_upload)
end
catalog = catalog.to_ral
catalog.finalize
diff --git a/lib/puppet/interface/v0.0.1/catalog/select.rb b/lib/puppet/string/v0.0.1/catalog/select.rb
similarity index 85%
rename from lib/puppet/interface/v0.0.1/catalog/select.rb
rename to lib/puppet/string/v0.0.1/catalog/select.rb
index 35f1a1e..52c77d3 100644
--- a/lib/puppet/interface/v0.0.1/catalog/select.rb
+++ b/lib/puppet/string/v0.0.1/catalog/select.rb
@@ -1,5 +1,5 @@
# Select and show a list of resources of a given type.
-Puppet::Interface.define(:catalog, '0.0.1') do
+Puppet::String.define(:catalog, '0.0.1') do
action :select do
invoke do |host,type|
catalog = Puppet::Resource::Catalog.indirection.find(host)
diff --git a/lib/puppet/interface/v0.0.1/certificate.rb b/lib/puppet/string/v0.0.1/certificate.rb
similarity index 84%
rename from lib/puppet/interface/v0.0.1/certificate.rb
rename to lib/puppet/string/v0.0.1/certificate.rb
index 2615e3d..7b2e5f3 100644
--- a/lib/puppet/interface/v0.0.1/certificate.rb
+++ b/lib/puppet/string/v0.0.1/certificate.rb
@@ -1,7 +1,7 @@
-require 'puppet/interface/indirector'
+require 'puppet/string/indirector'
require 'puppet/ssl/host'
-Puppet::Interface::Indirector.define(:certificate, '0.0.1') do
+Puppet::String::Indirector.define(:certificate, '0.0.1') do
action :generate do
invoke do |name|
diff --git a/lib/puppet/string/v0.0.1/certificate_request.rb b/lib/puppet/string/v0.0.1/certificate_request.rb
new file mode 100644
index 0000000..218b40b
--- /dev/null
+++ b/lib/puppet/string/v0.0.1/certificate_request.rb
@@ -0,0 +1,4 @@
+require 'puppet/string/indirector'
+
+Puppet::String::Indirector.define(:certificate_request, '0.0.1') do
+end
diff --git a/lib/puppet/string/v0.0.1/certificate_revocation_list.rb b/lib/puppet/string/v0.0.1/certificate_revocation_list.rb
new file mode 100644
index 0000000..9731b4f
--- /dev/null
+++ b/lib/puppet/string/v0.0.1/certificate_revocation_list.rb
@@ -0,0 +1,4 @@
+require 'puppet/string/indirector'
+
+Puppet::String::Indirector.define(:certificate_revocation_list, '0.0.1') do
+end
diff --git a/lib/puppet/interface/v0.0.1/config.rb b/lib/puppet/string/v0.0.1/config.rb
similarity index 69%
rename from lib/puppet/interface/v0.0.1/config.rb
rename to lib/puppet/string/v0.0.1/config.rb
index 7b74ce5..ae1a408 100644
--- a/lib/puppet/interface/v0.0.1/config.rb
+++ b/lib/puppet/string/v0.0.1/config.rb
@@ -1,6 +1,6 @@
-require 'puppet/interface'
+require 'puppet/string'
-Puppet::Interface.define(:config, '0.0.1') do
+Puppet::String.define(:config, '0.0.1') do
action(:print) do
invoke do |*args|
Puppet.settings[:configprint] = args.join(",")
diff --git a/lib/puppet/string/v0.0.1/configurer.rb b/lib/puppet/string/v0.0.1/configurer.rb
new file mode 100644
index 0000000..a6ea74b
--- /dev/null
+++ b/lib/puppet/string/v0.0.1/configurer.rb
@@ -0,0 +1,12 @@
+require 'puppet/string'
+
+Puppet::String.define(:configurer, '0.0.1') do
+ action(:synchronize) do
+ invoke do |certname|
+ 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/interface/v0.0.1/facts.rb b/lib/puppet/string/v0.0.1/facts.rb
similarity index 83%
rename from lib/puppet/interface/v0.0.1/facts.rb
rename to lib/puppet/string/v0.0.1/facts.rb
index c4bbad8..73acb0d 100644
--- a/lib/puppet/interface/v0.0.1/facts.rb
+++ b/lib/puppet/string/v0.0.1/facts.rb
@@ -1,7 +1,7 @@
-require 'puppet/interface/indirector'
+require 'puppet/string/indirector'
require 'puppet/node/facts'
-Puppet::Interface::Indirector.define(:facts, '0.0.1') do
+Puppet::String::Indirector.define(:facts, '0.0.1') do
set_default_format :yaml
# Upload our facts to the server
diff --git a/lib/puppet/string/v0.0.1/file.rb b/lib/puppet/string/v0.0.1/file.rb
new file mode 100644
index 0000000..cc5737f
--- /dev/null
+++ b/lib/puppet/string/v0.0.1/file.rb
@@ -0,0 +1,5 @@
+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/v0.0.1/key.rb b/lib/puppet/string/v0.0.1/key.rb
new file mode 100644
index 0000000..95acead
--- /dev/null
+++ b/lib/puppet/string/v0.0.1/key.rb
@@ -0,0 +1,4 @@
+require 'puppet/string/indirector'
+
+Puppet::String::Indirector.define(:key, '0.0.1') do
+end
diff --git a/lib/puppet/string/v0.0.1/node.rb b/lib/puppet/string/v0.0.1/node.rb
new file mode 100644
index 0000000..bc31a2c
--- /dev/null
+++ b/lib/puppet/string/v0.0.1/node.rb
@@ -0,0 +1,5 @@
+require 'puppet/string/indirector'
+
+Puppet::String::Indirector.define(:node, '0.0.1') do
+ set_default_format :yaml
+end
diff --git a/lib/puppet/interface/v0.0.1/report.rb b/lib/puppet/string/v0.0.1/report.rb
similarity index 75%
rename from lib/puppet/interface/v0.0.1/report.rb
rename to lib/puppet/string/v0.0.1/report.rb
index bacb46e..55a0085 100644
--- a/lib/puppet/interface/v0.0.1/report.rb
+++ b/lib/puppet/string/v0.0.1/report.rb
@@ -1,6 +1,6 @@
-require 'puppet/interface/indirector'
+require 'puppet/string/indirector'
-Puppet::Interface::Indirector.define(:report, '0.0.1') do
+Puppet::String::Indirector.define(:report, '0.0.1') do
action(:submit) do
invoke do |report|
begin
diff --git a/lib/puppet/string/v0.0.1/resource.rb b/lib/puppet/string/v0.0.1/resource.rb
new file mode 100644
index 0000000..9838be0
--- /dev/null
+++ b/lib/puppet/string/v0.0.1/resource.rb
@@ -0,0 +1,4 @@
+require 'puppet/string/indirector'
+
+Puppet::String::Indirector.define(:resource, '0.0.1') do
+end
diff --git a/lib/puppet/string/v0.0.1/resource_type.rb b/lib/puppet/string/v0.0.1/resource_type.rb
new file mode 100644
index 0000000..8ca31ea
--- /dev/null
+++ b/lib/puppet/string/v0.0.1/resource_type.rb
@@ -0,0 +1,4 @@
+require 'puppet/string/indirector'
+
+Puppet::String::Indirector.define(:resource_type, '0.0.1') do
+end
diff --git a/lib/puppet/string/v0.0.1/status.rb b/lib/puppet/string/v0.0.1/status.rb
new file mode 100644
index 0000000..41de2bb
--- /dev/null
+++ b/lib/puppet/string/v0.0.1/status.rb
@@ -0,0 +1,4 @@
+require 'puppet/string/indirector'
+
+Puppet::String::Indirector.define(:status, '0.0.1') do
+end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index c329c12..4e54d72 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(dir, dir + 'lib', dir + '../lib')
require 'mocha'
require 'puppet'
-require 'puppet/interface'
+require 'puppet/string'
require 'rspec'
RSpec.configure do |config|
diff --git a/spec/unit/application/config_spec.rb b/spec/unit/application/config_spec.rb
old mode 100644
new mode 100755
index 3d894a8..a45adc8
--- a/spec/unit/application/config_spec.rb
+++ b/spec/unit/application/config_spec.rb
@@ -4,7 +4,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
require 'puppet/application/config'
describe Puppet::Application::Config do
- it "should be a subclass of Puppet::Application::InterfaceBase" do
- Puppet::Application::Config.superclass.should equal(Puppet::Application::InterfaceBase)
+ it "should be a subclass of Puppet::Application::StringBase" do
+ Puppet::Application::Config.superclass.should equal(Puppet::Application::StringBase)
end
end
diff --git a/spec/unit/application/indirection_base_spec.rb b/spec/unit/application/indirection_base_spec.rb
old mode 100644
new mode 100755
index 2e7bd65..ecc49d9
--- a/spec/unit/application/indirection_base_spec.rb
+++ b/spec/unit/application/indirection_base_spec.rb
@@ -7,6 +7,6 @@ describe Puppet::Application::IndirectionBase do
it "should support a 'from' terminus"
describe "setup" do
- it "should fail if its interface does not support an indirection"
+ it "should fail if its string does not support an indirection"
end
end
diff --git a/spec/unit/application/interface_spec.rb b/spec/unit/application/interface_spec.rb
deleted file mode 100644
index 153e9bd..0000000
--- a/spec/unit/application/interface_spec.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
-require 'puppet/application/interface'
-
-describe Puppet::Application::Interface do
- it "should be an application" do
- Puppet::Application::Interface.superclass.should equal(Puppet::Application)
- end
-end
diff --git a/spec/unit/application/interface_base_spec.rb b/spec/unit/application/string_base_spec.rb
old mode 100644
new mode 100755
similarity index 60%
rename from spec/unit/application/interface_base_spec.rb
rename to spec/unit/application/string_base_spec.rb
index d82325b..bc563e1
--- a/spec/unit/application/interface_base_spec.rb
+++ b/spec/unit/application/string_base_spec.rb
@@ -1,14 +1,14 @@
#!/usr/bin/env ruby
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
-require 'puppet/application/interface_base'
+require 'puppet/application/string_base'
-describe Puppet::Application::InterfaceBase do
+describe Puppet::Application::StringBase do
before :all do
@dir = Dir.mktmpdir
$LOAD_PATH.push(@dir)
- FileUtils.mkdir_p(File.join @dir, 'puppet', 'interface', 'v0.0.1')
- FileUtils.touch(File.join @dir, 'puppet', 'interface', 'v0.0.1', 'basetest.rb')
+ FileUtils.mkdir_p(File.join @dir, 'puppet', 'string', 'v0.0.1')
+ FileUtils.touch(File.join @dir, 'puppet', 'string', 'v0.0.1', 'basetest.rb')
end
after :all do
@@ -16,13 +16,13 @@ describe Puppet::Application::InterfaceBase do
$LOAD_PATH.pop
end
- base_interface = Puppet::Interface.define(:basetest, '0.0.1')
- class Puppet::Application::InterfaceBase::Basetest < Puppet::Application::InterfaceBase
+ base_string = Puppet::String.define(:basetest, '0.0.1')
+ class Puppet::Application::StringBase::Basetest < Puppet::Application::StringBase
end
before do
- @app = Puppet::Application::InterfaceBase::Basetest.new
- @app.stubs(:interface).returns base_interface
+ @app = Puppet::Application::StringBase::Basetest.new
+ @app.stubs(:string).returns base_string
@app.stubs(:exit)
@app.stubs(:puts)
Puppet::Util::Log.stubs(:newdestination)
@@ -32,11 +32,11 @@ describe Puppet::Application::InterfaceBase do
before do
@app.verb = :find
@app.arguments = ["myname", "myarg"]
- @app.interface.stubs(:find)
+ @app.string.stubs(:find)
end
- it "should send the specified verb and name to the interface" do
- @app.interface.expects(:find).with("myname", "myarg")
+ it "should send the specified verb and name to the string" do
+ @app.string.expects(:find).with("myname", "myarg")
@app.main
end
@@ -63,11 +63,11 @@ describe Puppet::Application::InterfaceBase do
@app.arguments.should == ["myname", "myarg"]
end
- it "should set the options on the interface" do
+ it "should set the options on the string" do
@app.options[:foo] = "bar"
@app.setup
- @app.interface.options.should == @app.options
+ @app.string.options.should == @app.options
end
end
end
diff --git a/spec/unit/application/string_spec.rb b/spec/unit/application/string_spec.rb
new file mode 100755
index 0000000..13af0a5
--- /dev/null
+++ b/spec/unit/application/string_spec.rb
@@ -0,0 +1,10 @@
+#!/usr/bin/env ruby
+
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
+require 'puppet/application/string'
+
+describe Puppet::Application::String do
+ it "should be an application" do
+ Puppet::Application::String.superclass.should equal(Puppet::Application)
+ end
+end
diff --git a/spec/unit/interface/action_builder_spec.rb b/spec/unit/interface/action_builder_spec.rb
deleted file mode 100644
index 27e817f..0000000
--- a/spec/unit/interface/action_builder_spec.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
-require 'puppet/interface/action_builder'
-
-describe Puppet::Interface::ActionBuilder do
- describe "::build" do
- it "should build an action" do
- action = Puppet::Interface::ActionBuilder.build(nil,:foo) do
- end
- action.should be_a(Puppet::Interface::Action)
- action.name.should == "foo"
- end
-
- it "should define a method on the interface which invokes the action" do
- interface = Puppet::Interface.new(:action_builder_test_interface, '0.0.1')
- action = Puppet::Interface::ActionBuilder.build(interface, :foo) do
- invoke do
- "invoked the method"
- end
- end
-
- interface.foo.should == "invoked the method"
- end
-
- it "should require a block" do
- lambda { Puppet::Interface::ActionBuilder.build(nil,:foo) }.should raise_error("Action 'foo' must specify a block")
- end
- end
-end
diff --git a/spec/unit/interface/certificate_revocation_list_spec.rb b/spec/unit/interface/certificate_revocation_list_spec.rb
deleted file mode 100644
index 9655dd3..0000000
--- a/spec/unit/interface/certificate_revocation_list_spec.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
-
-describe Puppet::Interface.define(:certificate_revocation_list, '0.0.1') do
-end
diff --git a/spec/unit/interface/resource_spec.rb b/spec/unit/interface/resource_spec.rb
deleted file mode 100644
index 408be25..0000000
--- a/spec/unit/interface/resource_spec.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
-
-describe Puppet::Interface.define(:resource, '0.0.1') do
-end
diff --git a/spec/unit/interface/resource_type_spec.rb b/spec/unit/interface/resource_type_spec.rb
deleted file mode 100644
index 860be28..0000000
--- a/spec/unit/interface/resource_type_spec.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
-
-describe Puppet::Interface.define(:resource_type, '0.0.1') do
-end
diff --git a/spec/unit/interface_spec.rb b/spec/unit/interface_spec.rb
deleted file mode 100755
index cf7d209..0000000
--- a/spec/unit/interface_spec.rb
+++ /dev/null
@@ -1,83 +0,0 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')
-
-describe Puppet::Interface do
- before :all do
- @interfaces = Puppet::Interface::InterfaceCollection.instance_variable_get("@interfaces").dup
- end
-
- before :each do
- Puppet::Interface::InterfaceCollection.instance_variable_get("@interfaces").clear
- end
-
- after :all do
- Puppet::Interface::InterfaceCollection.instance_variable_set("@interfaces", @interfaces)
- end
-
- describe "#define" do
- it "should register the interface" do
- interface = Puppet::Interface.define(:interface_test_register, '0.0.1')
- interface.should == Puppet::Interface[:interface_test_register, '0.0.1']
- end
-
- it "should load actions" do
- Puppet::Interface.any_instance.expects(:load_actions)
- Puppet::Interface.define(:interface_test_load_actions, '0.0.1')
- end
-
- it "should require a version number" do
- proc { Puppet::Interface.define(:no_version) }.should raise_error(ArgumentError)
- end
- end
-
- describe "#initialize" do
- it "should require a version number" do
- proc { Puppet::Interface.new(:no_version) }.should raise_error(ArgumentError)
- end
-
- it "should require a valid version number" do
- proc { Puppet::Interface.new(:bad_version, 'Rasins') }.should raise_error(ArgumentError)
- end
-
- it "should instance-eval any provided block" do
- face = Puppet::Interface.new(:interface_test_block,'0.0.1') do
- action(:something) do
- invoke { "foo" }
- end
- end
-
- face.something.should == "foo"
- end
- end
-
- it "should have a name" do
- Puppet::Interface.new(:me,'0.0.1').name.should == :me
- end
-
- it "should stringify with its own name" do
- Puppet::Interface.new(:me,'0.0.1').to_s.should =~ /\bme\b/
- end
-
- it "should allow overriding of the default format" do
- face = Puppet::Interface.new(:me,'0.0.1')
- face.set_default_format :foo
- face.default_format.should == :foo
- end
-
- it "should default to :pson for its format" do
- Puppet::Interface.new(:me, '0.0.1').default_format.should == :pson
- end
-
- # Why?
- it "should create a class-level autoloader" do
- Puppet::Interface.autoloader.should be_instance_of(Puppet::Util::Autoload)
- end
-
- it "should try to require interfaces that are not known" do
- Puppet::Interface::InterfaceCollection.expects(:require).with "puppet/interface/v0.0.1/foo"
- Puppet::Interface[:foo, '0.0.1']
- end
-
- it "should be able to load all actions in all search paths"
-end
diff --git a/spec/unit/string/action_builder_spec.rb b/spec/unit/string/action_builder_spec.rb
new file mode 100755
index 0000000..c3395cf
--- /dev/null
+++ b/spec/unit/string/action_builder_spec.rb
@@ -0,0 +1,30 @@
+#!/usr/bin/env ruby
+
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
+require 'puppet/string/action_builder'
+
+describe Puppet::String::ActionBuilder do
+ describe "::build" do
+ it "should build an action" do
+ action = Puppet::String::ActionBuilder.build(nil,:foo) do
+ end
+ action.should be_a(Puppet::String::Action)
+ action.name.should == "foo"
+ end
+
+ it "should define a method on the string which invokes the action" do
+ string = Puppet::String.new(:action_builder_test_string, '0.0.1')
+ action = Puppet::String::ActionBuilder.build(string, :foo) do
+ invoke do
+ "invoked the method"
+ end
+ end
+
+ string.foo.should == "invoked the method"
+ end
+
+ it "should require a block" do
+ lambda { Puppet::String::ActionBuilder.build(nil,:foo) }.should raise_error("Action 'foo' must specify a block")
+ end
+ end
+end
diff --git a/spec/unit/interface/action_manager_spec.rb b/spec/unit/string/action_manager_spec.rb
similarity index 93%
rename from spec/unit/interface/action_manager_spec.rb
rename to spec/unit/string/action_manager_spec.rb
index 3aff7ac..3921f02 100755
--- a/spec/unit/interface/action_manager_spec.rb
+++ b/spec/unit/string/action_manager_spec.rb
@@ -2,14 +2,14 @@
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
-# This is entirely an internal class for Interface, so we have to load it instead of our class.
-require 'puppet/interface'
+# This is entirely an internal class for String, so we have to load it instead of our class.
+require 'puppet/string'
class ActionManagerTester
- include Puppet::Interface::ActionManager
+ include Puppet::String::ActionManager
end
-describe Puppet::Interface::ActionManager do
+describe Puppet::String::ActionManager do
subject { ActionManagerTester.new }
describe "when included in a class" do
@@ -73,7 +73,7 @@ describe Puppet::Interface::ActionManager do
end
describe "when used to extend a class" do
- subject { Class.new.extend(Puppet::Interface::ActionManager) }
+ subject { Class.new.extend(Puppet::String::ActionManager) }
it "should be able to define an action" do
subject.action(:foo) do
@@ -102,8 +102,8 @@ describe Puppet::Interface::ActionManager do
describe "when used both at the class and instance level" do
before do
@klass = Class.new do
- include Puppet::Interface::ActionManager
- extend Puppet::Interface::ActionManager
+ include Puppet::String::ActionManager
+ extend Puppet::String::ActionManager
end
@instance = @klass.new
end
diff --git a/spec/unit/interface/action_spec.rb b/spec/unit/string/action_spec.rb
old mode 100644
new mode 100755
similarity index 54%
rename from spec/unit/interface/action_spec.rb
rename to spec/unit/string/action_spec.rb
index 292caab..4026c9a
--- a/spec/unit/interface/action_spec.rb
+++ b/spec/unit/string/action_spec.rb
@@ -1,30 +1,30 @@
#!/usr/bin/env ruby
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
-require 'puppet/interface/action'
+require 'puppet/string/action'
-describe Puppet::Interface::Action do
+describe Puppet::String::Action do
describe "when validating the action name" do
it "should require a name" do
- lambda { Puppet::Interface::Action.new(nil,nil) }.should raise_error("'' is an invalid action name")
+ lambda { Puppet::String::Action.new(nil,nil) }.should raise_error("'' is an invalid action name")
end
it "should not allow empty names" do
- lambda { Puppet::Interface::Action.new(nil,'') }.should raise_error("'' is an invalid action name")
+ lambda { Puppet::String::Action.new(nil,'') }.should raise_error("'' is an invalid action name")
end
it "should not allow names with whitespace" do
- lambda { Puppet::Interface::Action.new(nil,'foo bar') }.should raise_error("'foo bar' is an invalid action name")
+ lambda { Puppet::String::Action.new(nil,'foo bar') }.should raise_error("'foo bar' is an invalid action name")
end
it "should not allow names beginning with dashes" do
- lambda { Puppet::Interface::Action.new(nil,'-foobar') }.should raise_error("'-foobar' is an invalid action name")
+ lambda { Puppet::String::Action.new(nil,'-foobar') }.should raise_error("'-foobar' is an invalid action name")
end
end
describe "when invoking" do
it "should be able to call other actions on the same object" do
- interface = Puppet::Interface.new(:my_interface, '0.0.1') do
+ string = Puppet::String.new(:my_string, '0.0.1') do
action(:foo) do
invoke { 25 }
end
@@ -33,8 +33,8 @@ describe Puppet::Interface::Action do
invoke { "the value of foo is '#{foo}'" }
end
end
- interface.foo.should == 25
- interface.bar.should == "the value of foo is '25'"
+ string.foo.should == 25
+ string.bar.should == "the value of foo is '25'"
end
# bar is a class action calling a class action
@@ -42,7 +42,7 @@ describe Puppet::Interface::Action do
# baz is an instance action calling a class action
# qux is an instance action calling an instance action
it "should be able to call other actions on the same object when defined on a class" do
- class Puppet::Interface::MyInterfaceBaseClass < Puppet::Interface
+ class Puppet::String::MyStringBaseClass < Puppet::String
action(:foo) do
invoke { 25 }
end
@@ -56,7 +56,7 @@ describe Puppet::Interface::Action do
end
end
- interface = Puppet::Interface::MyInterfaceBaseClass.new(:my_inherited_interface, '0.0.1') do
+ string = Puppet::String::MyStringBaseClass.new(:my_inherited_string, '0.0.1') do
action(:baz) do
invoke { "the value of foo in baz is '#{foo}'" }
end
@@ -65,11 +65,11 @@ describe Puppet::Interface::Action do
invoke { baz }
end
end
- interface.foo.should == 25
- interface.bar.should == "the value of foo is '25'"
- interface.quux.should == "qux told me the value of foo in baz is '25'"
- interface.baz.should == "the value of foo in baz is '25'"
- interface.qux.should == "the value of foo in baz is '25'"
+ string.foo.should == 25
+ string.bar.should == "the value of foo is '25'"
+ string.quux.should == "qux told me the value of foo in baz is '25'"
+ string.baz.should == "the value of foo in baz is '25'"
+ string.qux.should == "the value of foo in baz is '25'"
end
end
end
diff --git a/spec/unit/interface/catalog_spec.rb b/spec/unit/string/catalog_spec.rb
old mode 100644
new mode 100755
similarity index 64%
rename from spec/unit/interface/catalog_spec.rb
rename to spec/unit/string/catalog_spec.rb
index c615181..a11d29a
--- a/spec/unit/interface/catalog_spec.rb
+++ b/spec/unit/string/catalog_spec.rb
@@ -2,5 +2,5 @@
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
-describe Puppet::Interface.define(:catalog, '0.0.1') do
+describe Puppet::String.define(:catalog, '0.0.1') do
end
diff --git a/spec/unit/interface/certificate_spec.rb b/spec/unit/string/certificate_request_spec.rb
old mode 100644
new mode 100755
similarity index 60%
rename from spec/unit/interface/certificate_spec.rb
rename to spec/unit/string/certificate_request_spec.rb
index e5c63e4..96e1d88
--- a/spec/unit/interface/certificate_spec.rb
+++ b/spec/unit/string/certificate_request_spec.rb
@@ -2,5 +2,5 @@
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
-describe Puppet::Interface.define(:certificate, '0.0.1') do
+describe Puppet::String.define(:certificate_request, '0.0.1') do
end
diff --git a/spec/unit/interface/certificate_request_spec.rb b/spec/unit/string/certificate_revocation_list_spec.rb
old mode 100644
new mode 100755
similarity index 58%
rename from spec/unit/interface/certificate_request_spec.rb
rename to spec/unit/string/certificate_revocation_list_spec.rb
index 0143ebc..cf50471
--- a/spec/unit/interface/certificate_request_spec.rb
+++ b/spec/unit/string/certificate_revocation_list_spec.rb
@@ -2,5 +2,5 @@
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
-describe Puppet::Interface.define(:certificate_request, '0.0.1') do
+describe Puppet::String.define(:certificate_revocation_list, '0.0.1') do
end
diff --git a/spec/unit/interface/report_spec.rb b/spec/unit/string/certificate_spec.rb
old mode 100644
new mode 100755
similarity index 63%
copy from spec/unit/interface/report_spec.rb
copy to spec/unit/string/certificate_spec.rb
index 23855db..719ee6b
--- a/spec/unit/interface/report_spec.rb
+++ b/spec/unit/string/certificate_spec.rb
@@ -2,5 +2,5 @@
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
-describe Puppet::Interface.define(:report, '0.0.1') do
+describe Puppet::String.define(:certificate, '0.0.1') do
end
diff --git a/spec/unit/interface/config_spec.rb b/spec/unit/string/config_spec.rb
old mode 100644
new mode 100755
similarity index 93%
rename from spec/unit/interface/config_spec.rb
rename to spec/unit/string/config_spec.rb
index 2e82b0b..5622652
--- a/spec/unit/interface/config_spec.rb
+++ b/spec/unit/string/config_spec.rb
@@ -2,7 +2,7 @@
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
-describe Puppet::Interface.define(:config, '0.0.1') do
+describe Puppet::String.define(:config, '0.0.1') do
it "should use Settings#print_config_options when asked to print" do
Puppet.settings.stubs(:puts)
Puppet.settings.expects(:print_config_options)
diff --git a/spec/unit/interface/configurer_spec.rb b/spec/unit/string/configurer_spec.rb
old mode 100644
new mode 100755
similarity index 93%
rename from spec/unit/interface/configurer_spec.rb
rename to spec/unit/string/configurer_spec.rb
index e97e63b..400bfb5
--- a/spec/unit/interface/configurer_spec.rb
+++ b/spec/unit/string/configurer_spec.rb
@@ -4,7 +4,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
require 'puppet/indirector/catalog/rest'
require 'tempfile'
-describe Puppet::Interface.define(:configurer, '0.0.1') do
+describe Puppet::String.define(:configurer, '0.0.1') do
describe "#synchronize" do
it "should retrieve and apply a catalog and return a report" do
dirname = Dir.mktmpdir("puppetdir")
diff --git a/spec/unit/interface/facts_spec.rb b/spec/unit/string/facts_spec.rb
old mode 100644
new mode 100755
similarity index 89%
rename from spec/unit/interface/facts_spec.rb
rename to spec/unit/string/facts_spec.rb
index 5f0214f..a537b74
--- a/spec/unit/interface/facts_spec.rb
+++ b/spec/unit/string/facts_spec.rb
@@ -2,7 +2,7 @@
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
-describe Puppet::Interface.define(:facts, '0.0.1') do
+describe Puppet::String.define(:facts, '0.0.1') do
it "should define an 'upload' fact" do
subject.should be_action(:upload)
end
diff --git a/spec/unit/interface/file_spec.rb b/spec/unit/string/file_spec.rb
old mode 100644
new mode 100755
similarity index 65%
rename from spec/unit/interface/file_spec.rb
rename to spec/unit/string/file_spec.rb
index bd6e31c..bbc8c7e
--- a/spec/unit/interface/file_spec.rb
+++ b/spec/unit/string/file_spec.rb
@@ -2,5 +2,5 @@
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
-describe Puppet::Interface.define(:file, '0.0.1') do
+describe Puppet::String.define(:file, '0.0.1') do
end
diff --git a/spec/unit/interface/indirector_spec.rb b/spec/unit/string/indirector_spec.rb
old mode 100644
new mode 100755
similarity index 67%
rename from spec/unit/interface/indirector_spec.rb
rename to spec/unit/string/indirector_spec.rb
index 4b2beae..89306c4
--- a/spec/unit/interface/indirector_spec.rb
+++ b/spec/unit/string/indirector_spec.rb
@@ -1,11 +1,11 @@
#!/usr/bin/env ruby
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
-require 'puppet/interface/indirector'
+require 'puppet/string/indirector'
-describe Puppet::Interface::Indirector do
+describe Puppet::String::Indirector do
before do
- @instance = Puppet::Interface::Indirector.new(:test, '0.0.1')
+ @instance = Puppet::String::Indirector.new(:test, '0.0.1')
@indirection = stub 'indirection', :name => :stub_indirection
@@ -13,24 +13,24 @@ describe Puppet::Interface::Indirector do
end
it "should be able to return a list of indirections" do
- Puppet::Interface::Indirector.indirections.should be_include("catalog")
+ Puppet::String::Indirector.indirections.should be_include("catalog")
end
it "should be able to return a list of terminuses for a given indirection" do
- Puppet::Interface::Indirector.terminus_classes(:catalog).should be_include("compiler")
+ Puppet::String::Indirector.terminus_classes(:catalog).should be_include("compiler")
end
describe "as an instance" do
it "should be able to determine its indirection" do
# Loading actions here an get, um, complicated
- Puppet::Interface.stubs(:load_actions)
- Puppet::Interface::Indirector.new(:catalog, '0.0.1').indirection.should equal(Puppet::Resource::Catalog.indirection)
+ Puppet::String.stubs(:load_actions)
+ Puppet::String::Indirector.new(:catalog, '0.0.1').indirection.should equal(Puppet::Resource::Catalog.indirection)
end
end
[:find, :search, :save, :destroy].each do |method|
it "should define a '#{method}' action" do
- Puppet::Interface::Indirector.should be_action(method)
+ Puppet::String::Indirector.should be_action(method)
end
it "should just call the indirection method when the '#{method}' action is invoked" do
@@ -50,6 +50,6 @@ describe Puppet::Interface::Indirector do
end
it "should define a class-level 'info' action" do
- Puppet::Interface::Indirector.should be_action(:info)
+ Puppet::String::Indirector.should be_action(:info)
end
end
diff --git a/spec/unit/interface/key_spec.rb b/spec/unit/string/key_spec.rb
old mode 100644
new mode 100755
similarity index 66%
copy from spec/unit/interface/key_spec.rb
copy to spec/unit/string/key_spec.rb
index 5194978..d77f02e
--- a/spec/unit/interface/key_spec.rb
+++ b/spec/unit/string/key_spec.rb
@@ -2,5 +2,5 @@
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
-describe Puppet::Interface.define(:key, '0.0.1') do
+describe Puppet::String.define(:key, '0.0.1') do
end
diff --git a/spec/unit/interface/node_spec.rb b/spec/unit/string/node_spec.rb
old mode 100644
new mode 100755
similarity index 78%
rename from spec/unit/interface/node_spec.rb
rename to spec/unit/string/node_spec.rb
index 91914c3..7198efe
--- a/spec/unit/interface/node_spec.rb
+++ b/spec/unit/string/node_spec.rb
@@ -2,7 +2,7 @@
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
-describe Puppet::Interface.define(:node, '0.0.1') do
+describe Puppet::String.define(:node, '0.0.1') do
it "should set its default format to :yaml" do
subject.default_format.should == :yaml
end
diff --git a/spec/unit/interface/report_spec.rb b/spec/unit/string/report_spec.rb
old mode 100644
new mode 100755
similarity index 64%
copy from spec/unit/interface/report_spec.rb
copy to spec/unit/string/report_spec.rb
index 23855db..51342c2
--- a/spec/unit/interface/report_spec.rb
+++ b/spec/unit/string/report_spec.rb
@@ -2,5 +2,5 @@
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
-describe Puppet::Interface.define(:report, '0.0.1') do
+describe Puppet::String.define(:report, '0.0.1') do
end
diff --git a/spec/unit/interface/key_spec.rb b/spec/unit/string/resource_spec.rb
old mode 100644
new mode 100755
similarity index 65%
rename from spec/unit/interface/key_spec.rb
rename to spec/unit/string/resource_spec.rb
index 5194978..de7e747
--- a/spec/unit/interface/key_spec.rb
+++ b/spec/unit/string/resource_spec.rb
@@ -2,5 +2,5 @@
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
-describe Puppet::Interface.define(:key, '0.0.1') do
+describe Puppet::String.define(:resource, '0.0.1') do
end
diff --git a/spec/unit/interface/report_spec.rb b/spec/unit/string/resource_type_spec.rb
old mode 100644
new mode 100755
similarity index 63%
rename from spec/unit/interface/report_spec.rb
rename to spec/unit/string/resource_type_spec.rb
index 23855db..8b0b4aa
--- a/spec/unit/interface/report_spec.rb
+++ b/spec/unit/string/resource_type_spec.rb
@@ -2,5 +2,5 @@
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
-describe Puppet::Interface.define(:report, '0.0.1') do
+describe Puppet::String.define(:resource_type, '0.0.1') do
end
diff --git a/spec/unit/interface/interface_collection_spec.rb b/spec/unit/string/string_collection_spec.rb
old mode 100644
new mode 100755
similarity index 73%
rename from spec/unit/interface/interface_collection_spec.rb
rename to spec/unit/string/string_collection_spec.rb
index 3e4b9d6..46c431f
--- a/spec/unit/interface/interface_collection_spec.rb
+++ b/spec/unit/string/string_collection_spec.rb
@@ -3,26 +3,26 @@
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
require 'tmpdir'
-describe Puppet::Interface::InterfaceCollection do
+describe Puppet::String::StringCollection do
before :all do
- @interfaces = subject.instance_variable_get("@interfaces").dup
+ @strings = subject.instance_variable_get("@strings").dup
end
before :each do
- subject.instance_variable_get("@interfaces").clear
+ subject.instance_variable_get("@strings").clear
end
after :all do
- subject.instance_variable_set("@interfaces", @interfaces)
+ subject.instance_variable_set("@strings", @strings)
end
- describe "::interfaces" do
+ describe "::strings" do
end
describe "::versions" do
before :each do
@dir = Dir.mktmpdir
- @lib = FileUtils.mkdir_p(File.join @dir, 'puppet', 'interface')
+ @lib = FileUtils.mkdir_p(File.join @dir, 'puppet', 'string')
$LOAD_PATH.push(@dir)
end
@@ -35,13 +35,13 @@ describe Puppet::Interface::InterfaceCollection do
subject.versions(:fozzie).should == []
end
- it "should return versions loadable as puppet/interface/v{version}/{name}" do
+ it "should return versions loadable as puppet/string/v{version}/{name}" do
FileUtils.mkdir_p(File.join @lib, 'v1.0.0')
FileUtils.touch(File.join @lib, 'v1.0.0', 'fozzie.rb')
subject.versions(:fozzie).should == ['1.0.0']
end
- it "should an ordered list of all versions loadable as puppet/interface/v{version}/{name}" do
+ it "should an ordered list of all versions loadable as puppet/string/v{version}/{name}" do
%w[ 1.2.1rc2 1.2.1beta1 1.2.1rc1 1.2.1 1.2.2 ].each do |version|
FileUtils.mkdir_p(File.join @lib, "v#{version}")
FileUtils.touch(File.join @lib, "v#{version}", 'fozzie.rb')
@@ -49,12 +49,12 @@ describe Puppet::Interface::InterfaceCollection do
subject.versions(:fozzie).should == %w[ 1.2.1beta1 1.2.1rc1 1.2.1rc2 1.2.1 1.2.2 ]
end
- it "should not return a version for an empty puppet/interface/v{version}/{name}" do
+ it "should not return a version for an empty puppet/string/v{version}/{name}" do
FileUtils.mkdir_p(File.join @lib, 'v1.0.0', 'fozzie')
subject.versions(:fozzie).should == []
end
- it "should an ordered list of all versions loadable as puppet/interface/v{version}/{name}/*.rb" do
+ it "should an ordered list of all versions loadable as puppet/string/v{version}/{name}/*.rb" do
%w[ 1.2.1rc2 1.2.1beta1 1.2.1rc1 1.2.1 1.2.2 ].each do |version|
FileUtils.mkdir_p(File.join @lib, "v#{version}", "fozzie")
FileUtils.touch(File.join @lib, "v#{version}", 'fozzie', 'action.rb')
@@ -148,12 +148,12 @@ describe Puppet::Interface::InterfaceCollection do
describe "::[]" do
before :each do
- subject.instance_variable_get("@interfaces")[:foo]['0.0.1'] = 10
+ subject.instance_variable_get("@strings")[:foo]['0.0.1'] = 10
end
before :each do
@dir = Dir.mktmpdir
- @lib = FileUtils.mkdir_p(File.join @dir, 'puppet', 'interface')
+ @lib = FileUtils.mkdir_p(File.join @dir, 'puppet', 'string')
$LOAD_PATH.push(@dir)
end
@@ -162,62 +162,62 @@ describe Puppet::Interface::InterfaceCollection do
$LOAD_PATH.pop
end
- it "should return the interface with the given name" do
+ it "should return the string with the given name" do
subject["foo", '0.0.1'].should == 10
end
- it "should attempt to load the interface if it isn't found" do
- subject.expects(:require).with('puppet/interface/v0.0.1/bar')
+ it "should attempt to load the string if it isn't found" do
+ subject.expects(:require).with('puppet/string/v0.0.1/bar')
subject["bar", '0.0.1']
end
- it "should attempt to load the interface with the greatest version for specified version :latest" do
+ it "should attempt to load the string with the greatest version for specified version :latest" do
%w[ 1.2.1 1.2.2 ].each do |version|
FileUtils.mkdir_p(File.join @lib, "v#{version}")
FileUtils.touch(File.join @lib, "v#{version}", 'fozzie.rb')
end
- subject.expects(:require).with('puppet/interface/v1.2.2/fozzie')
+ subject.expects(:require).with('puppet/string/v1.2.2/fozzie')
subject['fozzie', :latest]
end
end
- describe "::interface?" do
+ describe "::string?" do
before :each do
- subject.instance_variable_get("@interfaces")[:foo]['0.0.1'] = 10
+ subject.instance_variable_get("@strings")[:foo]['0.0.1'] = 10
end
- it "should return true if the interface specified is registered" do
- subject.interface?("foo", '0.0.1').should == true
+ it "should return true if the string specified is registered" do
+ subject.string?("foo", '0.0.1').should == true
end
- it "should attempt to require the interface if it is not registered" do
- subject.expects(:require).with('puppet/interface/v0.0.1/bar')
- subject.interface?("bar", '0.0.1')
+ it "should attempt to require the string if it is not registered" do
+ subject.expects(:require).with('puppet/string/v0.0.1/bar')
+ subject.string?("bar", '0.0.1')
end
- it "should return true if requiring the interface registered it" do
+ it "should return true if requiring the string registered it" do
subject.stubs(:require).with do
- subject.instance_variable_get("@interfaces")[:bar]['0.0.1'] = 20
+ subject.instance_variable_get("@strings")[:bar]['0.0.1'] = 20
end
- subject.interface?("bar", '0.0.1').should == true
+ subject.string?("bar", '0.0.1').should == true
end
- it "should return false if the interface is not registered" do
+ it "should return false if the string is not registered" do
subject.stubs(:require).returns(true)
- subject.interface?("bar", '0.0.1').should == false
+ subject.string?("bar", '0.0.1').should == false
end
- it "should return false if there is a LoadError requiring the interface" do
+ it "should return false if there is a LoadError requiring the string" do
subject.stubs(:require).raises(LoadError)
- subject.interface?("bar", '0.0.1').should == false
+ subject.string?("bar", '0.0.1').should == false
end
end
describe "::register" do
- it "should store the interface by name" do
- interface = Puppet::Interface.new(:my_interface, '0.0.1')
- subject.register(interface)
- subject.instance_variable_get("@interfaces").should == {:my_interface => {'0.0.1' => interface}}
+ it "should store the string by name" do
+ string = Puppet::String.new(:my_string, '0.0.1')
+ subject.register(string)
+ subject.instance_variable_get("@strings").should == {:my_string => {'0.0.1' => string}}
end
end
@@ -242,7 +242,7 @@ describe Puppet::Interface::InterfaceCollection do
faulty.each do |input|
it "should fail when presented with #{input.inspect} (#{input.class})" do
expect { subject.underscorize(input) }.
- should raise_error ArgumentError, /not a valid interface name/
+ should raise_error ArgumentError, /not a valid string name/
end
end
end
diff --git a/spec/unit/string_spec.rb b/spec/unit/string_spec.rb
new file mode 100755
index 0000000..73d1f21
--- /dev/null
+++ b/spec/unit/string_spec.rb
@@ -0,0 +1,83 @@
+#!/usr/bin/env ruby
+
+require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')
+
+describe Puppet::String do
+ before :all do
+ @strings = Puppet::String::StringCollection.instance_variable_get("@strings").dup
+ end
+
+ before :each do
+ Puppet::String::StringCollection.instance_variable_get("@strings").clear
+ end
+
+ after :all do
+ Puppet::String::StringCollection.instance_variable_set("@strings", @strings)
+ end
+
+ describe "#define" do
+ it "should register the string" do
+ string = Puppet::String.define(:string_test_register, '0.0.1')
+ string.should == Puppet::String[:string_test_register, '0.0.1']
+ end
+
+ it "should load actions" do
+ Puppet::String.any_instance.expects(:load_actions)
+ Puppet::String.define(:string_test_load_actions, '0.0.1')
+ end
+
+ it "should require a version number" do
+ proc { Puppet::String.define(:no_version) }.should raise_error(ArgumentError)
+ end
+ end
+
+ describe "#initialize" do
+ it "should require a version number" do
+ proc { Puppet::String.new(:no_version) }.should raise_error(ArgumentError)
+ end
+
+ it "should require a valid version number" do
+ proc { Puppet::String.new(:bad_version, 'Rasins') }.should raise_error(ArgumentError)
+ end
+
+ it "should instance-eval any provided block" do
+ face = Puppet::String.new(:string_test_block,'0.0.1') do
+ action(:something) do
+ invoke { "foo" }
+ end
+ end
+
+ face.something.should == "foo"
+ end
+ end
+
+ it "should have a name" do
+ Puppet::String.new(:me,'0.0.1').name.should == :me
+ end
+
+ it "should stringify with its own name" do
+ Puppet::String.new(:me,'0.0.1').to_s.should =~ /\bme\b/
+ end
+
+ it "should allow overriding of the default format" do
+ face = Puppet::String.new(:me,'0.0.1')
+ face.set_default_format :foo
+ face.default_format.should == :foo
+ end
+
+ it "should default to :pson for its format" do
+ Puppet::String.new(:me, '0.0.1').default_format.should == :pson
+ end
+
+ # Why?
+ it "should create a class-level autoloader" do
+ Puppet::String.autoloader.should be_instance_of(Puppet::Util::Autoload)
+ end
+
+ it "should try to require strings that are not known" do
+ Puppet::String::StringCollection.expects(:require).with "puppet/string/v0.0.1/foo"
+ Puppet::String[:foo, '0.0.1']
+ end
+
+ it "should be able to load all actions in all search paths"
+end
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list