summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGianni Ceccarelli <gianni.ceccarelli@net-a-porter.com>2012-12-11 17:10:00 +0000
committerGianni Ceccarelli <gianni.ceccarelli@net-a-porter.com>2012-12-11 17:10:00 +0000
commit924e46179bb7dbab7bfc34d6234c97602f898b79 (patch)
treec721d745d5e3fe272d7101f341ebc6d680ba2736
parentBuild results of 0221a2c (on master) (diff)
downloaddata-multivalued-924e46179bb7dbab7bfc34d6234c97602f898b79.tar.gz
data-multivalued-924e46179bb7dbab7bfc34d6234c97602f898b79.tar.bz2
data-multivalued-924e46179bb7dbab7bfc34d6234c97602f898b79.zip
Build results of 2008730 (on master)
-rw-r--r--Changes3
-rw-r--r--MANIFEST1
-rw-r--r--META.json11
-rw-r--r--META.yml4
-rw-r--r--Makefile.PL2
-rw-r--r--lib/Data/MultiValued.pm7
-rw-r--r--lib/Data/MultiValued/AttributeAccessors.pm6
-rw-r--r--lib/Data/MultiValued/AttributeTrait.pm6
-rw-r--r--lib/Data/MultiValued/AttributeTrait/Ranges.pm26
-rw-r--r--lib/Data/MultiValued/AttributeTrait/Tags.pm28
-rw-r--r--lib/Data/MultiValued/AttributeTrait/TagsAndRanges.pm48
-rw-r--r--lib/Data/MultiValued/Exceptions.pm14
-rw-r--r--lib/Data/MultiValued/RangeContainer.pm6
-rw-r--r--lib/Data/MultiValued/Ranges.pm6
-rw-r--r--lib/Data/MultiValued/TagContainer.pm6
-rw-r--r--lib/Data/MultiValued/TagContainerForRanges.pm6
-rw-r--r--lib/Data/MultiValued/Tags.pm12
-rw-r--r--lib/Data/MultiValued/TagsAndRanges.pm12
-rw-r--r--lib/Data/MultiValued/UglySerializationHelperRole.pm6
-rw-r--r--t/moose-ranges.t27
-rw-r--r--t/moose-tagged.t34
-rw-r--r--t/moose-tags-ranges.t136
22 files changed, 345 insertions, 62 deletions
diff --git a/Changes b/Changes
index 25d9d68..ae2a889 100644
--- a/Changes
+++ b/Changes
@@ -1,6 +1,7 @@
Revision history for Data::MultiValued
-0.0.6_2 2012-05-22 09:58:14 Europe/London
+0.0.7_1 2012-12-11 17:09:50 Europe/London
+ - add all_tags, all_ranges, all_tags_and_ranges methods
0.0.6_1 2012-01-30 14:09:43 Europe/London
diff --git a/MANIFEST b/MANIFEST
index b75414c..79cb84a 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -22,6 +22,7 @@ lib/Data/MultiValued/UglySerializationHelperRole.pm
t/json.t
t/moose-ranges.t
t/moose-tagged.t
+t/moose-tags-ranges.t
t/more-overlapping-ranges.t
t/overlapping-ranges.t
t/ranges-setting.t
diff --git a/META.json b/META.json
index e5c6bd1..41248a0 100644
--- a/META.json
+++ b/META.json
@@ -4,7 +4,7 @@
"Gianni Ceccarelli <dakkar@thenautilus.net>"
],
"dynamic_config" : 0,
- "generated_by" : "Dist::Zilla version 4.300016, CPAN::Meta::Converter version 2.120921",
+ "generated_by" : "Dist::Zilla version 4.300028, CPAN::Meta::Converter version 2.120921",
"license" : [
"perl_5"
],
@@ -24,6 +24,13 @@
"ExtUtils::MakeMaker" : "6.30"
}
},
+ "develop" : {
+ "requires" : {
+ "Pod::Coverage::TrustPod" : "0",
+ "Test::Pod" : "1.41",
+ "Test::Pod::Coverage" : "1.08"
+ }
+ },
"runtime" : {
"requires" : {
"Carp" : "0",
@@ -52,6 +59,6 @@
}
},
"release_status" : "testing",
- "version" : "0.0.6_2"
+ "version" : "0.0.7_1"
}
diff --git a/META.yml b/META.yml
index b9afbfc..80407f2 100644
--- a/META.yml
+++ b/META.yml
@@ -9,7 +9,7 @@ build_requires:
configure_requires:
ExtUtils::MakeMaker: 6.30
dynamic_config: 0
-generated_by: 'Dist::Zilla version 4.300016, CPAN::Meta::Converter version 2.120921'
+generated_by: 'Dist::Zilla version 4.300028, CPAN::Meta::Converter version 2.120921'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -34,4 +34,4 @@ requires:
overload: 0
strict: 0
warnings: 0
-version: 0.0.6_2
+version: 0.0.7_1
diff --git a/Makefile.PL b/Makefile.PL
index 02e37a3..cf31eef 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -40,7 +40,7 @@ my %WriteMakefileArgs = (
"strict" => 0,
"warnings" => 0
},
- "VERSION" => "0.0.6_2",
+ "VERSION" => "0.0.7_1",
"test" => {
"TESTS" => "t/*.t"
}
diff --git a/lib/Data/MultiValued.pm b/lib/Data/MultiValued.pm
index 654604f..2fb73a7 100644
--- a/lib/Data/MultiValued.pm
+++ b/lib/Data/MultiValued.pm
@@ -1,6 +1,6 @@
package Data::MultiValued;
{
- $Data::MultiValued::VERSION = '0.0.6_2';
+ $Data::MultiValued::VERSION = '0.0.7_1';
}
{
$Data::MultiValued::DIST = 'Data-MultiValued';
@@ -13,8 +13,8 @@ warn "Don't use this module directly, use Data::MultiValued::Tags or Data::Multi
1;
-
__END__
+
=pod
=encoding utf-8
@@ -25,7 +25,7 @@ Data::MultiValued - store tag- and range-dependant data in a scalar or Moose att
=head1 VERSION
-version 0.0.6_2
+version 0.0.7_1
=head1 SYNOPSIS
@@ -106,4 +106,3 @@ This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
-
diff --git a/lib/Data/MultiValued/AttributeAccessors.pm b/lib/Data/MultiValued/AttributeAccessors.pm
index c29822b..1e49306 100644
--- a/lib/Data/MultiValued/AttributeAccessors.pm
+++ b/lib/Data/MultiValued/AttributeAccessors.pm
@@ -1,6 +1,6 @@
package Data::MultiValued::AttributeAccessors;
{
- $Data::MultiValued::AttributeAccessors::VERSION = '0.0.6_2';
+ $Data::MultiValued::AttributeAccessors::VERSION = '0.0.7_1';
}
{
$Data::MultiValued::AttributeAccessors::DIST = 'Data-MultiValued';
@@ -120,6 +120,7 @@ sub _generate_multi_clearer_method {
1;
__END__
+
=pod
=encoding utf-8
@@ -130,7 +131,7 @@ Data::MultiValued::AttributeAccessors - method meta-class for multi-valued attri
=head1 VERSION
-version 0.0.6_2
+version 0.0.7_1
=head1 DESCRIPTION
@@ -183,4 +184,3 @@ This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
-
diff --git a/lib/Data/MultiValued/AttributeTrait.pm b/lib/Data/MultiValued/AttributeTrait.pm
index 8a0c8c6..e784128 100644
--- a/lib/Data/MultiValued/AttributeTrait.pm
+++ b/lib/Data/MultiValued/AttributeTrait.pm
@@ -1,6 +1,6 @@
package Data::MultiValued::AttributeTrait;
{
- $Data::MultiValued::AttributeTrait::VERSION = '0.0.6_2';
+ $Data::MultiValued::AttributeTrait::VERSION = '0.0.7_1';
}
{
$Data::MultiValued::AttributeTrait::DIST = 'Data-MultiValued';
@@ -277,6 +277,7 @@ sub _as_hash {
1;
__END__
+
=pod
=encoding utf-8
@@ -287,7 +288,7 @@ Data::MultiValued::AttributeTrait - "base role" for traits of multi-valued Moose
=head1 VERSION
-version 0.0.6_2
+version 0.0.7_1
=head1 DESCRIPTION
@@ -503,4 +504,3 @@ This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
-
diff --git a/lib/Data/MultiValued/AttributeTrait/Ranges.pm b/lib/Data/MultiValued/AttributeTrait/Ranges.pm
index bb289f5..d8aaeef 100644
--- a/lib/Data/MultiValued/AttributeTrait/Ranges.pm
+++ b/lib/Data/MultiValued/AttributeTrait/Ranges.pm
@@ -1,6 +1,6 @@
package Data::MultiValued::AttributeTrait::Ranges;
{
- $Data::MultiValued::AttributeTrait::Ranges::VERSION = '0.0.6_2';
+ $Data::MultiValued::AttributeTrait::Ranges::VERSION = '0.0.7_1';
}
{
$Data::MultiValued::AttributeTrait::Ranges::DIST = 'Data-MultiValued';
@@ -17,9 +17,18 @@ sub multivalue_storage_class { 'Data::MultiValued::Ranges' };
sub opts_to_pass_set { qw(from to) }
sub opts_to_pass_get { qw(at) }
+sub all_ranges {
+ my ($self,$instance) = @_;
+
+ my $storage = $self->get_full_storage($instance);
+ return unless $storage;
+
+ return $storage->_storage->all_ranges;
+}
+
package Moose::Meta::Attribute::Custom::Trait::MultiValued::Ranges;
{
- $Moose::Meta::Attribute::Custom::Trait::MultiValued::Ranges::VERSION = '0.0.6_2';
+ $Moose::Meta::Attribute::Custom::Trait::MultiValued::Ranges::VERSION = '0.0.7_1';
}
{
$Moose::Meta::Attribute::Custom::Trait::MultiValued::Ranges::DIST = 'Data-MultiValued';
@@ -30,6 +39,7 @@ sub register_implementation { 'Data::MultiValued::AttributeTrait::Ranges' }
1;
__END__
+
=pod
=encoding utf-8
@@ -40,7 +50,7 @@ Data::MultiValued::AttributeTrait::Ranges - attribute traits for attributes hold
=head1 VERSION
-version 0.0.6_2
+version 0.0.7_1
=head1 SYNOPSIS
@@ -75,6 +85,15 @@ Returns C<('from', 'to')>.
Returns C<('at')>.
+=head2 C<all_ranges>
+
+ my @ranges = $obj->meta->get_attribute('my_attr')->all_ranges($obj);
+
+Returns a list of 2-element arrayrefs, each arrayref describing the
+extremes of a range. Something like:
+
+ [ [undef,10], [10,20], [20,undef] ]
+
=head1 AUTHOR
Gianni Ceccarelli <dakkar@thenautilus.net>
@@ -87,4 +106,3 @@ This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
-
diff --git a/lib/Data/MultiValued/AttributeTrait/Tags.pm b/lib/Data/MultiValued/AttributeTrait/Tags.pm
index cb501e3..36851b5 100644
--- a/lib/Data/MultiValued/AttributeTrait/Tags.pm
+++ b/lib/Data/MultiValued/AttributeTrait/Tags.pm
@@ -1,6 +1,6 @@
package Data::MultiValued::AttributeTrait::Tags;
{
- $Data::MultiValued::AttributeTrait::Tags::VERSION = '0.0.6_2';
+ $Data::MultiValued::AttributeTrait::Tags::VERSION = '0.0.7_1';
}
{
$Data::MultiValued::AttributeTrait::Tags::DIST = 'Data-MultiValued';
@@ -17,9 +17,22 @@ sub multivalue_storage_class { 'Data::MultiValued::Tags' };
sub opts_to_pass_set { qw(tag) }
sub opts_to_pass_get { qw(tag) }
+sub all_tags {
+ my ($self,$instance) = @_;
+
+ my $storage = $self->get_full_storage($instance);
+ return () unless $storage;
+
+ my @tags = $storage->_storage->all_tags;
+ if ($storage->_storage->_has_default_tag) {
+ push @tags,undef;
+ }
+ return @tags;
+}
+
package Moose::Meta::Attribute::Custom::Trait::MultiValued::Tags;
{
- $Moose::Meta::Attribute::Custom::Trait::MultiValued::Tags::VERSION = '0.0.6_2';
+ $Moose::Meta::Attribute::Custom::Trait::MultiValued::Tags::VERSION = '0.0.7_1';
}
{
$Moose::Meta::Attribute::Custom::Trait::MultiValued::Tags::DIST = 'Data-MultiValued';
@@ -30,6 +43,7 @@ sub register_implementation { 'Data::MultiValued::AttributeTrait::Tags' }
1;
__END__
+
=pod
=encoding utf-8
@@ -40,7 +54,7 @@ Data::MultiValued::AttributeTrait::Tags - attribute traits for attributes holdin
=head1 VERSION
-version 0.0.6_2
+version 0.0.7_1
=head1 SYNOPSIS
@@ -75,6 +89,13 @@ Returns C<('tag')>.
Returns C<('tag')>.
+=head2 C<all_tags>
+
+ my @tags = $obj->meta->get_attribute('my_attr')->all_tags($obj);
+
+Returns a list of all values for which C<<
+$obj->has_my_attr_multi({tag=>$tag}) >> would return true.
+
=head1 AUTHOR
Gianni Ceccarelli <dakkar@thenautilus.net>
@@ -87,4 +108,3 @@ This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
-
diff --git a/lib/Data/MultiValued/AttributeTrait/TagsAndRanges.pm b/lib/Data/MultiValued/AttributeTrait/TagsAndRanges.pm
index 4dee46e..f5849d4 100644
--- a/lib/Data/MultiValued/AttributeTrait/TagsAndRanges.pm
+++ b/lib/Data/MultiValued/AttributeTrait/TagsAndRanges.pm
@@ -1,6 +1,6 @@
package Data::MultiValued::AttributeTrait::TagsAndRanges;
{
- $Data::MultiValued::AttributeTrait::TagsAndRanges::VERSION = '0.0.6_2';
+ $Data::MultiValued::AttributeTrait::TagsAndRanges::VERSION = '0.0.7_1';
}
{
$Data::MultiValued::AttributeTrait::TagsAndRanges::DIST = 'Data-MultiValued';
@@ -17,9 +17,34 @@ sub multivalue_storage_class { 'Data::MultiValued::TagsAndRanges' };
sub opts_to_pass_set { qw(from to tag) }
sub opts_to_pass_get { qw(at tag) }
+require Data::MultiValued::AttributeTrait::Tags;
+
+sub all_tags {
+ my ($self,$instance) = @_;
+ return $self->Data::MultiValued::AttributeTrait::Tags::all_tags($instance);
+}
+
+sub all_tags_and_ranges {
+ my ($self,$instance) = @_;
+
+ my $storage = $self->get_full_storage($instance);
+ return unless $storage;
+
+ my @tags = $self->all_tags($instance);
+
+ my @tags_and_ranges;
+ for my $tag (@tags) {
+ my @these_ranges = $storage->_storage
+ ->get({tag=>$tag})->all_ranges;
+ push @tags_and_ranges,[$tag, \@these_ranges];
+ }
+
+ return @tags_and_ranges;
+}
+
package Moose::Meta::Attribute::Custom::Trait::MultiValued::TagsAndRanges;
{
- $Moose::Meta::Attribute::Custom::Trait::MultiValued::TagsAndRanges::VERSION = '0.0.6_2';
+ $Moose::Meta::Attribute::Custom::Trait::MultiValued::TagsAndRanges::VERSION = '0.0.7_1';
}
{
$Moose::Meta::Attribute::Custom::Trait::MultiValued::TagsAndRanges::DIST = 'Data-MultiValued';
@@ -30,6 +55,7 @@ sub register_implementation { 'Data::MultiValued::AttributeTrait::TagsAndRanges'
1;
__END__
+
=pod
=encoding utf-8
@@ -40,7 +66,7 @@ Data::MultiValued::AttributeTrait::TagsAndRanges - attribute traits for attribut
=head1 VERSION
-version 0.0.6_2
+version 0.0.7_1
=head1 SYNOPSIS
@@ -75,6 +101,21 @@ Returns C<('tag', 'from', 'to')>.
Returns C<('tag', 'at')>.
+=head2 C<all_tags_and_ranges>
+
+ my @tags_and_ranges = $obj->meta->get_attribute('my_attr')
+ ->all_tags_and_ranges($obj);
+
+Returns a list of 2-element arrayrefs. The first element of each
+arrayref is a tag (possibly C<undef>), the second element is an
+arrayref of 2-element arrayrefs, each arrayref describing the extremes
+of a range. Something like:
+
+ [
+ [ 'x', [ [undef,10], [10,20], [20,undef] ] ],
+ [ undef, [ [undef,undef] ] ],
+ ],
+
=head1 AUTHOR
Gianni Ceccarelli <dakkar@thenautilus.net>
@@ -87,4 +128,3 @@ This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
-
diff --git a/lib/Data/MultiValued/Exceptions.pm b/lib/Data/MultiValued/Exceptions.pm
index e127a5e..5d39aab 100644
--- a/lib/Data/MultiValued/Exceptions.pm
+++ b/lib/Data/MultiValued/Exceptions.pm
@@ -1,6 +1,6 @@
package Data::MultiValued::Exceptions;
{
- $Data::MultiValued::Exceptions::VERSION = '0.0.6_2';
+ $Data::MultiValued::Exceptions::VERSION = '0.0.7_1';
}
{
$Data::MultiValued::Exceptions::DIST = 'Data-MultiValued';
@@ -11,7 +11,7 @@ package Data::MultiValued::Exceptions;
package Data::MultiValued::Exceptions::NotFound;
{
- $Data::MultiValued::Exceptions::NotFound::VERSION = '0.0.6_2';
+ $Data::MultiValued::Exceptions::NotFound::VERSION = '0.0.7_1';
}
{
$Data::MultiValued::Exceptions::NotFound::DIST = 'Data-MultiValued';
@@ -44,7 +44,7 @@ sub as_string {
package Data::MultiValued::Exceptions::TagNotFound;
{
- $Data::MultiValued::Exceptions::TagNotFound::VERSION = '0.0.6_2';
+ $Data::MultiValued::Exceptions::TagNotFound::VERSION = '0.0.7_1';
}
{
$Data::MultiValued::Exceptions::TagNotFound::DIST = 'Data-MultiValued';
@@ -60,7 +60,7 @@ has '+message' => (
package Data::MultiValued::Exceptions::RangeNotFound;
{
- $Data::MultiValued::Exceptions::RangeNotFound::VERSION = '0.0.6_2';
+ $Data::MultiValued::Exceptions::RangeNotFound::VERSION = '0.0.7_1';
}
{
$Data::MultiValued::Exceptions::RangeNotFound::DIST = 'Data-MultiValued';
@@ -76,7 +76,7 @@ has '+message' => (
package Data::MultiValued::Exceptions::BadRange;
{
- $Data::MultiValued::Exceptions::BadRange::VERSION = '0.0.6_2';
+ $Data::MultiValued::Exceptions::BadRange::VERSION = '0.0.7_1';
}
{
$Data::MultiValued::Exceptions::BadRange::DIST = 'Data-MultiValued';
@@ -102,6 +102,7 @@ sub as_string {
1;
__END__
+
=pod
=encoding utf-8
@@ -112,7 +113,7 @@ Data::MultiValued::Exceptions - exception classes
=head1 VERSION
-version 0.0.6_2
+version 0.0.7_1
=head1 DESCRIPTION
@@ -161,4 +162,3 @@ This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
-
diff --git a/lib/Data/MultiValued/RangeContainer.pm b/lib/Data/MultiValued/RangeContainer.pm
index 084a83f..2246c30 100644
--- a/lib/Data/MultiValued/RangeContainer.pm
+++ b/lib/Data/MultiValued/RangeContainer.pm
@@ -1,6 +1,6 @@
package Data::MultiValued::RangeContainer;
{
- $Data::MultiValued::RangeContainer::VERSION = '0.0.6_2';
+ $Data::MultiValued::RangeContainer::VERSION = '0.0.7_1';
}
{
$Data::MultiValued::RangeContainer::DIST = 'Data-MultiValued';
@@ -238,6 +238,7 @@ __PACKAGE__->meta->make_immutable();
1;
__END__
+
=pod
=encoding utf-8
@@ -248,7 +249,7 @@ Data::MultiValued::RangeContainer - container for ranged values
=head1 VERSION
-version 0.0.6_2
+version 0.0.7_1
=head1 DESCRIPTION
@@ -317,4 +318,3 @@ This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
-
diff --git a/lib/Data/MultiValued/Ranges.pm b/lib/Data/MultiValued/Ranges.pm
index 12ec278..123bbea 100644
--- a/lib/Data/MultiValued/Ranges.pm
+++ b/lib/Data/MultiValued/Ranges.pm
@@ -1,6 +1,6 @@
package Data::MultiValued::Ranges;
{
- $Data::MultiValued::Ranges::VERSION = '0.0.6_2';
+ $Data::MultiValued::Ranges::VERSION = '0.0.7_1';
}
{
$Data::MultiValued::Ranges::DIST = 'Data-MultiValued';
@@ -83,6 +83,7 @@ __PACKAGE__->meta->make_immutable();
1;
__END__
+
=pod
=encoding utf-8
@@ -93,7 +94,7 @@ Data::MultiValued::Ranges - Handle values with validity ranges
=head1 VERSION
-version 0.0.6_2
+version 0.0.7_1
=head1 SYNOPSIS
@@ -215,4 +216,3 @@ This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
-
diff --git a/lib/Data/MultiValued/TagContainer.pm b/lib/Data/MultiValued/TagContainer.pm
index 35c38cc..3eb895b 100644
--- a/lib/Data/MultiValued/TagContainer.pm
+++ b/lib/Data/MultiValued/TagContainer.pm
@@ -1,6 +1,6 @@
package Data::MultiValued::TagContainer;
{
- $Data::MultiValued::TagContainer::VERSION = '0.0.6_2';
+ $Data::MultiValued::TagContainer::VERSION = '0.0.7_1';
}
{
$Data::MultiValued::TagContainer::DIST = 'Data-MultiValued';
@@ -116,6 +116,7 @@ __PACKAGE__->meta->make_immutable();
1;
__END__
+
=pod
=encoding utf-8
@@ -126,7 +127,7 @@ Data::MultiValued::TagContainer - container for tagged values
=head1 VERSION
-version 0.0.6_2
+version 0.0.7_1
=head1 DESCRIPTION
@@ -201,4 +202,3 @@ This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
-
diff --git a/lib/Data/MultiValued/TagContainerForRanges.pm b/lib/Data/MultiValued/TagContainerForRanges.pm
index 6d6fef8..3b0975d 100644
--- a/lib/Data/MultiValued/TagContainerForRanges.pm
+++ b/lib/Data/MultiValued/TagContainerForRanges.pm
@@ -1,6 +1,6 @@
package Data::MultiValued::TagContainerForRanges;
{
- $Data::MultiValued::TagContainerForRanges::VERSION = '0.0.6_2';
+ $Data::MultiValued::TagContainerForRanges::VERSION = '0.0.7_1';
}
{
$Data::MultiValued::TagContainerForRanges::DIST = 'Data-MultiValued';
@@ -58,6 +58,7 @@ __PACKAGE__->meta->make_immutable();
1;
__END__
+
=pod
=encoding utf-8
@@ -68,7 +69,7 @@ Data::MultiValued::TagContainerForRanges - container for tagged values that are
=head1 VERSION
-version 0.0.6_2
+version 0.0.7_1
=head1 DESCRIPTION
@@ -111,4 +112,3 @@ This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
-
diff --git a/lib/Data/MultiValued/Tags.pm b/lib/Data/MultiValued/Tags.pm
index edfcb54..247f114 100644
--- a/lib/Data/MultiValued/Tags.pm
+++ b/lib/Data/MultiValued/Tags.pm
@@ -1,6 +1,6 @@
package Data::MultiValued::Tags;
{
- $Data::MultiValued::Tags::VERSION = '0.0.6_2';
+ $Data::MultiValued::Tags::VERSION = '0.0.7_1';
}
{
$Data::MultiValued::Tags::DIST = 'Data-MultiValued';
@@ -30,7 +30,7 @@ sub _build__storage {
sub set {
my ($self,%args) = validated_hash(
\@_,
- tag => { isa => 'Str', optional => 1, },
+ tag => { isa => 'Maybe[Str]', optional => 1, },
value => { isa => 'Any', },
);
@@ -42,7 +42,7 @@ sub set {
sub get {
my ($self,%args) = validated_hash(
\@_,
- tag => { isa => 'Str', optional => 1, },
+ tag => { isa => 'Maybe[Str]', optional => 1, },
);
$self->_storage->get(\%args)
@@ -53,7 +53,7 @@ sub get {
sub clear {
my ($self,%args) = validated_hash(
\@_,
- tag => { isa => 'Str', optional => 1, },
+ tag => { isa => 'Maybe[Str]', optional => 1, },
);
$self->_storage->clear(\%args);
@@ -80,6 +80,7 @@ __PACKAGE__->meta->make_immutable();
1;
__END__
+
=pod
=encoding utf-8
@@ -90,7 +91,7 @@ Data::MultiValued::Tags - Handle values with tags
=head1 VERSION
-version 0.0.6_2
+version 0.0.7_1
=head1 SYNOPSIS
@@ -173,4 +174,3 @@ This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
-
diff --git a/lib/Data/MultiValued/TagsAndRanges.pm b/lib/Data/MultiValued/TagsAndRanges.pm
index f4c35ad..17f7e02 100644
--- a/lib/Data/MultiValued/TagsAndRanges.pm
+++ b/lib/Data/MultiValued/TagsAndRanges.pm
@@ -1,6 +1,6 @@
package Data::MultiValued::TagsAndRanges;
{
- $Data::MultiValued::TagsAndRanges::VERSION = '0.0.6_2';
+ $Data::MultiValued::TagsAndRanges::VERSION = '0.0.7_1';
}
{
$Data::MultiValued::TagsAndRanges::DIST = 'Data-MultiValued';
@@ -32,7 +32,7 @@ sub set {
\@_,
from => { isa => 'Num|Undef', optional => 1, },
to => { isa => 'Num|Undef', optional => 1, },
- tag => { isa => 'Str', optional => 1, },
+ tag => { isa => 'Maybe[Str]', optional => 1, },
value => { isa => 'Any', },
);
@@ -46,7 +46,7 @@ sub get {
my ($self,%args) = validated_hash(
\@_,
at => { isa => 'Num|Undef', optional => 1, },
- tag => { isa => 'Str', optional => 1, },
+ tag => { isa => 'Maybe[Str]', optional => 1, },
);
$self->_storage->get(\%args)
@@ -60,7 +60,7 @@ sub clear {
\@_,
from => { isa => 'Num|Undef', optional => 1, },
to => { isa => 'Num|Undef', optional => 1, },
- tag => { isa => 'Str', optional => 1, },
+ tag => { isa => 'Maybe[Str]', optional => 1, },
);
if (exists $args{from} || exists $args{to}) {
@@ -93,6 +93,7 @@ __PACKAGE__->meta->make_immutable();
1;
__END__
+
=pod
=encoding utf-8
@@ -103,7 +104,7 @@ Data::MultiValued::TagsAndRanges - Handle values with tags and validity ranges
=head1 VERSION
-version 0.0.6_2
+version 0.0.7_1
=head1 SYNOPSIS
@@ -186,4 +187,3 @@ This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
-
diff --git a/lib/Data/MultiValued/UglySerializationHelperRole.pm b/lib/Data/MultiValued/UglySerializationHelperRole.pm
index c750358..4c0f423 100644
--- a/lib/Data/MultiValued/UglySerializationHelperRole.pm
+++ b/lib/Data/MultiValued/UglySerializationHelperRole.pm
@@ -1,6 +1,6 @@
package Data::MultiValued::UglySerializationHelperRole;
{
- $Data::MultiValued::UglySerializationHelperRole::VERSION = '0.0.6_2';
+ $Data::MultiValued::UglySerializationHelperRole::VERSION = '0.0.7_1';
}
{
$Data::MultiValued::UglySerializationHelperRole::DIST = 'Data-MultiValued';
@@ -79,6 +79,7 @@ sub _dmv_multi_attrs {
1;
__END__
+
=pod
=encoding utf-8
@@ -89,7 +90,7 @@ Data::MultiValued::UglySerializationHelperRole - only use this if you know what
=head1 VERSION
-version 0.0.6_2
+version 0.0.7_1
=head1 SYNOPSIS
@@ -173,4 +174,3 @@ This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
-
diff --git a/t/moose-ranges.t b/t/moose-ranges.t
index 404e649..35ff83d 100644
--- a/t/moose-ranges.t
+++ b/t/moose-ranges.t
@@ -34,6 +34,15 @@ subtest 'default' => sub {
ok($obj->has_stuff,'has stuff');
is($obj->stuff,3,'default');
+
+ cmp_deeply(
+ [$obj->meta->get_attribute('stuff')->all_ranges($obj)],
+ [[undef,undef]],
+ 'stuff all_ranges');
+ cmp_deeply(
+ [$obj->meta->get_attribute('other')->all_ranges($obj)],
+ [],
+ 'other all_ranges');
};
subtest 'constructor param' => sub {
@@ -44,6 +53,15 @@ subtest 'constructor param' => sub {
is($obj->stuff,12,'param');
is($obj->other,'bar','param');
+
+ cmp_deeply(
+ [$obj->meta->get_attribute('stuff')->all_ranges($obj)],
+ [[undef,undef]],
+ 'stuff all_ranges');
+ cmp_deeply(
+ [$obj->meta->get_attribute('other')->all_ranges($obj)],
+ [[undef,undef]],
+ 'other all_ranges');
};
subtest 'with ranges' => sub {
@@ -62,6 +80,15 @@ subtest 'with ranges' => sub {
is($obj->stuff,3,'default');
is($obj->stuff_multi($opts),7,'stuff ranged');
is($obj->other_multi($opts),'foo','other ranged');
+
+ cmp_deeply(
+ [$obj->meta->get_attribute('stuff')->all_ranges($obj)],
+ [[undef,10],[10,20],[20,undef]],
+ 'stuff all_ranges');
+ cmp_deeply(
+ [$obj->meta->get_attribute('other')->all_ranges($obj)],
+ [[10,20]],
+ 'other all_ranges');
};
done_testing();
diff --git a/t/moose-tagged.t b/t/moose-tagged.t
index 1273bed..8e7dd97 100644
--- a/t/moose-tagged.t
+++ b/t/moose-tagged.t
@@ -39,6 +39,15 @@ subtest 'default' => sub {
ok($obj->has_stuff,'has stuff');
is($obj->stuff,3,'default');
+
+ cmp_deeply(
+ [$obj->meta->get_attribute('stuff')->all_tags($obj)],
+ [undef],
+ 'stuff all_tags');
+ cmp_deeply(
+ [$obj->meta->get_attribute('other')->all_tags($obj)],
+ [],
+ 'other all_tags');
};
subtest 'constructor param' => sub {
@@ -49,6 +58,15 @@ subtest 'constructor param' => sub {
is($obj->stuff,12,'param');
is($obj->other,'bar','param');
+
+ cmp_deeply(
+ [$obj->meta->get_attribute('stuff')->all_tags($obj)],
+ [undef],
+ 'stuff all_tags');
+ cmp_deeply(
+ [$obj->meta->get_attribute('other')->all_tags($obj)],
+ [undef],
+ 'other all_tags');
};
subtest 'with tags' => sub {
@@ -67,6 +85,22 @@ subtest 'with tags' => sub {
is($obj->stuff,3,'default');
is($obj->stuff_tagged($opts),7,'stuff tagged');
is($obj->other_multi($opts),'foo','other tagged');
+
+ cmp_deeply(
+ [$obj->meta->get_attribute('stuff')->all_tags($obj)],
+ bag(undef,'one'),
+ 'stuff all_tags');
+ cmp_deeply(
+ [$obj->meta->get_attribute('other')->all_tags($obj)],
+ bag('one'),
+ 'other all_tags');
+
+ my @tags = $obj->meta->get_attribute('stuff')->all_tags($obj);
+ my $pred=$obj->meta->get_attribute('stuff')->multi_predicate;
+ for my $tag (@tags) {
+ ok($obj->$pred({tag=>$tag}),"stuff has tag @{[ $tag || 'undef' ]}");
+ }
+
};
done_testing();
diff --git a/t/moose-tags-ranges.t b/t/moose-tags-ranges.t
new file mode 100644
index 0000000..bb8fb06
--- /dev/null
+++ b/t/moose-tags-ranges.t
@@ -0,0 +1,136 @@
+#!perl
+use strict;
+use warnings;
+
+package Foo;{
+use Moose;
+use Data::MultiValued::AttributeTrait::TagsAndRanges;
+
+has stuff => (
+ is => 'rw',
+ isa => 'Int',
+ traits => ['MultiValued::TagsAndRanges'],
+ default => 3,
+ predicate => 'has_stuff',
+ clearer => 'clear_stuff',
+);
+
+has other => (
+ is => 'rw',
+ isa => 'Str',
+ traits => ['MultiValued::TagsAndRanges'],
+ predicate => 'has_other',
+ clearer => 'clear_other',
+);
+}
+package main;
+use Test::Most 'die';
+use Data::Printer;
+
+subtest 'default' => sub {
+ my $obj = Foo->new();
+
+ ok(!$obj->has_other,'not has other');
+ ok($obj->has_stuff,'has stuff');
+
+ is($obj->stuff,3,'default');
+
+ cmp_deeply(
+ [$obj->meta->get_attribute('stuff')->all_tags_and_ranges($obj)],
+ [[undef, [[undef,undef]]]],
+ 'stuff all_ranges');
+ cmp_deeply(
+ [$obj->meta->get_attribute('other')->all_tags_and_ranges($obj)],
+ [],
+ 'other all_ranges');
+};
+
+subtest 'constructor param' => sub {
+ my $obj = Foo->new({stuff=>12,other=>'bar'});
+
+ ok($obj->has_other,'has other');
+ ok($obj->has_stuff,'has stuff');
+
+ is($obj->stuff,12,'param');
+ is($obj->other,'bar','param');
+
+ cmp_deeply(
+ [$obj->meta->get_attribute('stuff')->all_tags_and_ranges($obj)],
+ [[undef, [[undef,undef]]]],
+ 'stuff all_ranges');
+ cmp_deeply(
+ [$obj->meta->get_attribute('other')->all_tags_and_ranges($obj)],
+ [[undef, [[undef,undef]]]],
+ 'other all_ranges');
+};
+
+subtest 'with ranges' => sub {
+ my $obj = Foo->new();
+
+ my $opts = {from=>10,to=>20,at=>15};
+
+ ok($obj->has_stuff,'has stuff');
+ ok($obj->has_stuff_multi($opts),'has stuff ranged (forever)');
+ ok(!$obj->has_other,'not has other');
+ ok(!$obj->has_other_multi($opts),'not has other ranged');
+
+ $obj->stuff_multi($opts,7);
+ $obj->other_multi($opts,'foo');
+
+ is($obj->stuff,3,'default');
+ is($obj->stuff_multi($opts),7,'stuff ranged');
+ is($obj->other_multi($opts),'foo','other ranged');
+
+ cmp_deeply(
+ [$obj->meta->get_attribute('stuff')->all_tags($obj)],
+ [undef],
+ 'stuff all_tags');
+
+ cmp_deeply(
+ [$obj->meta->get_attribute('stuff')->all_tags_and_ranges($obj)],
+ [[undef, [[undef,10],[10,20],[20,undef]]]],
+ 'stuff all_tags_and_ranges');
+
+ cmp_deeply(
+ [$obj->meta->get_attribute('other')->all_tags_and_ranges($obj)],
+ [[undef, [[10,20]]]],
+ 'other all_tags_and_ranges');
+};
+
+subtest 'with tags and ranges' => sub {
+ my $obj = Foo->new();
+
+ my $opts = {from=>10,to=>20,at=>15,tag=>'x'};
+
+ ok($obj->has_stuff,'has stuff');
+ ok(!$obj->has_stuff_multi($opts),'has stuff ranged (forever)');
+ ok(!$obj->has_other,'not has other');
+ ok(!$obj->has_other_multi($opts),'not has other ranged');
+
+ $obj->stuff_multi($opts,7);
+ $obj->other_multi($opts,'foo');
+
+ is($obj->stuff,3,'default');
+ is($obj->stuff_multi($opts),7,'stuff ranged');
+ is($obj->other_multi($opts),'foo','other ranged');
+
+ cmp_deeply(
+ [$obj->meta->get_attribute('stuff')->all_tags($obj)],
+ bag(undef,'x'),
+ 'stuff all_tags');
+
+ cmp_deeply(
+ [$obj->meta->get_attribute('stuff')->all_tags_and_ranges($obj)],
+ bag(
+ ['x', [[10,20]]],
+ [undef,[[undef,undef]]],
+ ),
+ 'stuff all_tags_and_ranges');
+
+ cmp_deeply(
+ [$obj->meta->get_attribute('other')->all_tags_and_ranges($obj)],
+ [['x', [[10,20]]]],
+ 'other all_tags_and_ranges');
+};
+
+done_testing();