Skip to content

Commit 67fa81d

Browse files
committed
use Type::Tiny for most types rather than built in Moose types
1 parent df4d868 commit 67fa81d

File tree

7 files changed

+23
-20
lines changed

7 files changed

+23
-20
lines changed

lib/Catalyst/Authentication/Store/Proxy.pm

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package Catalyst::Authentication::Store::Proxy;
33
# ABSTRACT: Delegates authentication logic to the user object
44
use Moose;
55
use Catalyst::Utils ();
6-
use MetaCPAN::Types::TypeTiny qw( HashRef Str );
6+
use MetaCPAN::Types::TypeTiny qw( ClassName HashRef Str );
77

88
has user_class => (
99
is => 'ro',
@@ -14,7 +14,7 @@ has user_class => (
1414
);
1515
has handles => ( is => 'ro', isa => HashRef );
1616
has config => ( is => 'ro', isa => HashRef );
17-
has app => ( is => 'ro', isa => 'ClassName' );
17+
has app => ( is => 'ro', isa => ClassName );
1818
has realm => ( is => 'ro' );
1919

2020
sub BUILDARGS {

lib/MetaCPAN/Model/Archive.pm

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package MetaCPAN::Model::Archive;
33
use v5.10;
44
use Moose;
55
use MooseX::StrictConstructor;
6-
use MetaCPAN::Types::TypeTiny qw( AbsPath ArrayRef Bool Str );
6+
use MetaCPAN::Types::TypeTiny qw( AbsPath ArrayRef Bool InstanceOf Str );
77

88
use Archive::Any ();
99
use Carp qw( croak );
@@ -52,7 +52,7 @@ has file => (
5252

5353
has _extractor => (
5454
is => 'ro',
55-
isa => 'Archive::Any',
55+
isa => InstanceOf ['Archive::Any'],
5656
handles => [ qw(
5757
is_impolite
5858
is_naughty

lib/MetaCPAN/Model/Release.pm

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use File::Spec ();
1212
use Log::Contextual qw( :log :dlog );
1313
use MetaCPAN::ESConfig qw( es_doc_path );
1414
use MetaCPAN::Model::Archive ();
15-
use MetaCPAN::Types::TypeTiny qw( AbsPath ArrayRef Str );
15+
use MetaCPAN::Types::TypeTiny qw( AbsPath ArrayRef InstanceOf Str );
1616
use MetaCPAN::Util qw( fix_version true false );
1717
use Module::Metadata 1.000012 (); # Improved package detection.
1818
use MooseX::StrictConstructor;
@@ -24,7 +24,7 @@ with 'MetaCPAN::Role::Logger';
2424

2525
has archive => (
2626
is => 'ro',
27-
isa => 'MetaCPAN::Model::Archive',
27+
isa => InstanceOf ['MetaCPAN::Model::Archive'],
2828
lazy => 1,
2929
builder => '_build_archive',
3030
);
@@ -38,7 +38,7 @@ has dependencies => (
3838

3939
has distinfo => (
4040
is => 'ro',
41-
isa => 'CPAN::DistnameInfo',
41+
isa => InstanceOf ['CPAN::DistnameInfo'],
4242
handles => {
4343
maturity => 'maturity',
4444
author => 'cpanid',
@@ -55,7 +55,7 @@ has distinfo => (
5555

5656
has document => (
5757
is => 'ro',
58-
isa => 'MetaCPAN::Document::Release',
58+
isa => InstanceOf ['MetaCPAN::Document::Release'],
5959
lazy => 1,
6060
builder => '_build_document',
6161
);
@@ -77,7 +77,7 @@ has files => (
7777

7878
has date => (
7979
is => 'ro',
80-
isa => 'DateTime',
80+
isa => InstanceOf ['DateTime'],
8181
lazy => 1,
8282
default => sub {
8383
my $self = shift;
@@ -89,7 +89,7 @@ has model => ( is => 'ro' );
8989

9090
has metadata => (
9191
is => 'ro',
92-
isa => 'CPAN::Meta',
92+
isa => InstanceOf ['CPAN::Meta'],
9393
lazy => 1,
9494
builder => '_build_metadata',
9595
);

lib/MetaCPAN/Script/Snapshot.pm

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use DateTime::Format::ISO8601 ();
99
use HTTP::Tiny ();
1010
use Log::Contextual qw( :log :dlog );
1111
use MetaCPAN::Server::Config ();
12-
use MetaCPAN::Types::TypeTiny qw( ArrayRef Bool Str );
12+
use MetaCPAN::Types::TypeTiny qw( ArrayRef Bool Str Uri );
1313
use Moose;
1414
use Sys::Hostname qw( hostname );
1515

@@ -81,7 +81,8 @@ has snap_name => (
8181

8282
has host => (
8383
is => 'ro',
84-
isa => 'URI::http',
84+
isa => Uri,
85+
coerce => 1,
8586
default => sub {
8687
my $self = shift;
8788
return $self->es->transport->cxn_pool->cxns->[0]->uri;

t/lib/MetaCPAN/Script/MockError.pm

+6-5
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,46 @@ package MetaCPAN::Script::MockError;
22

33
use Moose;
44
use Exception::Class ('MockException');
5+
use MetaCPAN::Types::TypeTiny qw( Bool Int Str );
56

67
with 'MetaCPAN::Role::Script', 'MooseX::Getopt';
78

89
has arg_error_message => (
910
init_arg => 'message',
1011
is => 'ro',
11-
isa => 'Str',
12+
isa => Str,
1213
default => "",
1314
documentation => 'mock an Error Message',
1415
);
1516

1617
has arg_error_code => (
1718
init_arg => 'error',
1819
is => 'ro',
19-
isa => 'Int',
20+
isa => Int,
2021
default => -1,
2122
documentation => 'mock an Exit Code',
2223
);
2324

2425
has arg_die => (
2526
init_arg => 'die',
2627
is => 'ro',
27-
isa => 'Bool',
28+
isa => Bool,
2829
default => 0,
2930
documentation => 'mock an Exception',
3031
);
3132

3233
has arg_handle_error => (
3334
init_arg => 'handle_error',
3435
is => 'ro',
35-
isa => 'Bool',
36+
isa => Bool,
3637
default => 0,
3738
documentation => 'mock a handled error',
3839
);
3940

4041
has arg_exception => (
4142
init_arg => 'exception',
4243
is => 'ro',
43-
isa => 'Bool',
44+
isa => Bool,
4445
default => 0,
4546
documentation => 'mock an Exception Class',
4647
);

t/lib/MetaCPAN/Tests/Extra.pm

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package MetaCPAN::Tests::Extra;
22
use Test::More;
33
use Test::Routine;
4+
use MetaCPAN::Types::TypeTiny qw( CodeRef );
45

56
has _extra_tests => (
67
is => 'ro',
7-
isa => 'CodeRef',
8+
isa => CodeRef,
89
init_arg => 'extra_tests',
910
predicate => 'has_extra_tests',
1011
);

t/lib/MetaCPAN/Tests/Model.pm

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package MetaCPAN::Tests::Model;
33
use Test::Routine;
44

55
use MetaCPAN::Server::Test ();
6-
use MetaCPAN::Types::TypeTiny qw( ArrayRef HashRef Str );
6+
use MetaCPAN::Types::TypeTiny qw( ArrayRef HashRef InstanceOf Str );
77
use Test::More;
88
use Try::Tiny qw( try );
99

@@ -42,7 +42,7 @@ has _type => (
4242

4343
has model => (
4444
is => 'ro',
45-
isa => 'MetaCPAN::Model',
45+
isa => InstanceOf ['MetaCPAN::Model'],
4646
lazy => 1,
4747
default => sub { MetaCPAN::Server::Test::model() },
4848
);

0 commit comments

Comments
 (0)