Debian Codegraph @

README

raw
1 NAME
2
3 File::ShareDir::Dist - Locate per-dist shared files
4
5 VERSION
6
7 version 0.07
8
9 SYNOPSIS
10
11 use File::ShareDir::Dist qw( dist_share );
12
13 my $dir = dist_share 'Foo-Bar-Baz';
14
15 DESCRIPTION
16
17 File::ShareDir::Dist finds share directories for distributions. It is
18 similar to File::ShareDir with a few differences:
19
20 Only supports distribution directories.
21
22 It doesn't support perl modules or perl class directories. I have
23 never really needed anything other than a per-dist share directory.
24
25 Doesn't compute filenames.
26
27 Doesn't compute files in the share directory for you. This is what
28 File::Spec or Path::Tiny are for.
29
30 Doesn't support old style shares.
31
32 For some reason there are two types. I have never seen or needed the
33 older type.
34
35 Hopefully doesn't find the wrong directory.
36
37 It doesn't blindly go finding the first share directory in @INC that
38 matches the dist name. It actually checks to see that it matches the
39 .pm file that goes along with it.
40
41 That does mean that you need to have a .pm that corresponds to your
42 dist name. This is not always the case for some older historical
43 distributions, but it has been the recommended convention for quite
44 some time.
45
46 No non-core dependencies.
47
48 File::ShareDir only has Class::Inspector, but since we are only doing
49 per-dist share directories we don't even need that.
50
51 The goal of this project is to have no non-core dependencies for the
52 two most recent production versions of Perl. As of this writing that
53 means Perl 5.26 and 5.24. In the future, we may add dependencies on
54 modules that are not part of the Perl core on older Perls.
55
56 Works in your development tree.
57
58 Uses the heuristic, for determining if you are in a development tree,
59 and if so, uses the common convention to find the directory named
60 share. If you are using a relative path in @INC, if the directory
61 share is a sibling of that relative entry in @INC and if the last
62 element in that relative path is lib.
63
64 Example, if you have the directory structure:
65
66 lib/Foo/Bar/Baz.pm
67 share/data
68
69 and you invoke perl with
70
71 % perl -Ilib -MFoo::Bar::Baz -MFile::ShareDir::Dist=dist_share -E 'say dist_share("Foo-Bar-Baz")'
72
73 dist_share will return the (absolute) path to ./share/data. If you
74 invoked it with:
75
76 % export PERL5LIB `pwd`/lib
77 perl -MFoo::Bar::Baz -MFile::ShareDir::Dist=dist_share -E 'say dist_share("Foo-Bar-Baz")'
78
79 it would not. For me this covers most of my needs when developing a
80 Perl module with a share directory.
81
82 prove foils this heuristic by making @INC absolute paths. To get
83 around that you can use App::Prove::Plugin::ShareDirDist.
84
85 Built in override.
86
87 The hash %File::ShareDir::Dist::over can be used to override what
88 dist_share returns. You can also override behavior on the command
89 line using a dash followed by a key value pair joined by the equal
90 sign. In other words:
91
92 % perl -MFile::ShareDir::Dist=-Foo-Bar-Baz=./share -E 'say File::ShareDir::Dist::dist_share("Foo-Bar-Baz")'
93 /.../share
94
95 If neither of those work then you can set PERL_FILE_SHAREDIR_DIST to
96 a dist name, directory pair
97
98 % env PERL_FILE_SHAREDIR_DIST=Foo-Bar-Baz=`pwd`/share perl -MFile::ShareDir::Dist -E 'say File::ShareDir::Dist::dist_share("Foo-Bar-Baz")'
99
100 For File::ShareDir you have to either mock the dist_dir function or
101 install File::ShareDir::Override. For testing you can use
102 Test::File::ShareDir. I have never understood why such a simple
103 concept needs three modules to do all of this.
104
105 FUNCTIONS
106
107 Functions must be explicitly exported. They are not exported by
108 default.
109
110 dist_share
111
112 my $dir = dist_share $dist_name;
113 my $dir = dist_share $module_name;
114
115 Returns the absolute path to the share directory of the given
116 distribution.
117
118 As a convenience you can also use the "main" module name associated
119 with the distribution. That means if you want the share directory for
120 the dist Foo-Bar-Baz you may use either Foo-Bar-Baz or Foo::Bar::Baz to
121 find it.
122
123 Returns nothing if no share directory could be found.
124
125 dist_config
126
127 [version 0.07]
128
129 my $config = dist_config $dist_name;
130
131 Returns the config at runtime as created by
132 File::ShareDir::Dist::Install and install time.
133
134 ENVIRONMENT
135
136 PERL_FILE_SHAREDIR_DIST
137
138 Can be used to set a single dist directory override.
139
140 CAVEATS
141
142 All the stuff that is in File::ShareDir but not in this module could be
143 considered either caveats or features depending on your perspective I
144 suppose.
145
146 SEE ALSO
147
148 File::ShareDir::Dist::Install
149
150 App::Prove::Plugin::ShareDirDist
151
152 App::Yath::Plugin::ShareDirDist
153
154 AUTHOR
155
156 Author: Graham Ollis <[email protected]>
157
158 Contributors:
159
160 Yanick Champoux (yanick)
161
162 COPYRIGHT AND LICENSE
163
164 This software is copyright (c) 2017,2018 by Graham Ollis.
165
166 This is free software; you can redistribute it and/or modify it under
167 the same terms as the Perl 5 programming language system itself.
168