r56282 - in /branches/upstream/libversion-requirements-perl/current: Changes MANIFEST META.json META.yml Makefile.PL README lib/Version/Requirements.pm t/accepts.t t/finalize.t t/release-pod-coverage.t
ansgar-guest at users.alioth.debian.org
ansgar-guest at users.alioth.debian.org
Sat Apr 17 07:55:28 UTC 2010
Author: ansgar-guest
Date: Sat Apr 17 07:55:17 2010
New Revision: 56282
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=56282
Log:
[svn-upgrade] Integrating new upstream version, libversion-requirements-perl (0.101020)
Added:
branches/upstream/libversion-requirements-perl/current/t/finalize.t
Removed:
branches/upstream/libversion-requirements-perl/current/t/release-pod-coverage.t
Modified:
branches/upstream/libversion-requirements-perl/current/Changes
branches/upstream/libversion-requirements-perl/current/MANIFEST
branches/upstream/libversion-requirements-perl/current/META.json
branches/upstream/libversion-requirements-perl/current/META.yml
branches/upstream/libversion-requirements-perl/current/Makefile.PL
branches/upstream/libversion-requirements-perl/current/README
branches/upstream/libversion-requirements-perl/current/lib/Version/Requirements.pm
branches/upstream/libversion-requirements-perl/current/t/accepts.t
Modified: branches/upstream/libversion-requirements-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libversion-requirements-perl/current/Changes?rev=56282&op=diff
==============================================================================
--- branches/upstream/libversion-requirements-perl/current/Changes (original)
+++ branches/upstream/libversion-requirements-perl/current/Changes Sat Apr 17 07:55:17 2010
@@ -1,6 +1,12 @@
Revision history for Version-Requirements
-0.100660 2010-03-07 13:04:25 America/New_York
+0.101020 2010-04-12 09:08:26 America/New_York
+ add finalization with ->finalize and ->is_finalized
+
+0.101010 2010-04-11 10:20:02 America/New_York
+ add a public accepts_module version
+
+0.100660 2010-03-07 13:05:59 America/New_York
specify that we need version.pm 0.77
0.100630 2010-03-04 22:54:15 America/New_York
Modified: branches/upstream/libversion-requirements-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libversion-requirements-perl/current/MANIFEST?rev=56282&op=diff
==============================================================================
--- branches/upstream/libversion-requirements-perl/current/MANIFEST (original)
+++ branches/upstream/libversion-requirements-perl/current/MANIFEST Sat Apr 17 07:55:17 2010
@@ -9,7 +9,7 @@
lib/Version/Requirements.pm
t/accepts.t
t/basic.t
+t/finalize.t
t/from-hash.t
t/merge.t
-t/release-pod-coverage.t
t/release-pod-syntax.t
Modified: branches/upstream/libversion-requirements-perl/current/META.json
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libversion-requirements-perl/current/META.json?rev=56282&op=diff
==============================================================================
--- branches/upstream/libversion-requirements-perl/current/META.json (original)
+++ branches/upstream/libversion-requirements-perl/current/META.json Sat Apr 17 07:55:17 2010
@@ -1,28 +1,196 @@
{
+ "abstract" : "a set of version requirements for a CPAN dist",
+ "author" : [
+ "Ricardo Signes <rjbs at cpan.org>"
+ ],
+ "build_requires" : {
+ "Test::More" : "0.88"
+ },
+ "configure_requires" : {
+ "ExtUtils::MakeMaker" : "6.31"
+ },
+ "generated_by" : "Dist::Zilla version 2.100991",
+ "license" : "perl",
+ "meta-spec" : {
+ "url" : "http://module-build.sourceforge.net/META-spec-v1.4.html",
+ "version" : 1.4
+ },
+ "name" : "Version-Requirements",
+ "recommends" : {},
+ "requires" : {
+ "Carp" : "0",
+ "Scalar::Util" : "0",
+ "version" : "0.77"
+ },
"resources" : {
"repository" : "git://git.codesimply.com/Version-Requirements.git"
},
- "meta-spec" : {
- "version" : 1.4,
- "url" : "http://module-build.sourceforge.net/META-spec-v1.4.html"
- },
- "generated_by" : "Dist::Zilla version 1.100660",
- "version" : "0.100660",
- "name" : "Version-Requirements",
- "author" : [
- "Ricardo Signes <rjbs at cpan.org>"
- ],
- "license" : "perl",
- "build_requires" : {},
- "requires" : {
- "Scalar::Util" : "0",
- "Test::More" : "0.88",
- "version" : "0.77",
- "Carp" : "0"
- },
- "abstract" : "a set of version requirements for a CPAN dist",
- "configure_requires" : {
- "ExtUtils::MakeMaker" : "6.11"
+ "version" : "0.101020",
+ "x_Dist_Zilla" : {
+ "plugins" : [
+ {
+ "class" : "Dist::Zilla::Plugin::GatherDir",
+ "name" : "@RJBS/@Basic/GatherDir",
+ "version" : "2.100991"
+ },
+ {
+ "class" : "Dist::Zilla::Plugin::PruneCruft",
+ "name" : "@RJBS/@Basic/PruneCruft",
+ "version" : "2.100991"
+ },
+ {
+ "class" : "Dist::Zilla::Plugin::ManifestSkip",
+ "name" : "@RJBS/@Basic/ManifestSkip",
+ "version" : "2.100991"
+ },
+ {
+ "class" : "Dist::Zilla::Plugin::MetaYAML",
+ "name" : "@RJBS/@Basic/MetaYAML",
+ "version" : "2.100991"
+ },
+ {
+ "class" : "Dist::Zilla::Plugin::License",
+ "name" : "@RJBS/@Basic/License",
+ "version" : "2.100991"
+ },
+ {
+ "class" : "Dist::Zilla::Plugin::Readme",
+ "name" : "@RJBS/@Basic/Readme",
+ "version" : "2.100991"
+ },
+ {
+ "class" : "Dist::Zilla::Plugin::ExtraTests",
+ "name" : "@RJBS/@Basic/ExtraTests",
+ "version" : "2.100991"
+ },
+ {
+ "class" : "Dist::Zilla::Plugin::ExecDir",
+ "name" : "@RJBS/@Basic/ExecDir",
+ "version" : "2.100991"
+ },
+ {
+ "class" : "Dist::Zilla::Plugin::ShareDir",
+ "name" : "@RJBS/@Basic/ShareDir",
+ "version" : "2.100991"
+ },
+ {
+ "class" : "Dist::Zilla::Plugin::MakeMaker",
+ "name" : "@RJBS/@Basic/MakeMaker",
+ "version" : "2.100991"
+ },
+ {
+ "class" : "Dist::Zilla::Plugin::Manifest",
+ "name" : "@RJBS/@Basic/Manifest",
+ "version" : "2.100991"
+ },
+ {
+ "class" : "Dist::Zilla::Plugin::TestRelease",
+ "name" : "@RJBS/@Basic/TestRelease",
+ "version" : "2.100991"
+ },
+ {
+ "class" : "Dist::Zilla::Plugin::ConfirmRelease",
+ "name" : "@RJBS/@Basic/ConfirmRelease",
+ "version" : "2.100991"
+ },
+ {
+ "class" : "Dist::Zilla::Plugin::UploadToCPAN",
+ "name" : "@RJBS/@Basic/UploadToCPAN",
+ "version" : "2.100991"
+ },
+ {
+ "class" : "Dist::Zilla::Plugin::AutoPrereq",
+ "name" : "@RJBS/AutoPrereq",
+ "version" : "2.100991"
+ },
+ {
+ "class" : "Dist::Zilla::Plugin::AutoVersion",
+ "name" : "@RJBS/AutoVersion",
+ "version" : "2.100991"
+ },
+ {
+ "class" : "Dist::Zilla::Plugin::PkgVersion",
+ "name" : "@RJBS/PkgVersion",
+ "version" : "2.100991"
+ },
+ {
+ "class" : "Dist::Zilla::Plugin::MetaConfig",
+ "name" : "@RJBS/MetaConfig",
+ "version" : "2.100991"
+ },
+ {
+ "class" : "Dist::Zilla::Plugin::MetaJSON",
+ "name" : "@RJBS/MetaJSON",
+ "version" : "2.100991"
+ },
+ {
+ "class" : "Dist::Zilla::Plugin::NextRelease",
+ "name" : "@RJBS/NextRelease",
+ "version" : "2.100991"
+ },
+ {
+ "class" : "Dist::Zilla::Plugin::PodSyntaxTests",
+ "name" : "@RJBS/PodSyntaxTests",
+ "version" : "2.100991"
+ },
+ {
+ "class" : "Dist::Zilla::Plugin::PodWeaver",
+ "name" : "@RJBS/PodWeaver",
+ "version" : "3.100710"
+ },
+ {
+ "class" : "Dist::Zilla::Plugin::Repository",
+ "name" : "@RJBS/Repository",
+ "version" : "0.11"
+ },
+ {
+ "class" : "Dist::Zilla::Plugin::Git::Check",
+ "name" : "@RJBS/@Git/Check",
+ "version" : "1.100970"
+ },
+ {
+ "class" : "Dist::Zilla::Plugin::Git::Commit",
+ "name" : "@RJBS/@Git/Commit",
+ "version" : "1.100970"
+ },
+ {
+ "class" : "Dist::Zilla::Plugin::Git::Tag",
+ "name" : "@RJBS/@Git/Tag",
+ "version" : "1.100970"
+ },
+ {
+ "class" : "Dist::Zilla::Plugin::Git::Push",
+ "name" : "@RJBS/@Git/Push",
+ "version" : "1.100970"
+ },
+ {
+ "class" : "Dist::Zilla::Plugin::FinderCode",
+ "name" : ":InstallModules",
+ "version" : "2.100991"
+ },
+ {
+ "class" : "Dist::Zilla::Plugin::FinderCode",
+ "name" : ":TestFiles",
+ "version" : "2.100991"
+ },
+ {
+ "class" : "Dist::Zilla::Plugin::FinderCode",
+ "name" : ":ExecFiles",
+ "version" : "2.100991"
+ },
+ {
+ "class" : "Dist::Zilla::Plugin::FinderCode",
+ "name" : ":ShareFiles",
+ "version" : "2.100991"
+ }
+ ],
+ "zilla" : {
+ "class" : "Dist::Zilla",
+ "config" : {
+ "is_trial" : 0
+ },
+ "version" : "2.100991"
+ }
}
}
Modified: branches/upstream/libversion-requirements-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libversion-requirements-perl/current/META.yml?rev=56282&op=diff
==============================================================================
--- branches/upstream/libversion-requirements-perl/current/META.yml (original)
+++ branches/upstream/libversion-requirements-perl/current/META.yml Sat Apr 17 07:55:17 2010
@@ -2,20 +2,152 @@
abstract: 'a set of version requirements for a CPAN dist'
author:
- 'Ricardo Signes <rjbs at cpan.org>'
-build_requires: {}
+build_requires:
+ Test::More: 0.88
configure_requires:
- ExtUtils::MakeMaker: 6.11
-generated_by: 'Dist::Zilla version 1.100660'
+ ExtUtils::MakeMaker: 6.31
+generated_by: 'Dist::Zilla version 2.100991'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
name: Version-Requirements
+recommends: {}
requires:
Carp: 0
Scalar::Util: 0
- Test::More: 0.88
version: 0.77
resources:
repository: git://git.codesimply.com/Version-Requirements.git
-version: 0.100660
+version: 0.101020
+x_Dist_Zilla:
+ plugins:
+ -
+ class: Dist::Zilla::Plugin::GatherDir
+ name: '@RJBS/@Basic/GatherDir'
+ version: 2.100991
+ -
+ class: Dist::Zilla::Plugin::PruneCruft
+ name: '@RJBS/@Basic/PruneCruft'
+ version: 2.100991
+ -
+ class: Dist::Zilla::Plugin::ManifestSkip
+ name: '@RJBS/@Basic/ManifestSkip'
+ version: 2.100991
+ -
+ class: Dist::Zilla::Plugin::MetaYAML
+ name: '@RJBS/@Basic/MetaYAML'
+ version: 2.100991
+ -
+ class: Dist::Zilla::Plugin::License
+ name: '@RJBS/@Basic/License'
+ version: 2.100991
+ -
+ class: Dist::Zilla::Plugin::Readme
+ name: '@RJBS/@Basic/Readme'
+ version: 2.100991
+ -
+ class: Dist::Zilla::Plugin::ExtraTests
+ name: '@RJBS/@Basic/ExtraTests'
+ version: 2.100991
+ -
+ class: Dist::Zilla::Plugin::ExecDir
+ name: '@RJBS/@Basic/ExecDir'
+ version: 2.100991
+ -
+ class: Dist::Zilla::Plugin::ShareDir
+ name: '@RJBS/@Basic/ShareDir'
+ version: 2.100991
+ -
+ class: Dist::Zilla::Plugin::MakeMaker
+ name: '@RJBS/@Basic/MakeMaker'
+ version: 2.100991
+ -
+ class: Dist::Zilla::Plugin::Manifest
+ name: '@RJBS/@Basic/Manifest'
+ version: 2.100991
+ -
+ class: Dist::Zilla::Plugin::TestRelease
+ name: '@RJBS/@Basic/TestRelease'
+ version: 2.100991
+ -
+ class: Dist::Zilla::Plugin::ConfirmRelease
+ name: '@RJBS/@Basic/ConfirmRelease'
+ version: 2.100991
+ -
+ class: Dist::Zilla::Plugin::UploadToCPAN
+ name: '@RJBS/@Basic/UploadToCPAN'
+ version: 2.100991
+ -
+ class: Dist::Zilla::Plugin::AutoPrereq
+ name: '@RJBS/AutoPrereq'
+ version: 2.100991
+ -
+ class: Dist::Zilla::Plugin::AutoVersion
+ name: '@RJBS/AutoVersion'
+ version: 2.100991
+ -
+ class: Dist::Zilla::Plugin::PkgVersion
+ name: '@RJBS/PkgVersion'
+ version: 2.100991
+ -
+ class: Dist::Zilla::Plugin::MetaConfig
+ name: '@RJBS/MetaConfig'
+ version: 2.100991
+ -
+ class: Dist::Zilla::Plugin::MetaJSON
+ name: '@RJBS/MetaJSON'
+ version: 2.100991
+ -
+ class: Dist::Zilla::Plugin::NextRelease
+ name: '@RJBS/NextRelease'
+ version: 2.100991
+ -
+ class: Dist::Zilla::Plugin::PodSyntaxTests
+ name: '@RJBS/PodSyntaxTests'
+ version: 2.100991
+ -
+ class: Dist::Zilla::Plugin::PodWeaver
+ name: '@RJBS/PodWeaver'
+ version: 3.100710
+ -
+ class: Dist::Zilla::Plugin::Repository
+ name: '@RJBS/Repository'
+ version: 0.11
+ -
+ class: Dist::Zilla::Plugin::Git::Check
+ name: '@RJBS/@Git/Check'
+ version: 1.100970
+ -
+ class: Dist::Zilla::Plugin::Git::Commit
+ name: '@RJBS/@Git/Commit'
+ version: 1.100970
+ -
+ class: Dist::Zilla::Plugin::Git::Tag
+ name: '@RJBS/@Git/Tag'
+ version: 1.100970
+ -
+ class: Dist::Zilla::Plugin::Git::Push
+ name: '@RJBS/@Git/Push'
+ version: 1.100970
+ -
+ class: Dist::Zilla::Plugin::FinderCode
+ name: ':InstallModules'
+ version: 2.100991
+ -
+ class: Dist::Zilla::Plugin::FinderCode
+ name: ':TestFiles'
+ version: 2.100991
+ -
+ class: Dist::Zilla::Plugin::FinderCode
+ name: ':ExecFiles'
+ version: 2.100991
+ -
+ class: Dist::Zilla::Plugin::FinderCode
+ name: ':ShareFiles'
+ version: 2.100991
+ zilla:
+ class: Dist::Zilla
+ config:
+ is_trial: 0
+ version: 2.100991
Modified: branches/upstream/libversion-requirements-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libversion-requirements-perl/current/Makefile.PL?rev=56282&op=diff
==============================================================================
--- branches/upstream/libversion-requirements-perl/current/Makefile.PL (original)
+++ branches/upstream/libversion-requirements-perl/current/Makefile.PL Sat Apr 17 07:55:17 2010
@@ -4,7 +4,7 @@
-use ExtUtils::MakeMaker 6.11;
+use ExtUtils::MakeMaker 6.31;
@@ -15,16 +15,17 @@
'NAME' => 'Version::Requirements',
'DISTNAME' => 'Version-Requirements',
'CONFIGURE_REQUIRES' => {
- 'ExtUtils::MakeMaker' => '6.11'
+ 'ExtUtils::MakeMaker' => '6.31'
},
'AUTHOR' => 'Ricardo Signes <rjbs at cpan.org>',
- 'BUILD_REQUIRES' => {},
+ 'BUILD_REQUIRES' => {
+ 'Test::More' => '0.88'
+ },
'ABSTRACT' => 'a set of version requirements for a CPAN dist',
'EXE_FILES' => [],
- 'VERSION' => '0.100660',
+ 'VERSION' => '0.101020',
'PREREQ_PM' => {
'Scalar::Util' => '0',
- 'Test::More' => '0.88',
'version' => '0.77',
'Carp' => '0'
},
@@ -32,8 +33,11 @@
);
-delete $WriteMakefileArgs{LICENSE}
- unless eval { ExtUtils::MakeMaker->VERSION(6.31) };
+delete $WriteMakefileArgs{BUILD_REQUIRES}
+ unless eval { ExtUtils::MakeMaker->VERSION(6.56) };
+
+delete $WriteMakefileArgs{CONFIGURE_REQUIRES}
+ unless eval { ExtUtils::MakeMaker->VERSION(6.52) };
WriteMakefile(%WriteMakefileArgs);
Modified: branches/upstream/libversion-requirements-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libversion-requirements-perl/current/README?rev=56282&op=diff
==============================================================================
--- branches/upstream/libversion-requirements-perl/current/README (original)
+++ branches/upstream/libversion-requirements-perl/current/README Sat Apr 17 07:55:17 2010
@@ -1,7 +1,7 @@
-This archive contains the distribution Version-Requirements, version
-0.100660:
+This archive contains the distribution Version-Requirements,
+version 0.101020:
a set of version requirements for a CPAN dist
@@ -10,3 +10,4 @@
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
+
Modified: branches/upstream/libversion-requirements-perl/current/lib/Version/Requirements.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libversion-requirements-perl/current/lib/Version/Requirements.pm?rev=56282&op=diff
==============================================================================
--- branches/upstream/libversion-requirements-perl/current/lib/Version/Requirements.pm (original)
+++ branches/upstream/libversion-requirements-perl/current/lib/Version/Requirements.pm Sat Apr 17 07:55:17 2010
@@ -1,7 +1,9 @@
use strict;
use warnings;
package Version::Requirements;
-our $VERSION = '0.100660';
+BEGIN {
+ $Version::Requirements::VERSION = '0.101020';
+}
# ABSTRACT: a set of version requirements for a CPAN dist
@@ -36,9 +38,7 @@
$version = $self->_version_object( $version );
- my $old = $self->{ $name } || 'Version::Requirements::_Spec::Range';
-
- $self->{ $name } = $old->$method($version);
+ $self->__modify_entry_for($name, $method, $version);
return $self;
};
@@ -64,15 +64,31 @@
}
+sub accepts_module {
+ my ($self, $module, $version) = @_;
+
+ $version = $self->_version_object( $version );
+
+ return 1 unless my $range = $self->__entry_for($module);
+ return $range->_accepts($version);
+}
+
+
sub clear_requirement {
my ($self, $module) = @_;
- delete $self->{ $module };
+
+ return $self unless $self->__entry_for($module);
+
+ Carp::confess("can't clear requirements on finalized requirements")
+ if $self->is_finalized;
+
+ delete $self->{requirements}{ $module };
return $self;
}
-sub required_modules { keys %{ $_[ 0 ] } }
+sub required_modules { keys %{ $_[0]{requirements} } }
sub clone {
@@ -82,8 +98,24 @@
return $new->add_requirements($self);
}
-sub __entry_for {
- $_[0]{ $_[1] }
+sub __entry_for { $_[0]{requirements}{ $_[1] } }
+
+sub __modify_entry_for {
+ my ($self, $name, $method, $version) = @_;
+
+ my $fin = $self->is_finalized;
+ my $old = $self->__entry_for($name);
+
+ Carp::confess("can't add new requirements to finalized requirements")
+ if $fin and not $old;
+
+ my $new = ($old || 'Version::Requirements::_Range::Range')
+ ->$method($version);
+
+ Carp::confess("can't modify finalized requirements")
+ if $fin and $old->as_string ne $new->as_string;
+
+ $self->{requirements}{ $name } = $new;
}
@@ -98,10 +130,17 @@
}
+sub is_finalized { $_[0]{finalized} }
+
+
+sub finalize { $_[0]{finalized} = 1 }
+
+
sub as_string_hash {
my ($self) = @_;
- my %hash = map {; $_ => $self->{$_}->as_string } keys %$self;
+ my %hash = map {; $_ => $self->{requirements}{$_}->as_string }
+ $self->required_modules;
return \%hash;
}
@@ -144,8 +183,10 @@
{
package
- Version::Requirements::_Spec::Exact;
-our $VERSION = '0.100660';
+ Version::Requirements::_Range::Exact;
+BEGIN {
+ $Version::Requirements::_Range::Exact::VERSION = '0.101020';
+}
sub _new { bless { version => $_[1] } => $_[0] }
sub _accepts { return $_[0]{version} == $_[1] }
@@ -153,30 +194,34 @@
sub as_string { return "== $_[0]{version}" }
sub as_modifiers { return [ [ exact_version => $_[0]{version} ] ] }
+
+ sub _clone {
+ (ref $_[0])->_new( version->new( $_[0]{version} ) )
+ }
sub with_exact_version {
my ($self, $version) = @_;
- return $self if $self->_accepts($version);
+ return $self->_clone if $self->_accepts($version);
Carp::confess("illegal requirements: unequal exact version specified");
}
sub with_minimum {
my ($self, $minimum) = @_;
- return $self if $self->{version} >= $minimum;
+ return $self->_clone if $self->{version} >= $minimum;
Carp::confess("illegal requirements: minimum above exact specification");
}
sub with_maximum {
my ($self, $maximum) = @_;
- return $self if $self->{version} <= $maximum;
+ return $self->_clone if $self->{version} <= $maximum;
Carp::confess("illegal requirements: maximum below exact specification");
}
sub with_exclusion {
my ($self, $exclusion) = @_;
- return $self unless $exclusion == $self->{version};
+ return $self->_clone unless $exclusion == $self->{version};
Carp::confess("illegal requirements: excluded exact specification");
}
}
@@ -185,10 +230,28 @@
{
package
- Version::Requirements::_Spec::Range;
-our $VERSION = '0.100660';
+ Version::Requirements::_Range::Range;
+BEGIN {
+ $Version::Requirements::_Range::Range::VERSION = '0.101020';
+}
sub _self { ref($_[0]) ? $_[0] : (bless { } => $_[0]) }
+
+ sub _clone {
+ return (bless { } => $_[0]) unless ref $_[0];
+
+ my ($s) = @_;
+ my %guts = (
+ (exists $s->{minimum} ? (minimum => version->new($s->{minimum})) : ()),
+ (exists $s->{maximum} ? (maximum => version->new($s->{maximum})) : ()),
+
+ (exists $s->{exclusions}
+ ? (exclusions => [ map { version->new($_) } @{ $s->{exclusions} } ])
+ : ()),
+ );
+
+ bless \%guts => ref($s);
+ }
sub as_modifiers {
my ($self) = @_;
@@ -233,12 +296,12 @@
sub with_exact_version {
my ($self, $version) = @_;
- $self = $self->_self;
+ $self = $self->_clone;
Carp::confess("illegal requirements: exact specification outside of range")
unless $self->_accepts($version);
- return Version::Requirements::_Spec::Exact->_new($version);
+ return Version::Requirements::_Range::Exact->_new($version);
}
sub _simplify {
@@ -249,7 +312,7 @@
Carp::confess("illegal requirements: excluded all values")
if grep { $_ == $self->{minimum} } @{ $self->{exclusions} || [] };
- return Version::Requirements::_Spec::Exact->_new($self->{minimum})
+ return Version::Requirements::_Range::Exact->_new($self->{minimum})
}
Carp::confess("illegal requirements: minimum exceeds maximum")
@@ -273,7 +336,7 @@
sub with_minimum {
my ($self, $minimum) = @_;
- $self = $self->_self;
+ $self = $self->_clone;
if (defined (my $old_min = $self->{minimum})) {
$self->{minimum} = (sort { $b cmp $a } ($minimum, $old_min))[0];
@@ -286,7 +349,7 @@
sub with_maximum {
my ($self, $maximum) = @_;
- $self = $self->_self;
+ $self = $self->_clone;
if (defined (my $old_max = $self->{maximum})) {
$self->{maximum} = (sort { $a cmp $b } ($maximum, $old_max))[0];
@@ -299,7 +362,7 @@
sub with_exclusion {
my ($self, $exclusion) = @_;
- $self = $self->_self;
+ $self = $self->_clone;
push @{ $self->{exclusions} ||= [] }, $exclusion;
@@ -329,7 +392,7 @@
=head1 VERSION
-version 0.100660
+version 0.101020
=head1 SYNOPSIS
@@ -424,6 +487,21 @@
This method returns the requirements object.
+=head2 accepts_module
+
+ my $bool = $req->accepts_modules($module => $version);
+
+Given an module and version, this method returns true if the version
+specification for the module accepts the provided version. In other words,
+given:
+
+ Module => '>= 1.00, < 2.00'
+
+We will accept 1.00 and 1.75 but not 0.50 or 2.00.
+
+For modules that do not appear in the requirements, this method will return
+true.
+
=head2 clear_requirement
$req->clear_requirement( $module );
@@ -448,6 +526,20 @@
This method returns true if and only if all requirements are inclusive minimums
-- that is, if their string expression is just the version number.
+
+=head2 is_finalized
+
+This method returns true if the requirements have been finalized by having the
+C<finalize> method called on them.
+
+=head2 finalize
+
+This method marks the requirements finalized. Subsequent attempts to change
+the requirements will be fatal, I<if> they would result in a change. If they
+would not alter the requirements, they have no effect.
+
+If a finalized set of requirements is cloned, the cloned requirements are not
+also finalized.
=head2 as_string_hash
Modified: branches/upstream/libversion-requirements-perl/current/t/accepts.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libversion-requirements-perl/current/t/accepts.t?rev=56282&op=diff
==============================================================================
--- branches/upstream/libversion-requirements-perl/current/t/accepts.t (original)
+++ branches/upstream/libversion-requirements-perl/current/t/accepts.t Sat Apr 17 07:55:17 2010
@@ -5,30 +5,25 @@
use Test::More 0.88;
-# XXX: We're gonna violate us some encapsulation here and call us some private
-# methods. Y'all better just resign yourself to it. -- rjbs, 2010-02-22
{
my $req = Version::Requirements->new->add_minimum(Foo => 1);
- my $foo = $req->{Foo};
- ok($foo->_accepts(1));
- ok(! $foo->_accepts(0));
+ ok( $req->accepts_module(Foo => 1));
+ ok(! $req->accepts_module(Foo => 0));
}
{
my $req = Version::Requirements->new->add_maximum(Foo => 1);
- my $foo = $req->{Foo};
- ok($foo->_accepts(1));
- ok(! $foo->_accepts(2));
+ ok( $req->accepts_module(Foo => 1));
+ ok(! $req->accepts_module(Foo => 2));
}
{
my $req = Version::Requirements->new->add_exclusion(Foo => 1);
- my $foo = $req->{Foo};
- ok($foo->_accepts(0));
- ok(! $foo->_accepts(1));
+ ok( $req->accepts_module(Foo => 0));
+ ok(! $req->accepts_module(Foo => 1));
}
done_testing;
Added: branches/upstream/libversion-requirements-perl/current/t/finalize.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libversion-requirements-perl/current/t/finalize.t?rev=56282&op=file
==============================================================================
--- branches/upstream/libversion-requirements-perl/current/t/finalize.t (added)
+++ branches/upstream/libversion-requirements-perl/current/t/finalize.t Sat Apr 17 07:55:17 2010
@@ -1,0 +1,91 @@
+use strict;
+use warnings;
+
+use Version::Requirements;
+
+use Test::More 0.88;
+
+sub dies_ok (&@) {
+ my ($code, $qr, $comment) = @_;
+
+ my $lived = eval { $code->(); 1 };
+
+ if ($lived) {
+ fail("$comment: did not die");
+ } else {
+ like($@, $qr, $comment);
+ }
+}
+
+{
+ my $req = Version::Requirements->new;
+
+ $req->add_minimum('Foo::Bar' => 10);
+ $req->add_minimum('Foo::Bar' => 0);
+ $req->add_minimum('Foo::Bar' => 2);
+
+ $req->add_minimum('Foo::Baz' => version->declare('v1.2.3'));
+
+ $req->add_minimum('Foo::Undef' => undef);
+
+ my $want = {
+ 'Foo::Bar' => 10,
+ 'Foo::Baz' => 'v1.2.3',
+ 'Foo::Undef' => 0,
+ };
+
+ is_deeply(
+ $req->as_string_hash,
+ $want,
+ "some basic minimums",
+ );
+
+ $req->finalize;
+
+ $req->add_minimum('Foo::Bar', 2);
+
+ pass('we can add a Foo::Bar requirement with no effect post finalization');
+
+ dies_ok { $req->add_minimum('Foo::Bar', 12) }
+ qr{finalized req},
+ "can't add a higher Foo::Bar after finalization";
+
+ dies_ok { $req->add_minimum('Foo::New', 0) }
+ qr{finalized req},
+ "can't add a new module prereq after finalization";
+
+ dies_ok { $req->clear_requirement('Foo::Bar') }
+ qr{finalized req},
+ "can't clear an existing prereq after finalization";
+
+ $req->clear_requirement('Bogus::Req');
+
+ pass('we can clear a prereq that was not set to begin with');
+
+ is_deeply(
+ $req->as_string_hash,
+ $want,
+ "none of our attempts to alter the object post-finalization worked",
+ );
+
+ my $cloned = $req->clone;
+
+ $cloned->add_minimum('Foo::Bar', 12);
+
+ is_deeply(
+ $cloned->as_string_hash,
+ {
+ %$want,
+ 'Foo::Bar' => 12,
+ },
+ "we can alter a cloned V:R (finalization does not survive cloning)",
+ );
+
+ is_deeply(
+ $req->as_string_hash,
+ $want,
+ "...and original requirements are untouched",
+ );
+}
+
+done_testing;
More information about the Pkg-perl-cvs-commits
mailing list