Преглед изворни кода

Dpkg::Changelog::Parse: Refactor changelog_parse into changelog_parse_plugin

Guillem Jover пре 11 година
родитељ
комит
8c368c0005
2 измењених фајлова са 30 додато и 5 уклоњено
  1. 1 0
      debian/changelog
  2. 29 5
      scripts/Dpkg/Changelog/Parse.pm

+ 1 - 0
debian/changelog

@@ -9,6 +9,7 @@ dpkg (1.18.2) UNRELEASED; urgency=low
       Date::Parse in Dpkg::Changelog::Entry::Debian. This reduces the build
       and run-time dependencies, and helps architecture bootstrapping.
     - Simplify distribution splitting in Dpkg::Changelog::Entry::Debian.
+    - Add new function changelog_parse_plugin() in Dpkg::Changelog::Parse.
   * Documentation:
     - Fix grammar in dpkg-architecture(1).
       Thanks to Chris Lamb <lamby@debian.org>. Closes: #787616

+ 29 - 5
scripts/Dpkg/Changelog/Parse.pm

@@ -23,8 +23,8 @@ Dpkg::Changelog::Parse - generic changelog parser for dpkg-parsechangelog
 
 =head1 DESCRIPTION
 
-This module provides a single function changelog_parse() which reproduces
-all the features of dpkg-parsechangelog.
+This module provides a set of functions which reproduce all the features
+of dpkg-parsechangelog.
 
 =cut
 
@@ -33,8 +33,9 @@ package Dpkg::Changelog::Parse;
 use strict;
 use warnings;
 
-our $VERSION = '1.00';
+our $VERSION = '1.01';
 our @EXPORT = qw(
+    changelog_parse_plugin
     changelog_parse
 );
 
@@ -49,7 +50,7 @@ use Dpkg::Control::Changelog;
 
 =over 4
 
-=item $fields = changelog_parse(%opt)
+=item $fields = changelog_parse_plugin(%opt)
 
 This function will parse a changelog. In list context, it returns as many
 Dpkg::Control objects as the parser did output. In scalar context, it will
@@ -77,7 +78,7 @@ it is passed as the parameter that follows.
 
 =cut
 
-sub changelog_parse {
+sub changelog_parse_plugin {
     my (%options) = @_;
     my @parserpath = ('/usr/local/lib/dpkg/parsechangelog',
                       "$Dpkg::LIBDIR/parsechangelog",
@@ -163,10 +164,33 @@ sub changelog_parse {
     }
 }
 
+=item $fields = changelog_parse(%opt)
+
+This function will parse a changelog. In list context, it returns as many
+Dpkg::Control objects as the parser did create. In scalar context, it will
+return only the first one. If the parser did not return any data, it will
+return an empty list in list context or undef on scalar context. If the
+parser failed, it will die.
+
+The changelog file that is parsed is F<debian/changelog> by default but it
+can be overridden with $opt{file}.
+
+=cut
+
+sub changelog_parse {
+    my (%options) = @_;
+
+    return changelog_parse_plugin(%options);
+}
+
 =back
 
 =head1 CHANGES
 
+=head2 Version 1.01 (dpkg 1.18.2)
+
+New functions: changelog_parse_plugin().
+
 =head2 Version 1.00 (dpkg 1.15.6)
 
 Mark the module as public.