# File lib/puppet/application/describe.rb, line 5 def initialize(width) @width = width end
# File lib/puppet/application/describe.rb, line 31 def header(txt, sep = "-") "\n#{txt}\n" + sep * txt.size end
# File lib/puppet/application/describe.rb, line 9 def wrap(txt, opts) return "" unless txt && !txt.empty? work = (opts[:scrub] ? scrub(txt) : txt) indent = (opts[:indent] ? opts[:indent] : 0) textLen = @width - indent patt = Regexp.new("^(.{0,#{textLen}})[ \n]") prefix = " " * indent res = [] while work.length > textLen if work =~ patt res << $1 work.slice!(0, $MATCH.length) else res << work.slice!(0, textLen) end end res << work if work.length.nonzero? prefix + res.join("\n#{prefix}") end