Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

weaken type constraint of "directory" attribute #69

Merged
merged 3 commits into from
Feb 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cpanfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ on 'runtime' => sub {
requires 'Pod::Usage' => '0';
requires 'Try::Tiny' => '0';
requires 'Type::Tiny' => '2.000000';
requires 'Types::Path::Tiny' => '0';
requires 'Types::Self' => '0';
requires 'Types::URI' => '0';
requires 'feature' => '0';
Expand All @@ -46,8 +47,7 @@ on 'runtime' => sub {
on 'test' => sub {
requires 'File::Touch' => '0';
requires 'File::Which' => '0';
requires 'PAUSE::Packages' => '0';
requires 'Path::Class' => '0';
requires 'Path::Tiny' => '0.119';
requires 'Test::More' => '0.98';
requires 'Test::RequiresInternet' => '0.02';
};
Expand Down
3 changes: 2 additions & 1 deletion lib/OrePAN2/Indexer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ use Type::Params qw( signature );
use Types::Standard qw( Bool HashRef Str is_ArrayRef );
use Types::Common::Numeric qw( PositiveInt );
use Types::Self qw( Self );
use Types::Path::Tiny qw( Path );

use namespace::clean;

#<<<
has directory => ( is => 'ro', isa => Str, required => 1 );
has directory => ( is => 'ro', isa => Path, coerce => 1, required => 1 );
has simple => ( is => 'ro', isa => Bool, default => !!0 );
has metacpan => ( is => 'ro', isa => Bool, default => !!0 );
has metacpan_lookup_size => ( is => 'ro', isa => PositiveInt, default => 200 );
Expand Down
29 changes: 15 additions & 14 deletions lib/OrePAN2/Injector.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,25 @@ use utf8;

use Moo;

use Archive::Extract ();
use Archive::Tar qw( COMPRESS_GZIP );
use CPAN::Meta ();
use File::Basename qw( basename dirname );
use File::Copy qw( copy );
use File::Find qw( find );
use File::Path qw( mkpath );
use File::Spec ();
use File::Temp qw( tempdir );
use File::pushd qw( pushd );
use HTTP::Tiny ();
use MetaCPAN::Client ();
use Types::Standard qw( CodeRef Str );
use Archive::Extract ();
use Archive::Tar qw( COMPRESS_GZIP );
use CPAN::Meta ();
use File::Basename qw( basename dirname );
use File::Copy qw( copy );
use File::Find qw( find );
use File::Path qw( mkpath );
use File::Spec ();
use File::Temp qw( tempdir );
use File::pushd qw( pushd );
use HTTP::Tiny ();
use MetaCPAN::Client ();
use Types::Standard qw( CodeRef Str );
use Types::Path::Tiny qw( Path );

use namespace::clean;

has author => ( is => 'ro', isa => CodeRef | Str, default => 'DUMMY' );
has directory => ( is => 'ro', isa => Str, required => 1 );
has directory => ( is => 'ro', isa => Path, coerce => 1, required => 1 );

sub inject {
my ( $self, $source, $opts ) = @_;
Expand Down
3 changes: 2 additions & 1 deletion lib/OrePAN2/Repository.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ use OrePAN2::Indexer ();
use OrePAN2::Injector ();
use OrePAN2::Repository::Cache ();
use Types::Standard qw( Bool InstanceOf Str );
use Types::Path::Tiny qw( Path );

use namespace::clean;

#<<<
has compress_index => ( is => 'ro', isa => Bool, default => !!1 );
has cache => ( is => 'lazy', isa => InstanceOf ['OrePAN2::Repository::Cache'], builder => 1, handles => { has_cache => 'is_hit', save_cache => 'save' } );
has directory => ( is => 'ro', isa => Str, required => 1 );
has directory => ( is => 'ro', isa => Path, coerce => 1, required => 1 );
has indexer => ( is => 'lazy', isa => InstanceOf ['OrePAN2::Indexer'], builder => 1 );
has injector => ( is => 'lazy', isa => InstanceOf ['OrePAN2::Injector'], builder => 1 );
has simple => ( is => 'ro', isa => Bool, default => !!0 );
Expand Down
9 changes: 5 additions & 4 deletions lib/OrePAN2/Repository/Cache.pm
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ use File::stat qw( stat );
use IO::File::AtomicChange ();
use JSON::PP ();
use Types::Standard qw( Bool HashRef Str );
use Types::Path::Tiny qw( Path );

use namespace::clean;

has directory => ( is => 'ro', isa => Str, required => 1 );
has data => ( is => 'lazy', isa => HashRef, builder => 1 );
has filename => ( is => 'lazy', isa => Str, builder => 1 );
has is_dirty => ( is => 'rw', isa => Bool, default => !!0 );
has directory => ( is => 'ro', isa => Path, coerce => 1, required => 1 );
has data => ( is => 'lazy', isa => HashRef, builder => 1 );
has filename => ( is => 'lazy', isa => Str, builder => 1 );
has is_dirty => ( is => 'rw', isa => Bool, default => !!0 );

sub _build_data {
my $self = shift;
Expand Down
3 changes: 2 additions & 1 deletion t/01_indexer.t
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ use Local::Util qw( slurp slurp_gz );
use File::Temp qw( tempdir );
use File::Path qw( mkpath );
use File::Copy qw( copy );
use Path::Tiny qw();

use OrePAN2::Indexer ();

subtest 'gz' => sub {
my $tmpdir = tempdir( CLEANUP => 1 );
my $tmpdir = Path::Tiny->tempdir( CLEANUP => 1 );

mkpath "$tmpdir/authors/id/M/MI/MIYAGAWA/";

Expand Down
3 changes: 2 additions & 1 deletion t/03_inject.t
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ use lib 't/lib';
use Test::More;
use Test::More;
use File::Temp qw( tempdir );
use Path::Tiny qw();

use OrePAN2::Injector ();

subtest 'gz' => sub {
my $tmpdir = tempdir( CLEANUP => 1 );
my $tmpdir = Path::Tiny->tempdir( CLEANUP => 1 );

my $injector = OrePAN2::Injector->new(
directory => $tmpdir,
Expand Down
11 changes: 6 additions & 5 deletions t/04_repository.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ use utf8;

use lib 't/lib';

use File::Temp ();
use File::Touch qw( touch );
use Local::Util qw( slurp_gz );
use OrePAN2::Repository ();
use Test::More;
use File::Touch qw( touch );
use Local::Util qw( slurp_gz );
use Path::Tiny qw();

use OrePAN2::Repository ();

{
my ( $repo, $tmpdir ) = make_repo();
Expand All @@ -28,7 +29,7 @@ use Test::More;
}

sub make_repo {
my $tmpdir = File::Temp::tempdir( CLEANUP => 1 );
my $tmpdir = Path::Tiny->tempdir( CLEANUP => 1 );

my $repo = OrePAN2::Repository->new( directory => $tmpdir, simple => 1 );
$repo->inject('t/dat/Acme-Foo-0.01.tar.gz');
Expand Down
Loading