Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Substitute File::Spec::catdir() for Path::Class::Dir->new() so as to …

…eliminate need to install non-core module. Extract POD from .pm file and place in .pod file.
  • Loading branch information...
commit a3cbbfb9fc2a90b30b3656785767f1525652c98e 1 parent 3f6b7a8
@jkeenan authored
View
3  Makefile.PL
@@ -11,9 +11,10 @@ WriteMakefile(
'CPAN::Mini' => 0,
'File::Find' => 0,
'File::Path' => 2.06,
+ 'File::Spec' => 0,
'File::Temp' => 0.14,
'IO::CaptureOutput' => 0,
- 'Path::Class' => 0,
+# 'Path::Class' => 0,
'Scalar::Util' => 0,
'Test::Simple' => 0.44,
},
View
201 lib/CPAN/Mini/Visit/Simple.pm
@@ -9,59 +9,9 @@ $VERSION = eval $VERSION; ## no critic
use Carp;
use CPAN::Mini ();
use File::Find;
-use Path::Class::Dir;
+use File::Spec;
use Scalar::Util qw/ reftype /;
-=head1 NAME
-
-CPAN::Mini::Visit::Simple - Lightweight traversal of a minicpan repository
-
-=head1 SYNOPSIS
-
- use CPAN::Mini::Visit::Simple;
- $self = CPAN::Mini::Visit::Simple->new({});
- $self->identify_distros();
-
-=head1 DESCRIPTION
-
-This Perl extension is a variant on David Golden's App-CPAN-Mini-Visit. It
-can be used in the following circumstances:
-
-
-=head1 SUBROUTINES
-
-=head2 C<new()>
-
-=cut
-
-=over 4
-
-=item * Purpose
-
-CPAN::Mini::Visit::Simple constructor. While it cannot verify that you have a
-complete minicpan repository on disk, it does check that the most essential
-directories are present.
-
-=item * Arguments
-
- $self = CPAN::Mini::Visit::Simple->new({
- minicpan => $phony_minicpan, # optional
- });
-
-Optional single hash reference. That hash should have a C<minicpan> element
-whose value is the absolute path to your minicpan repository.
-
-If called with no arguments, the constructor will use the value of the
-C<local> key-value pair in your F<.minicpanrc> file.
-
-=item * Return Value
-
-CPAN::Mini::Visit::Simple object.
-
-=back
-
-=cut
-
sub new {
my ($class, $args) = @_;
my %data = ();
@@ -77,110 +27,15 @@ sub new {
croak "Directory $data{minicpan} not found"
unless (-d $data{minicpan});
- my $id_dir = Path::Class::Dir->new($data{minicpan}, qw/authors id/);
+ my $id_dir = File::Spec->catdir($data{minicpan}, qw/authors id/);
croak "Absence of $id_dir implies no valid minicpan"
unless -d $id_dir;
- $data{id_dir} = $id_dir->stringify;
+ $data{id_dir} = $id_dir;
my $self = bless \%data, $class;
return $self;
}
-=head2 C<identify_distros()>
-
-=cut
-
-=over 4
-
-=item * Purpose
-
-Prepare the list of distributions in the minicpan repository which will be
-visited.
-
-=item * Arguments
-
-May be called in any of the following two mutually exclusive ways:
-
-=over 4
-
-=item 1 No arguments
-
- $self->identify_distros();
-
-Will add all distributions found in the minicpan repository to the list of
-distributions to be visited.
-
-=item 2 Single hash reference
-
-You may provide a hash reference with B<one> of several elements. These
-elements are mutually exclusive and are listed in descending order of
-priority.
-
-=over 4
-
-=item * C<list>
-
- $minicpan_id_dir = '/home/user/minicpan/authors/id';
- $rv = $self->identify_distros( {
- list => [
- "$minicpan_id_dir/D/DR/DROLSKY/Alzabo-0.92.tar.gz",
- "$minicpan_id_dir/D/DR/DROLSKY/DateTime-0.53.tar.gz",
- "$minicpan_id_dir/D/DR/DROLSKY/Params-Validate-0.95.tar.gz",
- ],
- } );
-
-If a C<list> element is used, its value must be a reference to an array
-holding an exact list of the minicpan distributions to be visited.
-
-=item * C<start_dir>
-
- $rv = $self->identify_distros( {
- start_dir => "$minicpan_id_dir/D/DR/DROLSKY",
- } );
-
-If a C<list> element is not provided but a C<start_dir> element is provided,
-its value must be an absolute path to a directory inside the minicpan
-repository that is below the F<authors/id/> directory. The list of
-distributions to be visited will consist of all distributions below that point
-in the minicpan.
-
-=item * C<pattern>
-
- $rv = $self->identify_distros( {
- pattern => qr/Moose/,
- } );
-
-If a C<list> element is provided but a C<pattern>
-element is provided, its value must be a compiled regular expression. The
-list of distributions to be visited will consist of all distributions in the
-minicpan whose paths match that pattern.
-
-=item * Combination of C<start_dir> and C<pattern>
-
- $rv = $self->identify_distros( {
- start_dir => "$minicpan_id_dir/D/DR/DROLSKY",
- pattern => qr/Moose/,
- } );
-
-You may provide B<both> a C<start_dir> element and a C<pattern>
-element. In this case, the C<start_dir> element takes precedence, I<i.e.,>
-the list of distributions to be visited will consist of all distributions
-below the C<start_dir> which also match the C<pattern>.
-
-=back
-
-=back
-
-=item * Return Value
-
-Returns true value -- though this is not particularly meaningful. The list of
-distributions to be visited will be stored inside the object and can be
-accessed by other methods.
-
-=back
-
-=cut
-
sub identify_distros {
my ($self, $args) = @_;
@@ -230,28 +85,6 @@ sub identify_distros {
return 1;
}
-=head2 C<say_list()>
-
-=cut
-
-=over 4
-
-=item * Purpose
-
-Prints to STDOUT a list of distributions to be visited.
-
-=item * Arguments
-
- $self->say_list();
-
-None.
-
-=item * Return Value
-
-Implicitly returns true value.
-
-=cut
-
sub say_list {
my ($self) = @_;
say $_ for @{$self->{list}};
@@ -259,34 +92,6 @@ sub say_list {
1;
-=head1 BUGS
-
-Report bugs at
-F<https://rt.cpan.org/Public/Bug/Report.html?Queue=CPAN-Mini-Visit-Simple>.
-
-=head1 AUTHOR
-
- James E Keenan
- CPAN ID: jkeenan
- Perl Seminar NY
- jkeenan@cpan.org
- http://thenceforward.net/perl/modules/CPAN-Mini-Visit-Simple/
-
-=head1 COPYRIGHT
-
-This program is free software; you can redistribute
-it and/or modify it under the same terms as Perl itself.
-
-The full text of the license can be found in the
-LICENSE file included with this module.
-
-
-=head1 SEE ALSO
-
-perl(1). App-CPAN-Mini-Visit. CPAN-Mini.
-
-=cut
-
__END__
=head2 C<new()>
View
188 lib/CPAN/Mini/Visit/Simple.pod
@@ -0,0 +1,188 @@
+=head1 NAME
+
+CPAN::Mini::Visit::Simple - Lightweight traversal of a minicpan repository
+
+=head1 SYNOPSIS
+
+ use CPAN::Mini::Visit::Simple;
+ $self = CPAN::Mini::Visit::Simple->new({});
+ $self->identify_distros();
+
+=head1 DESCRIPTION
+
+This Perl extension is a variant on David Golden's App-CPAN-Mini-Visit. It
+can be used in the following circumstances:
+
+=head1 SUBROUTINES
+
+=head2 C<new()>
+
+=cut
+
+=over 4
+
+=item * Purpose
+
+CPAN::Mini::Visit::Simple constructor. While it cannot verify that you have a
+complete minicpan repository on disk, it does check that the most essential
+directories are present.
+
+=item * Arguments
+
+ $self = CPAN::Mini::Visit::Simple->new({
+ minicpan => $phony_minicpan, # optional
+ });
+
+Optional single hash reference. That hash should have a C<minicpan> element
+whose value is the absolute path to your minicpan repository.
+
+If called with no arguments, the constructor will use the value of the
+C<local> key-value pair in your F<.minicpanrc> file.
+
+=item * Return Value
+
+CPAN::Mini::Visit::Simple object.
+
+=back
+
+=head2 C<identify_distros()>
+
+=cut
+
+=over 4
+
+=item * Purpose
+
+Prepare the list of distributions in the minicpan repository which will be
+visited.
+
+=item * Arguments
+
+May be called in any of the following two mutually exclusive ways:
+
+=over 4
+
+=item 1 No arguments
+
+ $self->identify_distros();
+
+Will add all distributions found in the minicpan repository to the list of
+distributions to be visited.
+
+=item 2 Single hash reference
+
+You may provide a hash reference with B<one> of several elements. These
+elements are mutually exclusive and are listed in descending order of
+priority.
+
+=over 4
+
+=item * C<list>
+
+ $minicpan_id_dir = '/home/user/minicpan/authors/id';
+ $rv = $self->identify_distros( {
+ list => [
+ "$minicpan_id_dir/D/DR/DROLSKY/Alzabo-0.92.tar.gz",
+ "$minicpan_id_dir/D/DR/DROLSKY/DateTime-0.53.tar.gz",
+ "$minicpan_id_dir/D/DR/DROLSKY/Params-Validate-0.95.tar.gz",
+ ],
+ } );
+
+If a C<list> element is used, its value must be a reference to an array
+holding an exact list of the minicpan distributions to be visited.
+
+=item * C<start_dir>
+
+ $rv = $self->identify_distros( {
+ start_dir => "$minicpan_id_dir/D/DR/DROLSKY",
+ } );
+
+If a C<list> element is not provided but a C<start_dir> element is provided,
+its value must be an absolute path to a directory inside the minicpan
+repository that is below the F<authors/id/> directory. The list of
+distributions to be visited will consist of all distributions below that point
+in the minicpan.
+
+=item * C<pattern>
+
+ $rv = $self->identify_distros( {
+ pattern => qr/Moose/,
+ } );
+
+If a C<list> element is provided but a C<pattern>
+element is provided, its value must be a compiled regular expression. The
+list of distributions to be visited will consist of all distributions in the
+minicpan whose paths match that pattern.
+
+=item * Combination of C<start_dir> and C<pattern>
+
+ $rv = $self->identify_distros( {
+ start_dir => "$minicpan_id_dir/D/DR/DROLSKY",
+ pattern => qr/Moose/,
+ } );
+
+You may provide B<both> a C<start_dir> element and a C<pattern>
+element. In this case, the C<start_dir> element takes precedence, I<i.e.,>
+the list of distributions to be visited will consist of all distributions
+below the C<start_dir> which also match the C<pattern>.
+
+=back
+
+=back
+
+=item * Return Value
+
+Returns true value -- though this is not particularly meaningful. The list of
+distributions to be visited will be stored inside the object and can be
+accessed by other methods.
+
+=back
+
+=head2 C<say_list()>
+
+=over 4
+
+=item * Purpose
+
+Prints to STDOUT a list of distributions to be visited.
+
+=item * Arguments
+
+ $self->say_list();
+
+None.
+
+=item * Return Value
+
+Implicitly returns true value.
+
+=back
+
+=head1 BUGS
+
+Report bugs at
+F<https://rt.cpan.org/Public/Bug/Report.html?Queue=CPAN-Mini-Visit-Simple>.
+
+=head1 AUTHOR
+
+ James E Keenan
+ CPAN ID: jkeenan
+ Perl Seminar NY
+ jkeenan@cpan.org
+ http://thenceforward.net/perl/modules/CPAN-Mini-Visit-Simple/
+
+=head1 COPYRIGHT
+
+This program is free software; you can redistribute
+it and/or modify it under the same terms as Perl itself.
+
+The full text of the license can be found in the
+LICENSE file included with this module.
+
+
+=head1 SEE ALSO
+
+perl(1). App-CPAN-Mini-Visit. CPAN-Mini.
+
+=cut
+
View
4 t/001_new.t
@@ -4,8 +4,8 @@
use Carp;
use File::Path qw( make_path );
+use File::Spec;
use File::Temp qw( tempdir );
-use Path::Class::Dir;
use Test::More tests => 5;
BEGIN { use_ok( 'CPAN::Mini::Visit::Simple' ); }
@@ -29,7 +29,7 @@ like($@, qr/Directory $phony_minicpan not found/,
{
$tdir = tempdir();
- $id_dir = Path::Class::Dir->new($tdir, qw/authors id/);
+ $id_dir = File::Spec->catdir($tdir, qw/authors id/);
eval {
$self = CPAN::Mini::Visit::Simple->new({
minicpan => $tdir,
View
14 t/002_identify_distros.t
@@ -5,9 +5,9 @@
use CPAN::Mini::Visit::Simple;
use Carp;
use File::Path qw( make_path );
+use File::Spec;
use File::Temp qw( tempdir );
use IO::CaptureOutput qw( capture );
-use Path::Class::Dir;
use Test::More tests => 23;
my ( $self, $rv, @list, $phony_minicpan, $tdir, $id_dir );
@@ -65,10 +65,10 @@ like($@, qr/Directory $phony_minicpan not found/,
{
$tdir = tempdir();
ok( -d $tdir, "tempdir directory created for testing" );
- $id_dir = Path::Class::Dir->new($tdir, qw/authors id/);
+ $id_dir = File::Spec->catdir($tdir, qw/authors id/);
make_path($id_dir, { mode => 0711 });
ok( -d $id_dir, "'authors/id' directory created for testing" );
- my $phony_start_dir = Path::Class::Dir->new($tdir, qw/foo bar/);
+ my $phony_start_dir = File::Spec->catdir($tdir, qw/foo bar/);
make_path($phony_start_dir, { mode => 0711 });
ok( -d $phony_start_dir, "'start_dir' directory created for testing" );
$self = CPAN::Mini::Visit::Simple->new({
@@ -87,10 +87,10 @@ like($@, qr/Directory $phony_minicpan not found/,
{
$tdir = tempdir();
ok( -d $tdir, "tempdir directory created for testing" );
- $id_dir = Path::Class::Dir->new($tdir, qw/authors id/);
+ $id_dir = File::Spec->catdir($tdir, qw/authors id/);
make_path($id_dir, { mode => 0711 });
ok( -d $id_dir, "'authors/id' directory created for testing" );
- my $start_dir = Path::Class::Dir->new($id_dir, qw/foo bar/);
+ my $start_dir = File::Spec->catdir($id_dir, qw/foo bar/);
make_path($start_dir, { mode => 0711 });
ok( -d $start_dir, "'start_dir' directory created for testing" );
$self = CPAN::Mini::Visit::Simple->new({
@@ -98,9 +98,9 @@ like($@, qr/Directory $phony_minicpan not found/,
});
isa_ok ($self, 'CPAN::Mini::Visit::Simple');
$self->identify_distros({
- start_dir => $start_dir->stringify,
+ start_dir => $start_dir,
});
- is( $self->{'start_dir'}, $start_dir->stringify,
+ is( $self->{'start_dir'}, $start_dir,
"'start_dir' assigned as expected" );
}
Please sign in to comment.
Something went wrong with that request. Please try again.