Skip to content

Commit 82201c6

Browse files
authored
Merge pull request #1341 from metacpan/haarg/type-tiny
Use Type::Tiny based types in most cases
2 parents f72eadb + 02c1d5a commit 82201c6

File tree

20 files changed

+100
-89
lines changed

20 files changed

+100
-89
lines changed

lib/Catalyst/Authentication/Store/Proxy.pm

Lines changed: 2 additions & 2 deletions
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/Catalyst/Plugin/Session/Store/ElasticSearch.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package Catalyst::Plugin::Session::Store::ElasticSearch;
44

55
use Moose;
66
extends 'Catalyst::Plugin::Session::Store';
7-
use MooseX::Types::ElasticSearch qw( ES );
7+
use MetaCPAN::Types::TypeTiny qw( ES );
88

99
use MetaCPAN::ESConfig qw( es_doc_path );
1010
use MetaCPAN::Server::Config ();

lib/MetaCPAN/API.pm

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ To run the api web server, run the following on one of the servers:
1919

2020
use Mojo::Base 'Mojolicious';
2121

22-
use File::Temp ();
23-
use List::Util qw( any );
24-
use MetaCPAN::Script::Runner ();
25-
use Search::Elasticsearch ();
26-
use Try::Tiny qw( catch try );
27-
use MetaCPAN::Server::Config ();
28-
use MooseX::Types::ElasticSearch qw(ES);
22+
use File::Temp ();
23+
use List::Util qw( any );
24+
use MetaCPAN::Script::Runner ();
25+
use Search::Elasticsearch ();
26+
use Try::Tiny qw( catch try );
27+
use MetaCPAN::Server::Config ();
28+
use MetaCPAN::Types::TypeTiny qw( ES );
2929

