summaryrefslogtreecommitdiffstats
path: root/lib/puppet/application/doc.rb
diff options
context:
space:
mode:
authorJesse Wolfe <jes5199@gmail.com>2010-04-30 16:05:43 -0700
committertest branch <puppet-dev@googlegroups.com>2010-02-17 06:50:53 -0800
commitd038a1d3ddffdf1366c78fe31118e9f15c1c6ed1 (patch)
tree6ff89deef467aa58b8b50ea06200b5d2f2dc97ac /lib/puppet/application/doc.rb
parent7656ba73ddfd883b36a01c81147ae69e80773bce (diff)
downloadpuppet-d038a1d3ddffdf1366c78fe31118e9f15c1c6ed1.tar.gz
puppet-d038a1d3ddffdf1366c78fe31118e9f15c1c6ed1.tar.xz
puppet-d038a1d3ddffdf1366c78fe31118e9f15c1c6ed1.zip
Refactor #3706 Reify eigenclasses of Applications
The Puppet::Application DSL is complicated by the fact that it operates on eigenclasses of instances of Puppet::Application, rather than subclassing it. This patch reifies the eigenclasses as subclasses of Puppet::Application. Signed-off-by: Jesse Wolfe <jes5199@gmail.com>
Diffstat (limited to 'lib/puppet/application/doc.rb')
-rw-r--r--lib/puppet/application/doc.rb22
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/puppet/application/doc.rb b/lib/puppet/application/doc.rb
index 0a11d6045..295cd6771 100644
--- a/lib/puppet/application/doc.rb
+++ b/lib/puppet/application/doc.rb
@@ -7,13 +7,13 @@ require 'puppet/util/rdoc'
$tab = " "
Reference = Puppet::Util::Reference
-Puppet::Application.new(:doc) do
+class Puppet::Application::Doc < Puppet::Application
should_not_parse_config
attr_accessor :unknown_args, :manifest
- preinit do
+ def preinit
{:references => [], :mode => :text, :format => :to_rest }.each do |name,value|
options[name] = value
end
@@ -52,17 +52,17 @@ Puppet::Application.new(:doc) do
options[:references] << arg.intern
end
- unknown do |opt, arg|
+ def handle_unknown( opt, arg )
@unknown_args << {:opt => opt, :arg => arg }
true
end
- dispatch do
- return options[:mode] if [:rdoc, :trac, :markdown].include?(options[:mode])
- return :other
+ def run_command
+ return send(options[:mode]) if [:rdoc, :trac, :markdown].include?(options[:mode])
+ return other
end
- command(:rdoc) do
+ def rdoc
exit_code = 0
files = []
unless @manifest
@@ -93,7 +93,7 @@ Puppet::Application.new(:doc) do
exit exit_code
end
- command(:trac) do
+ def trac
options[:references].each do |name|
section = Puppet::Util::Reference.reference(name) or raise "Could not find section %s" % name
unless options[:mode] == :pdf
@@ -102,7 +102,7 @@ Puppet::Application.new(:doc) do
end
end
- command(:markdown) do
+ def markdown
text = ""
with_contents = false
exit_code = 0
@@ -127,7 +127,7 @@ Puppet::Application.new(:doc) do
exit exit_code
end
- command(:other) do
+ def other
text = ""
if options[:references].length > 1
with_contents = false
@@ -165,7 +165,7 @@ Puppet::Application.new(:doc) do
exit exit_code
end
- setup do
+ def setup
# sole manifest documentation
if Puppet::Util::CommandLine.args.size > 0
options[:mode] = :rdoc