1package Dist::Joseki::Find;
2use strict;
3use warnings;
4use File::Find;
5our $VERSION = '0.20';
6use base qw(Dist::Joseki::Base);
7
8sub projroot {
9    my $self = shift;
10    my @projroot =
11      map { s/^~/$ENV{HOME}/; $_ }
12      split /\s*;\s*/ => $ENV{PROJROOT};
13    wantarray ? @projroot : \@projroot;
14}
15
16sub find_dists {
17    my ($self, $restrict_path) = @_;
18    if (defined $restrict_path) {
19        $restrict_path = [$restrict_path]
20          unless ref $restrict_path eq 'ARRAY';
21    } else {
22        $restrict_path = [];
23    }
24    my %restrict_path = map { $_ => 1 } @$restrict_path;    # lookup hash
25    my @distro;
26    find(
27        sub {
28            return unless -d;
29
30        # prune some things first for efficiency reasons - otherwise find() gets
31        # quite slow.
32            if (/^(\.svn|blib|skel)$/) {
33                $File::Find::prune = 1;
34                return;
35            }
36            if (-e "$_/Build.PL" || -e "$_/Makefile.PL") {
37
38              # only remember the distro if there was no path restriction, or if
39              # it is within the restrict_path specs
40                if (@$restrict_path == 0 || exists $restrict_path{$_}) {
41                    push @distro => $File::Find::name;
42                }
43
44               # but prune anyway - we assume there are no distributions below a
45               # directory that contains a Build.PL or a Makefile.PL.
46                $File::Find::prune = 1;
47            }
48        },
49        $self->projroot
50    );
51    wantarray ? @distro : \@distro;
52}
531;
54__END__
55
56
57
58=head1 NAME
59
60Dist::Joseki::Find - find distributions within the project roots
61
62=head1 SYNOPSIS
63
64    Dist::Joseki::Find->new;
65
66=head1 DESCRIPTION
67
68None yet.
69
70=head1 METHODS
71
72=over 4
73
74
75
76=back
77
78Dist::Joseki::Find inherits from L<Dist::Joseki::Base>.
79
80The superclass L<Dist::Joseki::Base> defines these methods and functions:
81
82    new(), assert_is_dist_base_dir(), print_header(), read_from_cmd(),
83    safe_system()
84
85The superclass L<Class::Accessor::Complex> defines these methods and
86functions:
87
88    mk_abstract_accessors(), mk_array_accessors(), mk_boolean_accessors(),
89    mk_class_array_accessors(), mk_class_hash_accessors(),
90    mk_class_scalar_accessors(), mk_concat_accessors(),
91    mk_forward_accessors(), mk_hash_accessors(), mk_integer_accessors(),
92    mk_new(), mk_object_accessors(), mk_scalar_accessors(),
93    mk_set_accessors(), mk_singleton()
94
95The superclass L<Class::Accessor> defines these methods and functions:
96
97    _carp(), _croak(), _mk_accessors(), accessor_name_for(),
98    best_practice_accessor_name_for(), best_practice_mutator_name_for(),
99    follow_best_practice(), get(), make_accessor(), make_ro_accessor(),
100    make_wo_accessor(), mk_accessors(), mk_ro_accessors(),
101    mk_wo_accessors(), mutator_name_for(), set()
102
103The superclass L<Class::Accessor::Installer> defines these methods and
104functions:
105
106    install_accessor()
107
108=head1 BUGS AND LIMITATIONS
109
110No bugs have been reported.
111
112Please report any bugs or feature requests through the web interface at
113L<http://rt.cpan.org>.
114
115=head1 INSTALLATION
116
117See perlmodinstall for information and options on installing Perl modules.
118
119=head1 AVAILABILITY
120
121The latest version of this module is available from the Comprehensive Perl
122Archive Network (CPAN). Visit <http://www.perl.com/CPAN/> to find a CPAN
123site near you. Or see L<http://search.cpan.org/dist/Dist-Joseki/>.
124
125=head1 AUTHORS
126
127Marcel GrE<uuml>nauer, C<< <marcel@cpan.org> >>
128
129=head1 COPYRIGHT AND LICENSE
130
131Copyright 2007-2009 by the authors.
132
133This library is free software; you can redistribute it and/or modify
134it under the same terms as Perl itself.
135
136
137=cut
138
139