summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorDaniel Pittman <daniel@puppetlabs.com>2011-04-17 18:51:09 -0700
committerDaniel Pittman <daniel@puppetlabs.com>2011-04-19 10:33:08 -0700
commit32c667c79bc0d5151580ea79719f28739945bfb1 (patch)
treeed3857858710603fc771e9183b7155b91708bab4 /lib/puppet
parent0d0318f9f0eadff7f9934d3d02a7081bba05164c (diff)
downloadpuppet-32c667c79bc0d5151580ea79719f28739945bfb1.tar.gz
puppet-32c667c79bc0d5151580ea79719f28739945bfb1.tar.xz
puppet-32c667c79bc0d5151580ea79719f28739945bfb1.zip
(#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 <max@puppetlabs.com>
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/interface.rb9
-rw-r--r--lib/puppet/interface/action.rb15
2 files changed, 22 insertions, 2 deletions
diff --git a/lib/puppet/interface.rb b/lib/puppet/interface.rb
index 5e9355061..4a36b509a 100644
--- a/lib/puppet/interface.rb
+++ b/lib/puppet/interface.rb
@@ -70,9 +70,16 @@ class Puppet::Interface
attr_accessor :summary
def summary(value = nil)
- @summary = value unless value.nil?
+ value.nil? or summary = value
@summary
end
+ 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
attr_reader :name, :version
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