This should allow to run puppetdoc on ruby 1.8.5.

Signed-off-by: Brice Figureau <[email protected]>
---
 lib/puppet/util/rdoc.rb     |    9 +++++----
 spec/unit/util/rdoc_spec.rb |   10 +++++++++-
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/lib/puppet/util/rdoc.rb b/lib/puppet/util/rdoc.rb
index 085d8ec..bdac579 100644
--- a/lib/puppet/util/rdoc.rb
+++ b/lib/puppet/util/rdoc.rb
@@ -10,24 +10,25 @@ module Puppet::Util::RDoc
 
       # then rdoc
       require 'rdoc/rdoc'
+      require 'rdoc/options'
 
       # load our parser
       require 'puppet/util/rdoc/parser'
 
       r = RDoc::RDoc.new
 
-        RDoc::RDoc::GENERATORS["puppet"] = RDoc::RDoc::Generator.new(
+      RDoc::RDoc::GENERATORS["puppet"] = RDoc::RDoc::Generator.new(
           "puppet/util/rdoc/generators/puppet_generator.rb",
-            "PuppetGenerator".intern,
+          "PuppetGenerator".intern,
+          "puppet")
 
-            "puppet")
       # specify our own format & where to output
       options = [ "--fmt", "puppet",
         "--quiet",
-        "--force-update",
         "--exclude", "/modules/[^/]*/files/.*\.pp$",
         "--op", outputdir ]
 
+      options << "--force-update" if Options::OptionList.options.any? { |o| 
o[0] == "--force-update" }
       options += [ "--charset", charset] if charset
       options += files
 
diff --git a/spec/unit/util/rdoc_spec.rb b/spec/unit/util/rdoc_spec.rb
index 58c2034..41d4b9c 100755
--- a/spec/unit/util/rdoc_spec.rb
+++ b/spec/unit/util/rdoc_spec.rb
@@ -43,12 +43,20 @@ describe Puppet::Util::RDoc do
       Puppet::Util::RDoc.rdoc("output", [], "utf-8")
     end
 
-    it "should tell RDoc to force updates of indices" do
+    it "should tell RDoc to force updates of indices when RDoc supports it" do
+      Options::OptionList.stubs(:options).returns([["--force-update", "-U", 0 
]])
       @rdoc.expects(:document).with { |args| args.include?("--force-update") }
 
       Puppet::Util::RDoc.rdoc("output", [])
     end
 
+    it "should not tell RDoc to force updates of indices when RDoc doesn't 
support it" do
+      Options::OptionList.stubs(:options).returns([])
+      @rdoc.expects(:document).never.with { |args| 
args.include?("--force-update") }
+
+      Puppet::Util::RDoc.rdoc("output", [])
+    end
+
     it "should tell RDoc to use the given outputdir" do
       @rdoc.expects(:document).with { |args| args.include?("--op") and 
args.include?("myoutputdir") }
 
-- 
1.7.2.1

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to