Skip Menu |
 

This queue is for tickets about the MooseX-Types-DateTime-ButMaintained CPAN distribution.

Report information
The Basics
Id: 108686
Status: open
Priority: 0/
Queue: MooseX-Types-DateTime-ButMaintained

People
Owner: Nobody in particular
Requestors: ANDK [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.16
Fixed in: (no value)

Attachments
MooseX-Types-DateTime-ButMaintained-0.16-Accept-DateTime-Locale-FromData-object.patch



Subject: Fails with DateTime-Locale-1.01
Download (untitled) / with headers
text/plain 185b
As per subject. Downgrading to DateTime-Locale-0.92 does as a workaround. Sample fail report: http://www.cpantesters.org/cpan/report/66f5830e-86c7-11e5-851e-2688a9884ca8 HTH&&Thanks,
From: jplesnik [...] redhat.com
Download (untitled) / with headers
text/plain 336b
The attached patch solves the bug. DateTime::Locale::FromData should be used instead DateTime::Locale due to changes in newer version of DateTime::Locale. The problem is Moose type system checks for exact class name while doing coercion and because DateTime::Locale::FromData is not inherited from DateTime::Locale, the check fails.
Subject: MooseX-Types-DateTime-ButMaintained-0.16-Accept-DateTime-Locale-FromData-object.patch
diff -up MooseX-Types-DateTime-ButMaintained-0.16/lib/MooseX/Types/DateTime/ButMaintained.pm.orig MooseX-Types-DateTime-ButMaintained-0.16/lib/MooseX/Types/DateTime/ButMaintained.pm --- MooseX-Types-DateTime-ButMaintained-0.16/lib/MooseX/Types/DateTime/ButMaintained.pm.orig 2015-11-24 09:37:27.800280623 +0100 +++ MooseX-Types-DateTime-ButMaintained-0.16/lib/MooseX/Types/DateTime/ButMaintained.pm 2015-11-24 09:40:01.707349049 +0100 @@ -19,13 +19,14 @@ use namespace::autoclean; class_type "DateTime"; class_type "DateTime::Duration"; class_type "DateTime::TimeZone"; -class_type "DateTime::Locale::root" => { name => "DateTime::Locale" }; subtype DateTime, as 'DateTime'; subtype Duration, as 'DateTime::Duration'; subtype TimeZone, as Object, where { $_->isa('DateTime::TimeZone') || $_->isa('DateTime::TimeZone::Tzfile') }; +subtype 'DateTime::Locale', as Object, + where { $_->isa('DateTime::Locale::root') || $_->isa('DateTime::Locale::FromData') }; subtype Locale, as 'DateTime::Locale'; subtype( Now, as Str, where { $_ eq 'now' }, diff -up MooseX-Types-DateTime-ButMaintained-0.16/t/01_basic.t.orig MooseX-Types-DateTime-ButMaintained-0.16/t/01_basic.t --- MooseX-Types-DateTime-ButMaintained-0.16/t/01_basic.t.orig 2011-11-17 17:54:44.000000000 +0100 +++ MooseX-Types-DateTime-ButMaintained-0.16/t/01_basic.t 2015-11-24 09:36:04.000000000 +0100 @@ -103,7 +103,7 @@ isa_ok( find_type_constraint($_), "Moose my $loc = Gorch->new( loc => "he_IL" )->loc; - isa_ok( $loc, "DateTime::Locale::he", "coerced from string" ); + like( $loc->id, qr/he[_\-]IL/, "coerced from string" ); dies_ok { Gorch->new( loc => "not_a_place_or_a_locale" ) } "bad locale name"; @@ -126,7 +126,7 @@ isa_ok( find_type_constraint($_), "Moose isa_ok( $handle, "Some::L10N", "maketext handle" ); - isa_ok( Gorch->new( loc => $handle )->loc, "DateTime::Locale::ja", "coerced from maketext" );; + is( Gorch->new( loc => $handle )->loc->id, "ja", "coerced from maketext" );; } }
On 2015-11-24 22:35:19, jplesnik wrote:
Show quoted text
> The attached patch solves the bug.
>
>
> DateTime::Locale::FromData should be used instead DateTime::Locale due
> to changes in newer version of DateTime::Locale.
>
> The problem is Moose type system checks for exact class name while
> doing coercion and because DateTime::Locale::FromData is not inherited
> from DateTime::Locale, the check fails.

Attached patch really doesn't work as-is any more.

Defining subtypes with names identical to native classes creates an error.

Show quoted text
#     Error:  The type constraint 'DateTime::Locale' has already been created in Moose::Util::TypeConstraints and cannot be created again in Moose::Exporter at /usr/lib64/perl5/vendor_perl/5.26.1/x86_64-linux/Moose/Exporter.pm line 398
#     MooseX::Types::CheckedUtilExports::subtype('DateTime::Locale', 'HASH(0x2fab928)', 'HASH(0x2e6a5a8)') called at /tmp/MooseX-Types-DateTime-ButMaintained/blib/lib/MooseX/Types/DateTime/ButMaintained.pm line 29

Show quoted text
#     Error:  The type constraint 'DateTime::Locale' has already been created in Moose::Util::TypeConstraints and cannot be created again in Moose::Exporter at /usr/lib64/perl5/vendor_perl/5.26.1/x86_64-linux/Moose/Exporter.pm line 398
#     MooseX::Types::CheckedUtilExports::subtype('DateTime::Locale', 'HASH(0x2fab928)', 'HASH(0x2e6a5a8)') called at /tmp/MooseX-Types-DateTime-ButMaintained/blib/lib/MooseX/Types/DateTime/ButMaintained.pm line 29



-- 
- CPAN kentnl@cpan.org
- Gentoo Perl Maintainer kentnl@gentoo.org ( perl@gentoo.org )
Just use MooseX::Types::DateTime, which ironically _is_ maintained.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.