diff options
| author | Dominic Maraglia <dmaraglia@gmail.com> | 2011-05-03 17:59:26 -0700 |
|---|---|---|
| committer | Dominic Maraglia <dmaraglia@gmail.com> | 2011-05-03 17:59:26 -0700 |
| commit | e5b62d7424da24799c4d16f0e104fac3008e2b89 (patch) | |
| tree | 7d2d710fa43c39dd35d96cc2db371c548a85518f /lib/puppet/interface | |
| parent | 94f0b0996ba628f4916bcf0978b29c584c15818b (diff) | |
| parent | d203853bc8b40732c2ba88a4e5396f00a1e3a4ec (diff) | |
Merge branch '2.7.x' of github.com:puppetlabs/puppet into 2.7.x
Diffstat (limited to 'lib/puppet/interface')
| -rw-r--r-- | lib/puppet/interface/action.rb | 13 | ||||
| -rw-r--r-- | lib/puppet/interface/documentation.rb | 5 | ||||
| -rw-r--r-- | lib/puppet/interface/face_collection.rb | 1 |
3 files changed, 15 insertions, 4 deletions
diff --git a/lib/puppet/interface/action.rb b/lib/puppet/interface/action.rb index 203d80827..622371a4e 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}") @@ -74,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 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}}/, '') 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 |
