Instead of just returning vague values, return useful information when rendering for a human being.
Based on work by Luke Kaines <[email protected]> in https://github.com/lak/puppet/commit/a61cc770ca9b2cad744b5b21b9776a834d6ca895 Reviewed-By: Pieter van de Bruggen <[email protected]> --- lib/puppet/face/plugin.rb | 12 ++++++++++++ spec/unit/face/{file_spec.rb => plugin_spec.rb} | 6 ++---- 2 files changed, 14 insertions(+), 4 deletions(-) copy spec/unit/face/{file_spec.rb => plugin_spec.rb} (53%) diff --git a/lib/puppet/face/plugin.rb b/lib/puppet/face/plugin.rb index 1906094..4b45ed3 100644 --- a/lib/puppet/face/plugin.rb +++ b/lib/puppet/face/plugin.rb @@ -7,6 +7,10 @@ Puppet::Face.define(:plugin, '0.0.1') do action :download do summary "Download plugins from the configured master" + returns <<-EOT + An array containing the files actually downloaded. + This will be empty array when everything was in sync. + EOT when_invoked do |options| require 'puppet/configurer/downloader' @@ -15,5 +19,13 @@ Puppet::Face.define(:plugin, '0.0.1') do Puppet[:pluginsource], Puppet[:pluginsignore]).evaluate end + + when_rendering :for_humans do |value| + if value.empty? then + "No plugins downloaded." + else + "Downloaded these plugins: #{value.join(', ')}" + end + end end end diff --git a/spec/unit/face/file_spec.rb b/spec/unit/face/plugin_spec.rb similarity index 53% copy from spec/unit/face/file_spec.rb copy to spec/unit/face/plugin_spec.rb index c3f0572..383aaa3 100755 --- a/spec/unit/face/file_spec.rb +++ b/spec/unit/face/plugin_spec.rb @@ -2,10 +2,8 @@ require 'spec_helper' require 'puppet/face' -describe Puppet::Face[:file, '0.0.1'] do - it_should_behave_like "an indirector face" - - [:download, :store].each do |action| +describe Puppet::Face[:plugin, '0.0.1'] do + [:download].each do |action| it { should be_action action } it { should respond_to action } end -- 1.7.5 -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
