diff options
author | Guillem Jover <guillem@debian.org> | 2015-04-21 17:18:15 +0200 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2015-05-09 05:12:26 +0200 |
commit | 7e85106707c5ddea3381bc985e0c916507915bcc (patch) | |
tree | 54da9f6ed01b6026fd34134d56f3360adcb9de55 /scripts/Dpkg/Control | |
parent | 2a76ceda76f462cea6f50ac740ed95c343ec409e (diff) | |
download | dpkg-7e85106707c5ddea3381bc985e0c916507915bcc.tar.gz |
Dpkg::Control::Info: Allow not loading the file in the constuctor
Accept an %opts argument for the constructor, and accept either passing
a filename option as undef, or a scalar undef.
Closes: #782019
Diffstat (limited to 'scripts/Dpkg/Control')
-rw-r--r-- | scripts/Dpkg/Control/Info.pm | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/scripts/Dpkg/Control/Info.pm b/scripts/Dpkg/Control/Info.pm index 13083c755..dd7b90a30 100644 --- a/scripts/Dpkg/Control/Info.pm +++ b/scripts/Dpkg/Control/Info.pm @@ -19,7 +19,7 @@ package Dpkg::Control::Info; use strict; use warnings; -our $VERSION = '1.00'; +our $VERSION = '1.01'; use Dpkg::Control; use Dpkg::ErrorHandling; @@ -45,26 +45,36 @@ syntax as F<debian/control>. =over 4 -=item $c = Dpkg::Control::Info->new($file) +=item $c = Dpkg::Control::Info->new(%opts) -Create a new Dpkg::Control::Info object for $file. If $file is omitted, it -loads F<debian/control>. If file is "-", it parses the standard input. +Create a new Dpkg::Control::Info object. Loads the file from the filename +option, if no option is specified filename defaults to F<debian/control>. +If a scalar is passed instead, it will be used as the filename. If filename +is "-", it parses the standard input. If filename is undef no loading will +be performed. =cut sub new { - my ($this, $arg) = @_; + my ($this, @args) = @_; my $class = ref($this) || $this; my $self = { source => undef, packages => [], }; bless $self, $class; - if ($arg) { - $self->load($arg); + + my %opts; + if (scalar @args == 0) { + $opts{filename} = 'debian/control'; + } elsif (scalar @args == 1) { + $opts{filename} = $args[0]; } else { - $self->load('debian/control'); + %opts = @args; } + + $self->load($opts{filename}) if $opts{filename}; + return $self; } @@ -203,6 +213,10 @@ information. =head1 CHANGES +=head2 Version 1.01 + +New argument: The $c->new() constructor accepts an %opts argument. + =head2 Version 1.00 Mark the module as public. |