line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
48351
|
use 5.008; # utf8 |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
98
|
|
2
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
73
|
|
3
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
75
|
|
4
|
2
|
|
|
2
|
|
3708
|
use utf8; |
|
2
|
|
|
|
|
22
|
|
|
2
|
|
|
|
|
15
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package Path::FindDev; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.5.2'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# ABSTRACT: Find a development path somewhere in an upper hierarchy. |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY |
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
2
|
|
2810
|
use Sub::Exporter -setup => { exports => [ find_dev => \&_build_find_dev, ] }; |
|
2
|
|
|
|
|
52779
|
|
|
2
|
|
|
|
|
27
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub _build_find_dev { |
28
|
3
|
|
|
3
|
|
111
|
my ( undef, undef, $arg ) = @_; |
29
|
|
|
|
|
|
|
|
30
|
3
|
|
|
|
|
4
|
my $finddev_object; |
31
|
|
|
|
|
|
|
return sub { |
32
|
1
|
|
|
1
|
|
169
|
my ($path) = @_; |
33
|
1
|
|
33
|
|
|
6
|
$finddev_object ||= do { |
34
|
1
|
|
|
|
|
632
|
require Path::FindDev::Object; |
35
|
1
|
|
|
|
|
12
|
Path::FindDev::Object->new($arg); |
36
|
|
|
|
|
|
|
}; |
37
|
1
|
|
|
|
|
36
|
return $finddev_object->find_dev($path); |
38
|
3
|
|
|
|
|
17
|
}; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
*find_dev = _build_find_dev( __PACKAGE__, 'find_dev', {} ); |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
__END__ |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=pod |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=encoding UTF-8 |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 NAME |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Path::FindDev - Find a development path somewhere in an upper hierarchy. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 VERSION |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
version 0.5.2 |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 DESCRIPTION |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
This package is mostly a glue layer around L<< C<Path::IsDev>|Path::IsDev >> |
95
|
|
|
|
|
|
|
with a few directory walking tricks. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
use Path::FindDev qw( find_dev ); |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
if ( my $root = find_dev('/some/path/to/something/somewhere')) { |
100
|
|
|
|
|
|
|
print "development root = $root"; |
101
|
|
|
|
|
|
|
} else { |
102
|
|
|
|
|
|
|
print "No development root :("; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 FUNCTIONS |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head2 find_dev |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
my $result = find_dev('/some/path'); |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
If a C<dev> directory is found at, or above, C</some/path>, it will be returned |
112
|
|
|
|
|
|
|
as a L<< C<Path::Tiny>|Path::Tiny >> |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
If you pass configurations to import: |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
use Path::FindDev find_dev => { set => $someset }; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Then the exported C<find_dev> will pass that set name to L<< C<Path::IsDev>|Path::IsDev >>. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Though you should only do this if |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=over 4 |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=item * the default set is inadequate for your usage |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=item * you don't want the set to be overridden by C<%ENV> |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=back |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Additionally, you can call find_dev directly: |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
require Path::FindDev; |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
my $result = Path::FindDev::find_dev('/some/path'); |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Which by design inhibits your capacity to specify an alternative set in code. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=begin MetaPOD::JSON v1.1.0 |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
{ |
141
|
|
|
|
|
|
|
"namespace":"Path::FindDev", |
142
|
|
|
|
|
|
|
"interface":"exporter" |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=end MetaPOD::JSON |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 EXAMPLE USE-CASES |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Have you ever found yourself doing |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
use FindBin; |
153
|
|
|
|
|
|
|
use lib "$FindBin::Bin/../../../tlib" |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
In a test? |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Have you found yourself paranoid of file-system semantics and tried |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
use FindBin; |
160
|
|
|
|
|
|
|
use Path::Tiny qw(path) |
161
|
|
|
|
|
|
|
use lib path($FindBin::Bin)->parent->parent->parent->child('tlib')->stringify; |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Have you ever done either of the above in a test, only to |
164
|
|
|
|
|
|
|
find you've needed to move the test to a deeper hierarchy, |
165
|
|
|
|
|
|
|
and thus, need to re-write all your path resolution? |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Have you ever had this problem for multiple files? |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
No more! |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
use FindBin; |
172
|
|
|
|
|
|
|
use Path::FindDev qw(find_dev); |
173
|
|
|
|
|
|
|
use lib find_dev($FindBin::Bin)->child('t','tlib')->stringify; |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
^ Should work, regardless of which test you put it in, and regardless |
176
|
|
|
|
|
|
|
of what C<$CWD> happens to be when you call it. |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head1 AUTHOR |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
Kent Fredric <kentfredric@gmail.com> |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
This software is copyright (c) 2014 by Kent Fredric <kentfredric@gmail.com>. |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
187
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=cut |