From 0d6ac040f4223725586c2b5d71ffcb0d36206080 Mon Sep 17 00:00:00 2001 From: Daniel Pittman Date: Tue, 3 May 2011 13:33:43 -0700 Subject: maint: remove emacs 'coding' cookie from files. This is unnecessary, and only turned up because Matz &c. impose their taste on the rest of the world through the Emacs Ruby mode. Since people are starting to clone that, and it doesn't add value, eliminate it everywhere. Reviewed-By: Pieter van de Bruggen --- lib/puppet/interface/face_collection.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/puppet/interface') diff --git a/lib/puppet/interface/face_collection.rb b/lib/puppet/interface/face_collection.rb index baa424692..12d3c56b1 100644 --- a/lib/puppet/interface/face_collection.rb +++ b/lib/puppet/interface/face_collection.rb @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- require 'puppet/interface' module Puppet::Interface::FaceCollection -- cgit From 5490f7aee19f477914520f0735858f58136122e4 Mon Sep 17 00:00:00 2001 From: Daniel Pittman Date: Tue, 3 May 2011 14:38:57 -0700 Subject: (#6962) Added 'returns' block to action documentation. We want to be able to document the data returned from an action, since this is one of the most critical parts of the API for Ruby developers. This adds a multiline documentation block that captures that. Reviewed-By: Pieter van de Bruggen --- lib/puppet/interface/action.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/puppet/interface') diff --git a/lib/puppet/interface/action.rb b/lib/puppet/interface/action.rb index 203d80827..d4cf23fce 100644 --- a/lib/puppet/interface/action.rb +++ b/lib/puppet/interface/action.rb @@ -3,6 +3,7 @@ require 'puppet/interface/documentation' require 'prettyprint' class Puppet::Interface::Action + extend Puppet::Interface::DocGen include Puppet::Interface::FullDocs def initialize(face, name, attrs = {}) @@ -44,6 +45,7 @@ class Puppet::Interface::Action ######################################################################## # Documentation... + attr_doc :returns def synopsis output = PrettyPrint.format do |s| s.text("puppet #{@face.name}") -- cgit From 8f81f56e8315a62e6c8ff8943c64df7594855359 Mon Sep 17 00:00:00 2001 From: Daniel Pittman Date: Tue, 3 May 2011 15:51:02 -0700 Subject: (#7326) Fix faces on Ruby 1.8.5 Turns out that String#each_line on Ruby 1.8.5 only takes a block, and will not return an enumerable. Rewrite to use split(/\n/) which has the same effect but works on all our platforms. --- lib/puppet/interface/documentation.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/puppet/interface') diff --git a/lib/puppet/interface/documentation.rb b/lib/puppet/interface/documentation.rb index 91db0e074..48e9a8b1a 100644 --- a/lib/puppet/interface/documentation.rb +++ b/lib/puppet/interface/documentation.rb @@ -6,7 +6,10 @@ class Puppet::Interface # We need to identify an indent: the minimum number of whitespace # characters at the start of any line in the text. - indent = text.each_line.map {|x| x.index(/[^\s]/) }.compact.min + # + # Using split rather than each_line is because the later only takes a + # block on Ruby 1.8.5 / Centos, and we support that. --daniel 2011-05-03 + indent = text.split(/\n/).map {|x| x.index(/[^\s]/) }.compact.min if indent > 0 then text.gsub!(/^[ \t\f]{0,#{indent}}/, '') -- cgit From 18b3584e16515cfc45aeaa8d0913de8e8bcb3e95 Mon Sep 17 00:00:00 2001 From: Daniel Pittman Date: Mon, 2 May 2011 16:27:28 -0700 Subject: (#7329) Consistent naming for rendering formats and hooks. We refer to rendering formats pretty consistently as `json`, `yaml`, `s`, and so forth; unqualified names. On the other hand, we refer to the rendering hooks *mostly* as `to_*`, except the `:for_humans` and `:json` formats. Which is kind of confusing because of the internal inconsistency, and because it doesn't match the public name. Fix the code to resolve both, so the `to_*` format still works, but we mostly expect to use the `*` version, to match public expectation. --- lib/puppet/interface/action.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lib/puppet/interface') diff --git a/lib/puppet/interface/action.rb b/lib/puppet/interface/action.rb index d4cf23fce..622371a4e 100644 --- a/lib/puppet/interface/action.rb +++ b/lib/puppet/interface/action.rb @@ -76,8 +76,15 @@ class Puppet::Interface::Action unless type.is_a? Symbol raise ArgumentError, "The rendering format must be a symbol, not #{type.class.name}" end - return unless @when_rendering.has_key? type - return @when_rendering[type].bind(@face) + # Do we have a rendering hook for this name? + return @when_rendering[type].bind(@face) if @when_rendering.has_key? type + + # How about by another name? + alt = type.to_s.sub(/^to_/, '').to_sym + return @when_rendering[alt].bind(@face) if @when_rendering.has_key? alt + + # Guess not, nothing to run. + return nil end def set_rendering_method_for(type, proc) unless proc.is_a? Proc -- cgit