diff options
| author | Daniel Pittman <daniel@puppetlabs.com> | 2011-04-13 00:17:57 -0700 |
|---|---|---|
| committer | Daniel Pittman <daniel@puppetlabs.com> | 2011-04-13 00:17:57 -0700 |
| commit | 4dd6a77481400b7eeac3377267d092d4c6d22da3 (patch) | |
| tree | f95d292596144832805a9b57a55bc440f7cfaa43 | |
| parent | 941c56a283265cdf5a951ecaae63580b60486c52 (diff) | |
(#7056) Use 'face' rather than 'faces' in the production code.
After some discussion we decided that most uses of the Puppet Face
infrastructure were about single faces on their own, not about the collection,
and so we were better referring to Puppet::Face[...] in code.
This implements that by translating names and references in the Ruby code to
the new, s-less, name.
70 files changed, 187 insertions, 199 deletions
diff --git a/lib/puppet/application/config.rb b/lib/puppet/application/config.rb index 41a46c339..a94441e7f 100644 --- a/lib/puppet/application/config.rb +++ b/lib/puppet/application/config.rb @@ -1,4 +1,4 @@ -require 'puppet/application/faces_base' +require 'puppet/application/face_base' -class Puppet::Application::Config < Puppet::Application::FacesBase +class Puppet::Application::Config < Puppet::Application::FaceBase end diff --git a/lib/puppet/application/configurer.rb b/lib/puppet/application/configurer.rb index 751e6b4d7..6e86cd2d4 100644 --- a/lib/puppet/application/configurer.rb +++ b/lib/puppet/application/configurer.rb @@ -1,5 +1,5 @@ require 'puppet/application' -require 'puppet/faces' +require 'puppet/face' 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::Faces[:configurer, '0.0.1'].synchronize(Puppet[:certname]) - Puppet::Faces[:report, '0.0.1'].submit(report) + report = Puppet::Face[:configurer, '0.0.1'].synchronize(Puppet[:certname]) + Puppet::Face[:report, '0.0.1'].submit(report) end end diff --git a/lib/puppet/application/faces_base.rb b/lib/puppet/application/face_base.rb index f1b77f285..2a048a532 100644 --- a/lib/puppet/application/faces_base.rb +++ b/lib/puppet/application/face_base.rb @@ -1,8 +1,8 @@ require 'puppet/application' -require 'puppet/faces' +require 'puppet/face' require 'optparse' -class Puppet::Application::FacesBase < Puppet::Application +class Puppet::Application::FaceBase < Puppet::Application should_parse_config run_mode :agent @@ -60,7 +60,7 @@ class Puppet::Application::FacesBase < Puppet::Application # REVISIT: 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 - @face = Puppet::Faces[@type, :current] + @face = Puppet::Face[@type, :current] @format = @face.default_format # Now, walk the command line and identify the action. We skip over diff --git a/lib/puppet/application/faces.rb b/lib/puppet/application/faces.rb index a7b227e23..3dd3f0312 100644 --- a/lib/puppet/application/faces.rb +++ b/lib/puppet/application/faces.rb @@ -1,5 +1,5 @@ require 'puppet/application' -require 'puppet/faces' +require 'puppet/face' class Puppet::Application::Faces < Puppet::Application @@ -12,7 +12,7 @@ class Puppet::Application::Faces < Puppet::Application option("--help", "-h") do |arg| puts "Usage: puppet faces [actions|terminuses] -Lists all available interfaces, and by default includes all available terminuses and actions. +Lists all available faces, and by default includes all available terminuses and actions. " end @@ -66,7 +66,7 @@ Lists all available interfaces, and by default includes all available terminuses end def faces - Puppet::Faces.faces + Puppet::Face.faces end def terminus_classes(indirection) @@ -74,9 +74,9 @@ Lists all available interfaces, and by default includes all available terminuses end def actions(indirection) - return [] unless faces = Puppet::Faces[indirection, '0.0.1'] - faces.load_actions - return faces.actions.sort { |a, b| a.to_s <=> b.to_s } + return [] unless face = Puppet::Face[indirection, '0.0.1'] + face.load_actions + return face.actions.sort { |a, b| a.to_s <=> b.to_s } end def load_applications diff --git a/lib/puppet/application/help.rb b/lib/puppet/application/help.rb index fd8818db0..0d7767632 100644 --- a/lib/puppet/application/help.rb +++ b/lib/puppet/application/help.rb @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -require 'puppet/application/faces_base' +require 'puppet/application/face_base' -class Puppet::Application::Help < Puppet::Application::FacesBase +class Puppet::Application::Help < Puppet::Application::FaceBase # Meh. Disable the default behaviour, which is to inspect the # string and return that – not so helpful. --daniel 2011-04-11 def render(result) result end diff --git a/lib/puppet/application/indirection_base.rb b/lib/puppet/application/indirection_base.rb index 7455ebedf..580a0999a 100644 --- a/lib/puppet/application/indirection_base.rb +++ b/lib/puppet/application/indirection_base.rb @@ -1,4 +1,4 @@ -require 'puppet/application/faces_base' +require 'puppet/application/face_base' -class Puppet::Application::IndirectionBase < Puppet::Application::FacesBase +class Puppet::Application::IndirectionBase < Puppet::Application::FaceBase end diff --git a/lib/puppet/faces.rb b/lib/puppet/face.rb index 947eecf24..f73b2fc3b 100644 --- a/lib/puppet/faces.rb +++ b/lib/puppet/face.rb @@ -1,4 +1,4 @@ -# The public name of this feature is 'faces', but we have hidden all the +# The public name of this feature is 'face', but we have hidden all the # plumbing over in the 'interfaces' namespace to make clear the distinction # between the two. # @@ -9,4 +9,4 @@ # 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 +Puppet::Face = Puppet::Interface diff --git a/lib/puppet/faces/catalog.rb b/lib/puppet/face/catalog.rb index 3353d5d04..0dcde3591 100644 --- a/lib/puppet/faces/catalog.rb +++ b/lib/puppet/face/catalog.rb @@ -1,6 +1,6 @@ -require 'puppet/faces/indirector' +require 'puppet/face/indirector' -Puppet::Faces::Indirector.define(:catalog, '0.0.1') do +Puppet::Face::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::Faces::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::Faces[:catalog, '0.0.1'].find(certname, facts_to_upload) + catalog = Puppet::Face[:catalog, '0.0.1'].find(certname, facts_to_upload) end catalog = catalog.to_ral catalog.finalize diff --git a/lib/puppet/faces/catalog/select.rb b/lib/puppet/face/catalog/select.rb index e29d19970..ba27117bc 100644 --- a/lib/puppet/faces/catalog/select.rb +++ b/lib/puppet/face/catalog/select.rb @@ -1,5 +1,5 @@ # Select and show a list of resources of a given type. -Puppet::Faces.define(:catalog, '0.0.1') do +Puppet::Face.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/faces/certificate.rb b/lib/puppet/face/certificate.rb index b10bee579..77e80f099 100644 --- a/lib/puppet/faces/certificate.rb +++ b/lib/puppet/face/certificate.rb @@ -1,7 +1,7 @@ -require 'puppet/faces/indirector' +require 'puppet/face/indirector' require 'puppet/ssl/host' -Puppet::Faces::Indirector.define(:certificate, '0.0.1') do +Puppet::Face::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/face/certificate_request.rb b/lib/puppet/face/certificate_request.rb new file mode 100644 index 000000000..1feba25ab --- /dev/null +++ b/lib/puppet/face/certificate_request.rb @@ -0,0 +1,4 @@ +require 'puppet/face/indirector' + +Puppet::Face::Indirector.define(:certificate_request, '0.0.1') do +end diff --git a/lib/puppet/face/certificate_revocation_list.rb b/lib/puppet/face/certificate_revocation_list.rb new file mode 100644 index 000000000..6a75aa578 --- /dev/null +++ b/lib/puppet/face/certificate_revocation_list.rb @@ -0,0 +1,4 @@ +require 'puppet/face/indirector' + +Puppet::Face::Indirector.define(:certificate_revocation_list, '0.0.1') do +end diff --git a/lib/puppet/faces/config.rb b/lib/puppet/face/config.rb index 647bf5052..45cb6b156 100644 --- a/lib/puppet/faces/config.rb +++ b/lib/puppet/face/config.rb @@ -1,6 +1,6 @@ -require 'puppet/faces' +require 'puppet/face' -Puppet::Faces.define(:config, '0.0.1') do +Puppet::Face.define(:config, '0.0.1') do action(:print) do when_invoked do |*args| options = args.pop diff --git a/lib/puppet/face/configurer.rb b/lib/puppet/face/configurer.rb new file mode 100644 index 000000000..74dfb854e --- /dev/null +++ b/lib/puppet/face/configurer.rb @@ -0,0 +1,12 @@ +require 'puppet/face' + +Puppet::Face.define(:configurer, '0.0.1') do + action(:synchronize) do + when_invoked do |certname, options| + facts = Puppet::Face[:facts, '0.0.1'].find(certname) + catalog = Puppet::Face[:catalog, '0.0.1'].download(certname, facts) + report = Puppet::Face[:catalog, '0.0.1'].apply(catalog) + report + end + end +end diff --git a/lib/puppet/faces/facts.rb b/lib/puppet/face/facts.rb index 33eacef38..8668b2531 100644 --- a/lib/puppet/faces/facts.rb +++ b/lib/puppet/face/facts.rb @@ -1,7 +1,7 @@ -require 'puppet/faces/indirector' +require 'puppet/face/indirector' require 'puppet/node/facts' -Puppet::Faces::Indirector.define(:facts, '0.0.1') do +Puppet::Face::Indirector.define(:facts, '0.0.1') do set_default_format :yaml # Upload our facts to the server diff --git a/lib/puppet/face/file.rb b/lib/puppet/face/file.rb new file mode 100644 index 000000000..1aa9462dd --- /dev/null +++ b/lib/puppet/face/file.rb @@ -0,0 +1,5 @@ +require 'puppet/face/indirector' + +Puppet::Face::Indirector.define(:file, '0.0.1') do + set_indirection_name :file_bucket_file +end diff --git a/lib/puppet/faces/help.rb b/lib/puppet/face/help.rb index 1d8abe20e..1c2da9e83 100644 --- a/lib/puppet/faces/help.rb +++ b/lib/puppet/face/help.rb @@ -1,9 +1,9 @@ -require 'puppet/faces' +require 'puppet/face' require 'puppet/util/command_line' require 'pathname' require 'erb' -Puppet::Faces.define(:help, '0.0.1') do +Puppet::Face.define(:help, '0.0.1') do summary "Displays help about puppet subcommands" action(:help) do @@ -41,7 +41,7 @@ Puppet::Faces.define(:help, '0.0.1') do actionname and raise ArgumentError, "Legacy subcommands don't take actions" return Puppet::Application[facename].help else - face = Puppet::Faces[facename.to_sym, version] + face = Puppet::Face[facename.to_sym, version] actionname and action = face.get_action(actionname.to_sym) end end @@ -76,9 +76,9 @@ Puppet::Faces.define(:help, '0.0.1') do def legacy_applications # The list of applications, less those that are duplicated as a face. Puppet::Util::CommandLine.available_subcommands.reject do |appname| - Puppet::Faces.face? appname.to_sym, :current or + Puppet::Face.face? appname.to_sym, :current or # ...this is a nasty way to exclude non-applications. :( - %w{faces_base indirection_base}.include? appname + %w{face_base indirection_base}.include? appname end.sort end diff --git a/lib/puppet/faces/help/action.erb b/lib/puppet/face/help/action.erb index eaf131464..eaf131464 100644 --- a/lib/puppet/faces/help/action.erb +++ b/lib/puppet/face/help/action.erb diff --git a/lib/puppet/faces/help/face.erb b/lib/puppet/face/help/face.erb index efe5fd809..efe5fd809 100644 --- a/lib/puppet/faces/help/face.erb +++ b/lib/puppet/face/help/face.erb diff --git a/lib/puppet/faces/help/global.erb b/lib/puppet/face/help/global.erb index e123367a2..f4c761b2b 100644 --- a/lib/puppet/faces/help/global.erb +++ b/lib/puppet/face/help/global.erb @@ -1,8 +1,8 @@ puppet <subcommand> [options] <action> [options] Available subcommands, from Puppet Faces: -% Puppet::Faces.faces.sort.each do |name| -% face = Puppet::Faces[name, :current] +% Puppet::Face.faces.sort.each do |name| +% face = Puppet::Face[name, :current] <%= face.name.to_s.ljust(16) %> <%= face.summary %> % end diff --git a/lib/puppet/faces/indirector.rb b/lib/puppet/face/indirector.rb index 7e4e0f00f..f48611e4b 100644 --- a/lib/puppet/faces/indirector.rb +++ b/lib/puppet/face/indirector.rb @@ -1,7 +1,7 @@ require 'puppet' -require 'puppet/faces' +require 'puppet/face' -class Puppet::Faces::Indirector < Puppet::Faces +class Puppet::Face::Indirector < Puppet::Face option "--terminus TERMINUS" do desc "REVISIT: You can select a terminus, which has some bigger effect that we should describe in this file somehow." diff --git a/lib/puppet/face/key.rb b/lib/puppet/face/key.rb new file mode 100644 index 000000000..3a11ddb03 --- /dev/null +++ b/lib/puppet/face/key.rb @@ -0,0 +1,4 @@ +require 'puppet/face/indirector' + +Puppet::Face::Indirector.define(:key, '0.0.1') do +end diff --git a/lib/puppet/face/node.rb b/lib/puppet/face/node.rb new file mode 100644 index 000000000..fd1a548d6 --- /dev/null +++ b/lib/puppet/face/node.rb @@ -0,0 +1,5 @@ +require 'puppet/face/indirector' + +Puppet::Face::Indirector.define(:node, '0.0.1') do + set_default_format :yaml +end diff --git a/lib/puppet/faces/report.rb b/lib/puppet/face/report.rb index 23a518981..6e6f0b335 100644 --- a/lib/puppet/faces/report.rb +++ b/lib/puppet/face/report.rb @@ -1,6 +1,6 @@ -require 'puppet/faces/indirector' +require 'puppet/face/indirector' -Puppet::Faces::Indirector.define(:report, '0.0.1') do +Puppet::Face::Indirector.define(:report, '0.0.1') do action(:submit) do when_invoked do |report, options| begin diff --git a/lib/puppet/face/resource.rb b/lib/puppet/face/resource.rb new file mode 100644 index 000000000..d162f728a --- /dev/null +++ b/lib/puppet/face/resource.rb @@ -0,0 +1,4 @@ +require 'puppet/face/indirector' + +Puppet::Face::Indirector.define(:resource, '0.0.1') do +end diff --git a/lib/puppet/face/resource_type.rb b/lib/puppet/face/resource_type.rb new file mode 100644 index 000000000..0cdbd719f --- /dev/null +++ b/lib/puppet/face/resource_type.rb @@ -0,0 +1,4 @@ +require 'puppet/face/indirector' + +Puppet::Face::Indirector.define(:resource_type, '0.0.1') do +end diff --git a/lib/puppet/face/status.rb b/lib/puppet/face/status.rb new file mode 100644 index 000000000..7085e7cd7 --- /dev/null +++ b/lib/puppet/face/status.rb @@ -0,0 +1,4 @@ +require 'puppet/face/indirector' + +Puppet::Face::Indirector.define(:status, '0.0.1') do +end diff --git a/lib/puppet/faces/certificate_request.rb b/lib/puppet/faces/certificate_request.rb deleted file mode 100644 index 5e91bdb7f..000000000 --- a/lib/puppet/faces/certificate_request.rb +++ /dev/null @@ -1,4 +0,0 @@ -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 deleted file mode 100644 index 2f2d72874..000000000 --- a/lib/puppet/faces/certificate_revocation_list.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'puppet/faces/indirector' - -Puppet::Faces::Indirector.define(:certificate_revocation_list, '0.0.1') do -end diff --git a/lib/puppet/faces/configurer.rb b/lib/puppet/faces/configurer.rb deleted file mode 100644 index d40987697..000000000 --- a/lib/puppet/faces/configurer.rb +++ /dev/null @@ -1,12 +0,0 @@ -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/faces/file.rb b/lib/puppet/faces/file.rb deleted file mode 100644 index e8ad18c17..000000000 --- a/lib/puppet/faces/file.rb +++ /dev/null @@ -1,5 +0,0 @@ -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/faces/key.rb b/lib/puppet/faces/key.rb deleted file mode 100644 index 7b6ad52ac..000000000 --- a/lib/puppet/faces/key.rb +++ /dev/null @@ -1,4 +0,0 @@ -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 deleted file mode 100644 index 7eed0df91..000000000 --- a/lib/puppet/faces/node.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'puppet/faces/indirector' - -Puppet::Faces::Indirector.define(:node, '0.0.1') do - set_default_format :yaml -end diff --git a/lib/puppet/faces/resource.rb b/lib/puppet/faces/resource.rb deleted file mode 100644 index 60b0d94db..000000000 --- a/lib/puppet/faces/resource.rb +++ /dev/null @@ -1,4 +0,0 @@ -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 deleted file mode 100644 index 4321d65e7..000000000 --- a/lib/puppet/faces/resource_type.rb +++ /dev/null @@ -1,4 +0,0 @@ -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 deleted file mode 100644 index e035f281f..000000000 --- a/lib/puppet/faces/status.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'puppet/faces/indirector' - -Puppet::Faces::Indirector.define(:status, '0.0.1') do -end diff --git a/lib/puppet/interface.rb b/lib/puppet/interface.rb index 27b3584b9..6570ebe46 100644 --- a/lib/puppet/interface.rb +++ b/lib/puppet/interface.rb @@ -19,7 +19,7 @@ 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/faces") + @autoloader ||= Puppet::Util::Autoload.new(:application, "puppet/face") end def faces @@ -90,7 +90,7 @@ class Puppet::Interface # Try to find actions defined in other files. def load_actions - path = "puppet/faces/#{name}" + path = "puppet/face/#{name}" loaded = [] [path, "#{name}@#{version}/#{path}"].each do |path| @@ -115,6 +115,6 @@ class Puppet::Interface end def to_s - "Puppet::Faces[#{name.inspect}, #{version.inspect}]" + "Puppet::Face[#{name.inspect}, #{version.inspect}]" end end diff --git a/lib/puppet/interface/face_collection.rb b/lib/puppet/interface/face_collection.rb index e4eb22fa3..591471d4b 100644 --- a/lib/puppet/interface/face_collection.rb +++ b/lib/puppet/interface/face_collection.rb @@ -12,7 +12,7 @@ module Puppet::Interface::FaceCollection $LOAD_PATH.each do |dir| next unless FileTest.directory?(dir) Dir.chdir(dir) do - Dir.glob("puppet/faces/*.rb").collect { |f| f.sub(/\.rb/, '') }.each do |file| + Dir.glob("puppet/face/*.rb").collect { |f| f.sub(/\.rb/, '') }.each do |file| iname = file.sub(/\.rb/, '') begin require iname @@ -66,7 +66,7 @@ module Puppet::Interface::FaceCollection # 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/faces/#{name}" + require "puppet/face/#{name}" # If we wanted :current, we need to index to find that; direct version # requests just work™ as they go. --daniel 2011-04-06 @@ -100,7 +100,7 @@ module Puppet::Interface::FaceCollection @faces[name][:current] = @faces[name][latest_ver] end rescue LoadError => e - raise unless e.message =~ %r{-- puppet/faces/#{name}$} + raise unless e.message =~ %r{-- puppet/face/#{name}$} # ...guess we didn't find the file; return a much better problem. end diff --git a/lib/puppet/util/command_line.rb b/lib/puppet/util/command_line.rb index fa462ee2d..a884b8658 100644 --- a/lib/puppet/util/command_line.rb +++ b/lib/puppet/util/command_line.rb @@ -70,8 +70,8 @@ module Puppet # Doing this at the top of the file is natural, but causes puppet.rb # to load too early, which causes things to break. This is a nasty # thing, found in #7065. --daniel 2011-04-11 - require 'puppet/faces/help' - puts Puppet::Faces[:help, :current].help + require 'puppet/face' + puts Puppet::Face[:help, :current].help end end diff --git a/lib/puppet/util/selinux.rb b/lib/puppet/util/selinux.rb index 9d0e0a715..cec8a57d9 100644 --- a/lib/puppet/util/selinux.rb +++ b/lib/puppet/util/selinux.rb @@ -1,4 +1,4 @@ -# Provides utility functions to help interfaces Puppet to SELinux. +# Provides utility functions to help interface Puppet to SELinux. # # This requires the very new SELinux Ruby bindings. These bindings closely # mirror the SELinux C library interface. diff --git a/spec/lib/puppet/face/basetest.rb b/spec/lib/puppet/face/basetest.rb new file mode 100644 index 000000000..00616f74f --- /dev/null +++ b/spec/lib/puppet/face/basetest.rb @@ -0,0 +1 @@ +Puppet::Face.define(:basetest, '0.0.1') diff --git a/spec/lib/puppet/faces/huzzah.rb b/spec/lib/puppet/face/huzzah.rb index e86730250..3428c6816 100644 --- a/spec/lib/puppet/faces/huzzah.rb +++ b/spec/lib/puppet/face/huzzah.rb @@ -1,5 +1,5 @@ -require 'puppet/faces' -Puppet::Faces.define(:huzzah, '2.0.1') do +require 'puppet/face' +Puppet::Face.define(:huzzah, '2.0.1') do summary "life is a thing for celebration" action :bar do "is where beer comes from" end end diff --git a/spec/lib/puppet/faces/basetest.rb b/spec/lib/puppet/faces/basetest.rb deleted file mode 100644 index d20c52b97..000000000 --- a/spec/lib/puppet/faces/basetest.rb +++ /dev/null @@ -1 +0,0 @@ -Puppet::Faces.define(:basetest, '0.0.1') diff --git a/spec/unit/application/config_spec.rb b/spec/unit/application/config_spec.rb index 0c1279630..fb224eac6 100755 --- a/spec/unit/application/config_spec.rb +++ b/spec/unit/application/config_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require 'puppet/application/config' describe Puppet::Application::Config do - it "should be a subclass of Puppet::Application::FacesBase" do - Puppet::Application::Config.superclass.should equal(Puppet::Application::FacesBase) + it "should be a subclass of Puppet::Application::FaceBase" do + Puppet::Application::Config.superclass.should equal(Puppet::Application::FaceBase) end end diff --git a/spec/unit/application/faces_base_spec.rb b/spec/unit/application/face_base_spec.rb index 18bd30295..d09e00a32 100755 --- a/spec/unit/application/faces_base_spec.rb +++ b/spec/unit/application/face_base_spec.rb @@ -1,15 +1,15 @@ #!/usr/bin/env rspec require 'spec_helper' -require 'puppet/application/faces_base' +require 'puppet/application/face_base' require 'tmpdir' -class Puppet::Application::FacesBase::Basetest < Puppet::Application::FacesBase +class Puppet::Application::FaceBase::Basetest < Puppet::Application::FaceBase end -describe Puppet::Application::FacesBase do +describe Puppet::Application::FaceBase do before :all do - Puppet::Faces.define(:basetest, '0.0.1') do + Puppet::Face.define(:basetest, '0.0.1') do option("--[no-]boolean") option("--mandatory MANDATORY") option("--optional [OPTIONAL]") @@ -22,7 +22,7 @@ describe Puppet::Application::FacesBase do end let :app do - app = Puppet::Application::FacesBase::Basetest.new + app = Puppet::Application::FaceBase::Basetest.new app.command_line.stubs(:subcommand_name).returns('subcommand') Puppet::Util::Log.stubs(:newdestination) app @@ -57,11 +57,11 @@ describe Puppet::Application::FacesBase do app.parse_options end - it "should set the faces based on the type" do + it "should set the face based on the type" do app.face.name.should == :basetest end - it "should set the format based on the faces default" do + it "should set the format based on the face default" do app.format.should == :pson end @@ -168,13 +168,13 @@ describe Puppet::Application::FacesBase do before :each do app.expects(:exit).with(0) - app.face = Puppet::Faces[:basetest, '0.0.1'] + app.face = Puppet::Face[:basetest, '0.0.1'] app.action = app.face.get_action(:foo) app.format = :pson app.arguments = ["myname", "myarg"] end - it "should send the specified verb and name to the faces" do + it "should send the specified verb and name to the face" do app.face.expects(:foo).with(*app.arguments) app.main end diff --git a/spec/unit/application/faces_spec.rb b/spec/unit/application/faces_spec.rb index c4d15a297..9b6f073f5 100755 --- a/spec/unit/application/faces_spec.rb +++ b/spec/unit/application/faces_spec.rb @@ -9,8 +9,7 @@ describe Puppet::Application::Faces do end it "should always call 'list'" do - faces = Puppet::Application::Faces.new - faces.expects(:list) - faces.main + subject.expects(:list) + subject.main end end diff --git a/spec/unit/application/indirection_base_spec.rb b/spec/unit/application/indirection_base_spec.rb index 98eb3a118..9aac36860 100755 --- a/spec/unit/application/indirection_base_spec.rb +++ b/spec/unit/application/indirection_base_spec.rb @@ -2,19 +2,19 @@ require 'spec_helper' require 'puppet/application/indirection_base' -require 'puppet/faces/indirector' +require 'puppet/face/indirector' ######################################################################## # Stub for testing; the names are critical, sadly. --daniel 2011-03-30 class Puppet::Application::TestIndirection < Puppet::Application::IndirectionBase end -face = Puppet::Faces::Indirector.define(:testindirection, '0.0.1') do +face = Puppet::Face::Indirector.define(:testindirection, '0.0.1') do end # REVISIT: This horror is required because we don't allow anything to be # :current except for if it lives on, and is loaded from, disk. --daniel 2011-03-29 face.instance_variable_set('@version', :current) -Puppet::Faces.register(face) +Puppet::Face.register(face) ######################################################################## diff --git a/spec/unit/face/catalog_spec.rb b/spec/unit/face/catalog_spec.rb new file mode 100755 index 000000000..28c2aa9be --- /dev/null +++ b/spec/unit/face/catalog_spec.rb @@ -0,0 +1,4 @@ +require 'puppet/face' +describe Puppet::Face[:catalog, '0.0.1'] do + it "should actually have some testing..." +end diff --git a/spec/unit/face/certificate_request_spec.rb b/spec/unit/face/certificate_request_spec.rb new file mode 100755 index 000000000..a83a92df8 --- /dev/null +++ b/spec/unit/face/certificate_request_spec.rb @@ -0,0 +1,3 @@ +describe Puppet::Face[:certificate_request, '0.0.1'] do + it "should actually have some tests..." +end diff --git a/spec/unit/face/certificate_revocation_list_spec.rb b/spec/unit/face/certificate_revocation_list_spec.rb new file mode 100755 index 000000000..22c0fa2bf --- /dev/null +++ b/spec/unit/face/certificate_revocation_list_spec.rb @@ -0,0 +1,3 @@ +describe Puppet::Face[:certificate_revocation_list, '0.0.1'] do + it "should actually have some tests..." +end diff --git a/spec/unit/faces/certificate_spec.rb b/spec/unit/face/certificate_spec.rb index ba264f967..dbcc888ad 100755 --- a/spec/unit/faces/certificate_spec.rb +++ b/spec/unit/face/certificate_spec.rb @@ -1,12 +1,12 @@ require 'puppet/ssl/host' -describe Puppet::Faces[:certificate, '0.0.1'] do +describe Puppet::Face[:certificate, '0.0.1'] do it "should have a ca-location option" do subject.should be_option :ca_location end it "should set the ca location when invoked" do - pending "#6983: This is broken in the actual faces..." + pending "#6983: This is broken in the actual face..." Puppet::SSL::Host.expects(:ca_location=).with(:foo) Puppet::SSL::Host.indirection.expects(:save) subject.sign :ca_location => :foo diff --git a/spec/unit/faces/config_spec.rb b/spec/unit/face/config_spec.rb index b71995e9f..3657b9abd 100755 --- a/spec/unit/faces/config_spec.rb +++ b/spec/unit/face/config_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Puppet::Faces[:config, '0.0.1'] do +describe Puppet::Face[: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/faces/configurer_spec.rb b/spec/unit/face/configurer_spec.rb index 6982c00ae..a404c926f 100755 --- a/spec/unit/faces/configurer_spec.rb +++ b/spec/unit/face/configurer_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require 'puppet/indirector/catalog/rest' require 'tempfile' -describe Puppet::Faces[:configurer, '0.0.1'] do +describe Puppet::Face[:configurer, '0.0.1'] do describe "#synchronize" do it "should retrieve and apply a catalog and return a report" do pending "REVISIT: 2.7 changes broke this, and we want the merge published" diff --git a/spec/unit/faces/facts_spec.rb b/spec/unit/face/facts_spec.rb index 46496a839..f574ac741 100755 --- a/spec/unit/faces/facts_spec.rb +++ b/spec/unit/face/facts_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Puppet::Faces[:facts, '0.0.1'] do +describe Puppet::Face[:facts, '0.0.1'] do it "should define an 'upload' fact" do subject.should be_action(:upload) end diff --git a/spec/unit/faces/file_spec.rb b/spec/unit/face/file_spec.rb index fcb52c67e..97e8bcc08 100755 --- a/spec/unit/faces/file_spec.rb +++ b/spec/unit/face/file_spec.rb @@ -1,3 +1,3 @@ -describe Puppet::Faces[:file, '0.0.1'] do +describe Puppet::Face[:file, '0.0.1'] do it "should actually have some tests..." end diff --git a/spec/unit/faces/help_spec.rb b/spec/unit/face/help_spec.rb index cd74a5bf1..e67f29e07 100644 --- a/spec/unit/faces/help_spec.rb +++ b/spec/unit/face/help_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' -require 'puppet/faces/help' +require 'puppet/face/help' -describe Puppet::Faces[:help, '0.0.1'] do +describe Puppet::Face[:help, '0.0.1'] do it "should have a help action" do subject.should be_action :help end @@ -38,41 +38,41 @@ describe Puppet::Faces[:help, '0.0.1'] do end it "should find a face by version" do - face = Puppet::Faces[:huzzah, :current] + face = Puppet::Face[:huzzah, :current] subject.help(:huzzah, :version => face.version). should == subject.help(:huzzah, :version => :current) end context "when listing subcommands" do - subject { Puppet::Faces[:help, :current].help } + subject { Puppet::Face[:help, :current].help } # Check a precondition for the next block; if this fails you have - # something odd in your set of faces, and we skip testing things that + # something odd in your set of face, and we skip testing things that # matter. --daniel 2011-04-10 it "should have at least one face with a summary" do - Puppet::Faces.faces.should be_any do |name| - Puppet::Faces[name, :current].summary + Puppet::Face.faces.should be_any do |name| + Puppet::Face[name, :current].summary end end - Puppet::Faces.faces.each do |name| - face = Puppet::Faces[name, :current] + Puppet::Face.faces.each do |name| + face = Puppet::Face[name, :current] summary = face.summary it { should =~ %r{ #{name} } } it { should =~ %r{ #{name} +#{summary}} } if summary end - Puppet::Faces[:help, :current].legacy_applications.each do |appname| + Puppet::Face[:help, :current].legacy_applications.each do |appname| it { should =~ %r{ #{appname} } } - summary = Puppet::Faces[:help, :current].horribly_extract_summary_from(appname) + summary = Puppet::Face[:help, :current].horribly_extract_summary_from(appname) summary and it { should =~ %r{ #{summary}\b} } end end context "#legacy_applications" do - subject { Puppet::Faces[:help, :current].legacy_applications } + subject { Puppet::Face[:help, :current].legacy_applications } # If we don't, these tests are ... less than useful, because they assume # it. When this breaks you should consider ditching the entire feature @@ -83,13 +83,13 @@ describe Puppet::Faces[:help, '0.0.1'] do # bug that caused these to be listed is annoyingly subtle and has a nasty # fix, so better to have a "fail if you do something daft" trigger in # place here, I think. --daniel 2011-04-11 - %w{faces_base indirection_base}.each do |name| + %w{face_base indirection_base}.each do |name| it { should_not include name } end end context "help for legacy applications" do - subject { Puppet::Faces[:help, :current] } + subject { Puppet::Face[:help, :current] } let :appname do subject.legacy_applications.first end # This test is purposely generic, so that as we eliminate legacy commands diff --git a/spec/unit/faces/indirector_spec.rb b/spec/unit/face/indirector_spec.rb index c1aed9617..269e05543 100755 --- a/spec/unit/faces/indirector_spec.rb +++ b/spec/unit/face/indirector_spec.rb @@ -1,11 +1,11 @@ #!/usr/bin/env ruby require 'spec_helper' -require 'puppet/faces/indirector' +require 'puppet/face/indirector' -describe Puppet::Faces::Indirector do +describe Puppet::Face::Indirector do subject do - instance = Puppet::Faces::Indirector.new(:test, '0.0.1') + instance = Puppet::Face::Indirector.new(:test, '0.0.1') indirection = stub('indirection', :name => :stub_indirection, :reset_terminus_class => nil) @@ -14,24 +14,24 @@ describe Puppet::Faces::Indirector do end it "should be able to return a list of indirections" do - Puppet::Faces::Indirector.indirections.should be_include("catalog") + Puppet::Face::Indirector.indirections.should be_include("catalog") end it "should be able to return a list of terminuses for a given indirection" do - Puppet::Faces::Indirector.terminus_classes(:catalog).should be_include("compiler") + Puppet::Face::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::Faces.stubs(:load_actions) - Puppet::Faces::Indirector.new(:catalog, '0.0.1').indirection.should equal(Puppet::Resource::Catalog.indirection) + Puppet::Face.stubs(:load_actions) + Puppet::Face::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::Faces::Indirector.should be_action(method) + Puppet::Face::Indirector.should be_action(method) end it "should call the indirection method with options when the '#{method}' action is invoked" do @@ -55,6 +55,6 @@ describe Puppet::Faces::Indirector do end it "should define a class-level 'info' action" do - Puppet::Faces::Indirector.should be_action(:info) + Puppet::Face::Indirector.should be_action(:info) end end diff --git a/spec/unit/faces/key_spec.rb b/spec/unit/face/key_spec.rb index 9b7a58706..10d664790 100755 --- a/spec/unit/faces/key_spec.rb +++ b/spec/unit/face/key_spec.rb @@ -1,3 +1,3 @@ -describe Puppet::Faces[:key, '0.0.1'] do +describe Puppet::Face[:key, '0.0.1'] do it "should actually have some tests..." end diff --git a/spec/unit/faces/node_spec.rb b/spec/unit/face/node_spec.rb index c6ed71f59..d27f41b56 100755 --- a/spec/unit/faces/node_spec.rb +++ b/spec/unit/face/node_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Puppet::Faces[:node, '0.0.1'] do +describe Puppet::Face[: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/faces/report_spec.rb b/spec/unit/face/report_spec.rb index 30897d5e7..b1b28167e 100755 --- a/spec/unit/faces/report_spec.rb +++ b/spec/unit/face/report_spec.rb @@ -1,3 +1,3 @@ -describe Puppet::Faces[:report, '0.0.1'] do +describe Puppet::Face[:report, '0.0.1'] do it "should actually have some tests..." end diff --git a/spec/unit/faces/resource_spec.rb b/spec/unit/face/resource_spec.rb index e3f2e1c62..084e2a6a9 100755 --- a/spec/unit/faces/resource_spec.rb +++ b/spec/unit/face/resource_spec.rb @@ -1,3 +1,3 @@ -describe Puppet::Faces[:resource, '0.0.1'] do +describe Puppet::Face[:resource, '0.0.1'] do it "should actually have some tests..." end diff --git a/spec/unit/face/resource_type_spec.rb b/spec/unit/face/resource_type_spec.rb new file mode 100755 index 000000000..2adaedca1 --- /dev/null +++ b/spec/unit/face/resource_type_spec.rb @@ -0,0 +1,3 @@ +describe Puppet::Face[:resource_type, '0.0.1'] do + it "should actually have some tests..." +end diff --git a/spec/unit/faces_spec.rb b/spec/unit/face_spec.rb index b6c49d917..b6c49d917 100644 --- a/spec/unit/faces_spec.rb +++ b/spec/unit/face_spec.rb diff --git a/spec/unit/faces/catalog_spec.rb b/spec/unit/faces/catalog_spec.rb deleted file mode 100755 index e0a771d10..000000000 --- a/spec/unit/faces/catalog_spec.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'puppet/faces' -describe Puppet::Faces[:catalog, '0.0.1'] do - it "should actually have some testing..." -end diff --git a/spec/unit/faces/certificate_request_spec.rb b/spec/unit/faces/certificate_request_spec.rb deleted file mode 100755 index 1a71a8379..000000000 --- a/spec/unit/faces/certificate_request_spec.rb +++ /dev/null @@ -1,3 +0,0 @@ -describe Puppet::Faces[:certificate_request, '0.0.1'] do - it "should actually have some tests..." -end diff --git a/spec/unit/faces/certificate_revocation_list_spec.rb b/spec/unit/faces/certificate_revocation_list_spec.rb deleted file mode 100755 index 4f41edef6..000000000 --- a/spec/unit/faces/certificate_revocation_list_spec.rb +++ /dev/null @@ -1,3 +0,0 @@ -describe Puppet::Faces[:certificate_revocation_list, '0.0.1'] do - it "should actually have some tests..." -end diff --git a/spec/unit/faces/resource_type_spec.rb b/spec/unit/faces/resource_type_spec.rb deleted file mode 100755 index fcbf07520..000000000 --- a/spec/unit/faces/resource_type_spec.rb +++ /dev/null @@ -1,3 +0,0 @@ -describe Puppet::Faces[:resource_type, '0.0.1'] do - it "should actually have some tests..." -end diff --git a/spec/unit/interface/face_collection_spec.rb b/spec/unit/interface/face_collection_spec.rb index 752871035..6ba35b4b2 100755 --- a/spec/unit/interface/face_collection_spec.rb +++ b/spec/unit/interface/face_collection_spec.rb @@ -15,7 +15,7 @@ describe Puppet::Interface::FaceCollection do before :each do @original_faces = subject.instance_variable_get("@faces").dup @original_required = $".dup - $".delete_if do |path| path =~ %r{/faces/.*\.rb$} end + $".delete_if do |path| path =~ %r{/face/.*\.rb$} end subject.instance_variable_get("@faces").clear end @@ -59,82 +59,71 @@ describe Puppet::Interface::FaceCollection do subject.instance_variable_get("@faces")[:foo]['0.0.1'] = 10 end - before :each do - @dir = Dir.mktmpdir - @lib = FileUtils.mkdir_p(File.join @dir, 'puppet', 'faces') - $LOAD_PATH.push(@dir) - end - - after :each do - FileUtils.remove_entry_secure @dir - $LOAD_PATH.pop - end - - it "should return the faces with the given name" do + it "should return the face with the given name" do subject["foo", '0.0.1'].should == 10 end - it "should attempt to load the faces if it isn't found" do - subject.expects(:require).with('puppet/faces/bar') + it "should attempt to load the face if it isn't found" do + subject.expects(:require).with('puppet/face/bar') subject["bar", '0.0.1'] end - it "should attempt to load the default faces for the specified version :current" do - subject.expects(:require).with('puppet/faces/fozzie') + it "should attempt to load the default face for the specified version :current" do + subject.expects(:require).with('puppet/face/fozzie') subject['fozzie', :current] end end describe "::face?" do - it "should return true if the faces specified is registered" do + it "should return true if the face specified is registered" do subject.instance_variable_get("@faces")[:foo]['0.0.1'] = 10 subject.face?("foo", '0.0.1').should == true end - it "should attempt to require the faces if it is not registered" do + it "should attempt to require the face if it is not registered" do subject.expects(:require).with do |file| subject.instance_variable_get("@faces")[:bar]['0.0.1'] = true - file == 'puppet/faces/bar' + file == 'puppet/face/bar' end subject.face?("bar", '0.0.1').should == true end - it "should return true if requiring the faces registered it" do + it "should return true if requiring the face registered it" do subject.stubs(:require).with do subject.instance_variable_get("@faces")[:bar]['0.0.1'] = 20 end end - it "should return false if the faces is not registered" do + it "should return false if the face is not registered" do subject.stubs(:require).returns(true) subject.face?("bar", '0.0.1').should be_false end - it "should return false if the faces file itself is missing" do + it "should return false if the face file itself is missing" do subject.stubs(:require). - raises(LoadError, 'no such file to load -- puppet/faces/bar') + raises(LoadError, 'no such file to load -- puppet/face/bar') subject.face?("bar", '0.0.1').should be_false end it "should register the version loaded by `:current` as `:current`" do subject.expects(:require).with do |file| - subject.instance_variable_get("@faces")[:huzzah]['2.0.1'] = :huzzah_faces - file == 'puppet/faces/huzzah' + subject.instance_variable_get("@faces")[:huzzah]['2.0.1'] = :huzzah_face + file == 'puppet/face/huzzah' end subject.face?("huzzah", :current) - subject.instance_variable_get("@faces")[:huzzah][:current].should == :huzzah_faces + subject.instance_variable_get("@faces")[:huzzah][:current].should == :huzzah_face end context "with something on disk" do - it "should register the version loaded from `puppet/faces/{name}` as `:current`" do + it "should register the version loaded from `puppet/face/{name}` as `:current`" do subject.should be_face "huzzah", '2.0.1' subject.should be_face "huzzah", :current - Puppet::Faces[:huzzah, '2.0.1'].should == Puppet::Faces[:huzzah, :current] + Puppet::Face[:huzzah, '2.0.1'].should == Puppet::Face[:huzzah, :current] end it "should index :current when the code was pre-required" do subject.instance_variable_get("@faces")[:huzzah].should_not be_key :current - require 'puppet/faces/huzzah' + require 'puppet/face/huzzah' subject.face?(:huzzah, :current).should be_true end end @@ -146,10 +135,10 @@ describe Puppet::Interface::FaceCollection do end describe "::register" do - it "should store the faces by name" do - faces = Puppet::Faces.new(:my_faces, '0.0.1') - subject.register(faces) - subject.instance_variable_get("@faces").should == {:my_faces => {'0.0.1' => faces}} + it "should store the face by name" do + face = Puppet::Face.new(:my_face, '0.0.1') + subject.register(face) + subject.instance_variable_get("@faces").should == {:my_face => {'0.0.1' => face}} end end diff --git a/spec/unit/interface_spec.rb b/spec/unit/interface_spec.rb index 7e6b7de77..2365d5cac 100755 --- a/spec/unit/interface_spec.rb +++ b/spec/unit/interface_spec.rb @@ -1,5 +1,5 @@ require 'spec_helper' -require 'puppet/faces' +require 'puppet/face' require 'puppet/interface' describe Puppet::Interface do @@ -116,7 +116,7 @@ describe Puppet::Interface do it "should try to require faces that are not known" do pending "mocking require causes random stack overflow" - subject::FaceCollection.expects(:require).with "puppet/faces/foo" + subject::FaceCollection.expects(:require).with "puppet/face/foo" subject[:foo, '0.0.1'] end diff --git a/spec/unit/util/command_line_spec.rb b/spec/unit/util/command_line_spec.rb index 6cf90475b..b0c2a85ae 100755 --- a/spec/unit/util/command_line_spec.rb +++ b/spec/unit/util/command_line_spec.rb @@ -99,7 +99,7 @@ describe Puppet::Util::CommandLine do Puppet::Util.expects(:which).with('puppet-whatever').returns(nil) commandline.expects(:system).never - text = Puppet::Faces[:help, :current].help + text = Puppet::Face[:help, :current].help commandline.expects(:puts).with { |x| x =~ /Unknown Puppet subcommand/ } commandline.expects(:puts).with text |
