From 32c667c79bc0d5151580ea79719f28739945bfb1 Mon Sep 17 00:00:00 2001 From: Daniel Pittman Date: Sun, 17 Apr 2011 18:51:09 -0700 Subject: (#7132) Reject 'summary' text with newlines embedded. Our summary documentation is used to provide single-line context to faces, actions, and other items. To support this we hard-fail if someone tries to use the summary to embed the long documentation, and point them to the right place to add the extended text. Reviewed-By: Max Martin --- lib/puppet/interface/action.rb | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'lib/puppet/interface') diff --git a/lib/puppet/interface/action.rb b/lib/puppet/interface/action.rb index b94298963..d2d4facaa 100644 --- a/lib/puppet/interface/action.rb +++ b/lib/puppet/interface/action.rb @@ -24,8 +24,21 @@ class Puppet::Interface::Action attr_reader :name def to_s() "#{@face}##{@name}" end - attr_accessor :default, :summary + attr_accessor :default + ######################################################################## + # Documentation stuff, whee! + attr_accessor :summary + def summary=(value) + value = value.to_s + value =~ /\n/ and + raise ArgumentError, "Face summary should be a single line; put the long text in 'description' instead." + + @summary = value + end + + + ######################################################################## # Initially, this was defined to allow the @action.invoke pattern, which is # a very natural way to invoke behaviour given our introspection # capabilities. Heck, our initial plan was to have the faces delegate to -- cgit