3030
has es => sub {
3131
ES->assert_coerce(

lib/MetaCPAN/Model/Archive.pm

Lines changed: 2 additions & 2 deletions
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

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,25 @@ use Moose;
44

55
use v5.10;
66

7-
use CPAN::DistnameInfo ();
8-
use CPAN::Meta ();
9-
use DateTime ();
10-
use File::Find ();
11-
use File::Spec ();
12-
use Log::Contextual qw( :log :dlog );
13-
use MetaCPAN::ESConfig qw( es_doc_path );
14-
use MetaCPAN::Model::Archive ();
15-
use MetaCPAN::Types::TypeTiny qw( AbsPath ArrayRef Str );
16-
use MetaCPAN::Util qw( fix_version true false );
17-
use Module::Metadata 1.000012 (); # Improved package detection.
7+
use CPAN::DistnameInfo ();
8+
use CPAN::Meta ();
9+
use DateTime ();
10+
use File::Find ();
11+
use File::Spec ();
12+
use Log::Contextual::Easy::Default qw( :log :dlog );
13+
use MetaCPAN::ESConfig qw( es_doc_path );
14+
use MetaCPAN::Model::Archive ();
15+
use MetaCPAN::Types::TypeTiny qw( AbsPath ArrayRef InstanceOf Str );
16+
use MetaCPAN::Util qw( fix_version true false );
17+
use Module::Metadata 1.000012 (); # Improved package detection.
1818
use MooseX::StrictConstructor;
1919
use Parse::PMFile ();
2020
use Path::Tiny qw( path );
2121
use Try::Tiny qw( catch try );
2222

23-
with 'MetaCPAN::Role::Logger';
24-
2523
has archive => (
2624
is => 'ro',
27-
isa => 'MetaCPAN::Model::Archive',
25+
isa => InstanceOf ['MetaCPAN::Model::Archive'],
2826
lazy => 1,
2927
builder => '_build_archive',
3028
);
@@ -38,7 +36,7 @@ has dependencies => (
3836

3937
has distinfo => (
4038
is => 'ro',
41-
isa => 'CPAN::DistnameInfo',
39+
isa => InstanceOf ['CPAN::DistnameInfo'],
4240
handles => {
4341
maturity => 'maturity',
4442
author => 'cpanid',
@@ -55,7 +53,7 @@ has distinfo => (
5553

5654
has document => (
5755
is => 'ro',
58-
isa => 'MetaCPAN::Document::Release',
56+
isa => InstanceOf ['MetaCPAN::Document::Release'],
5957
lazy => 1,
6058
builder => '_build_document',
6159
);
@@ -77,7 +75,7 @@ has files => (
7775

7876
has date => (
7977
is => 'ro',
80-
isa => 'DateTime',
78+
isa => InstanceOf ['DateTime'],
8179
lazy => 1,
8280
default => sub {
8381
my $self = shift;
@@ -89,7 +87,7 @@ has model => ( is => 'ro' );
8987

9088
has metadata => (
9189
is => 'ro',
92-
isa => 'CPAN::Meta',
90+
isa => InstanceOf ['CPAN::Meta'],
9391
lazy => 1,
9492
builder => '_build_metadata',
9593
);

lib/MetaCPAN/Query.pm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package MetaCPAN::Query;
22
use Moose;
33

4-
use Module::Runtime qw( require_module );
5-
use Module::Pluggable::Object ();
6-
use MooseX::Types::ElasticSearch qw( ES );
4+
use Module::Runtime qw( require_module );
5+
use Module::Pluggable::Object ();
6+
use MetaCPAN::Types::TypeTiny qw( ES );
77

88
has es => (
99
is => 'ro',

lib/MetaCPAN/Query/Role/Common.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package MetaCPAN::Query::Role::Common;
22
use Moose::Role;
33

4-
use MooseX::Types::ElasticSearch qw( ES );
4+
use MetaCPAN::Types::TypeTiny qw( ES );
55

66
has es => (
77
is => 'ro',

lib/MetaCPAN/Role/Logger.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use Moose::Role;
66
use Log::Contextual qw( set_logger );
77
use Log::Log4perl ':easy';
88
use MetaCPAN::Types::TypeTiny qw( Logger Str );
9+
use MooseX::Getopt ();
910
use Path::Tiny qw( path );
1011

1112
has level => (

lib/MetaCPAN/Role/Script.pm

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,19 @@ package MetaCPAN::Role::Script;
22

33
use Moose::Role;
44

5-
use Carp ();
6-
use MooseX::Types::ElasticSearch qw( ES );
7-
use IO::Prompt::Tiny qw( prompt );
8-
use Log::Contextual qw( :log :dlog );
9-
use MetaCPAN::Model ();
10-
use MetaCPAN::Types::TypeTiny qw( Bool HashRef Int Path Str );
11-
use MetaCPAN::Util qw( root_dir );
12-
use Mojo::Server ();
13-
use Term::ANSIColor qw( colored );
5+
use Carp ();
6+
use IO::Prompt::Tiny qw( prompt );
7+
use Log::Contextual qw( :log :dlog );
8+
use MetaCPAN::Model ();
9+
use MetaCPAN::Types::TypeTiny qw( AbsPath Bool ES HashRef Int Path Str );
10+
use MetaCPAN::Util qw( root_dir );
11+
use Mojo::Server ();
12+
use Term::ANSIColor qw( colored );
13+
14+
use MooseX::Getopt::OptionTypeMap ();
15+
for my $type ( Path, AbsPath, ES ) {
16+
MooseX::Getopt::OptionTypeMap->add_option_type_to_map( $type, '=s' );
17+
}
1418

1519
with( 'MetaCPAN::Role::HasConfig', 'MetaCPAN::Role::Fastly',
1620
'MetaCPAN::Role::Logger' );

lib/MetaCPAN/Script/Release.pm

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,6 @@ sub _get_release_model {
270270
distinfo => $d,
271271
file => $archive_path,
272272
model => $self->model,
273-
level => $self->level,
274-
logger => $self->logger,
275273
status => $self->detect_status( $d->cpanid, $d->filename ),
276274
);
277275

0 commit comments

Comments
 (0)