Commits

Shlomi Fish committed 657665a

Add the rpm_dash input format.

Comments (0)

Files changed (2)

Module-Format/Module-Format/lib/Module/Format/Module.pm

         }
         return $class->from({format => 'colon', value => $1});
     }
+    elsif ($format eq 'rpm_dash')
+    {
+        if ($value !~ s{\Aperl-}{})
+        {
+            die "rpm_dash value does not start with the 'perl-' prefix.";
+        }
+        
+        return $class->from({format => 'dash', value => $value});
+    }
     else
     {
         die "Unknown format '$format'!";

Module-Format/Module-Format/t/module.t

 use strict;
 use warnings;
 
-use Test::More tests => 19;
+use Test::More tests => 23;
 
 use Module::Format::Module;
 
         "from rpm_colon Format as dash is sane.",
     );
 }
+
+{
+    my $module = Module::Format::Module->from(
+        {
+            format => 'rpm_dash',
+            value => 'perl-HTML-TreeBuilder-LibXML',
+        }
+    );
+
+    # TEST
+    ok ($module);
+
+    # TEST
+    is_deeply(
+        $module->get_components_list(),
+        [qw(HTML TreeBuilder LibXML)],
+        "get_components_list() is sane.",
+    );
+
+    # TEST
+    is ($module->format_as('colon'), 'HTML::TreeBuilder::LibXML',
+        "Format as colon is sane."
+    );
+
+    # TEST
+    is ($module->format_as('dash'),  'HTML-TreeBuilder-LibXML',
+        "Format as dash is sane.",
+    );
+}