[DRE-commits] [SCM] ruby-debian-doc.git branch, master, updated. 565da9dc9eb8eaece8548fe1e77f45266785bdcf

Antonio Terceiro terceiro at softwarelivre.org
Sat Dec 31 20:57:47 UTC 2011


The following commit has been merged in the master branch:
commit 565da9dc9eb8eaece8548fe1e77f45266785bdcf
Author: Antonio Terceiro <terceiro at softwarelivre.org>
Date:   Sat Dec 31 14:50:18 2011 -0200

    Don't crash with packages without Ruby code

diff --git a/features/build.feature b/features/build.feature
index aef4638..5011fb5 100644
--- a/features/build.feature
+++ b/features/build.feature
@@ -10,3 +10,8 @@ Feature: build documentation
     When I run "ruby-debian-doc ruby-foobarbaz"
     Then the error output should be empty
     And the output should contain "ruby-foobarbaz is not installed"
+
+  Scenario: non-Ruby package
+    When I run "ruby-debian-doc dpkg"
+    Then the error output should be empty
+    And the output should contain "dpkg does not look like Ruby software"
diff --git a/lib/debian-doc/cli.rb b/lib/debian-doc/cli.rb
index 52b45ac..688aa94 100644
--- a/lib/debian-doc/cli.rb
+++ b/lib/debian-doc/cli.rb
@@ -17,6 +17,8 @@ module Debian
           Kernel.system("xdg-open", index)
         rescue Debian::Doc::Package::NotFound
           puts "#{args.first} is not installed"
+        rescue Debian::Doc::Writer::NotRubySoftware
+          puts "#{args.first} does not look like Ruby software"
         end
 
       end
diff --git a/lib/debian-doc/writer.rb b/lib/debian-doc/writer.rb
index 29372e2..c9e0dad 100644
--- a/lib/debian-doc/writer.rb
+++ b/lib/debian-doc/writer.rb
@@ -5,7 +5,11 @@ module Debian
 
     class Writer
 
+      class NotRubySoftware < Exception; end
+
       def write(package)
+        raise NotRubySoftware if package.code.empty?
+
         output_directory = File.join(base_output_dir, package.name)
 
         rebuild = true
diff --git a/spec/debian-doc/writer_spec.rb b/spec/debian-doc/writer_spec.rb
index 692c8d8..fbbf5e0 100644
--- a/spec/debian-doc/writer_spec.rb
+++ b/spec/debian-doc/writer_spec.rb
@@ -56,4 +56,9 @@ describe Debian::Doc::Writer do
     TestBackend.instance.times_called.should == 2
   end
 
+  it 'does not accept non-Ruby packages' do
+    @package.stub(:files) { [] }
+    (lambda { @writer.write(@package) }).should raise_exception(Debian::Doc::Writer::NotRubySoftware)
+  end
+
 end

-- 
ruby-debian-doc.git



More information about the Pkg-ruby-extras-commits mailing list