1Dir::Manifest(3)      User Contributed Perl Documentation     Dir::Manifest(3)
2
3
4

NAME

6       Dir::Manifest - treat a directory and a manifest file as a
7       hash/dictionary of keys to texts or blobs
8

VERSION

10       version 0.6.1
11

SYNOPSIS

13           use Dir::Manifest ();
14
15           my $obj = Dir::Manifest->new(
16               {
17                   manifest_fn => "./t/data/texts/list.txt",
18                   dir         => "./t/data/texts/texts",
19               }
20           );
21
22           # Or alternatively:
23           my $obj = Dir::Manifest->dwim_new(
24               {
25                   base => "./t/data/texts",
26               }
27           );
28
29           # TEST
30           is (
31               scalar(`my-process ...`),
32               $obj->text("my-process-output1", {lf => 1,}),
33               "Good output of my-process.",
34           );
35

DESCRIPTION

37       Here is the primary use case: you have several long texts (and/or
38       binary blobs) that you wish to load from the code (e.g: for the
39       "want"/expected values of tests) and you wish to conventiently edit
40       them, track them and maintain them. Using Dir::Manifest you can put
41       each in a separate file in a directory, create a manifest file listing
42       all valid filenames/key and then say something like "my $text =
43       $dir->text("deal24solution.txt", {lf => 1})". And hopefully it will be
44       done securely and reliably.
45

METHODS

47   my $obj = Dir::Manifest->new({manifest_fn => "/path/to/base-dir/list.txr",
48       dir => "/path/to/base-dir/texts",});
49       Constructs a new Dir::Manifest object from separate manifest_fn and a
50       directory holding the texts.
51
52   my $obj = Dir::Manifest->dwim_new({base => "/path/to/base-dir"});
53       Constructs a new Dir::Manifest with manifest_fn being
54       "$base->child("list.txt")" and dir being "$base->child("texts")".
55       ("Convention over configuration".)
56
57       Added in version 0.6.0.
58
59   $self->manifest_fn()
60       The path to the manifest file.
61
62   $self->dir()
63       The path to the directory containing the texts and blobs as files.
64
65   $self->get_keys()
66       Returns a sorted array reference containing the available keys as
67       strings.
68
69   $self->get_obj($key)
70       Returns the Dir::Manifest::Key object associated with the string $key.
71       Throws an error if $key was not given in the manifest.
72
73   $self->fh($key)
74       Returns the Path::Tiny objects for the key, which is usable as a path
75       in string context. Equivalent to "$self->get_obj($key)->fh()".
76
77       (Added in version 0.2.0. ).
78
79   my $contents = $self->text("$key", {%OPTS})
80       Slurps the key using Dir::Manifest::Slurp
81
82   my $hash_ref = $obj->texts_dictionary( {slurp_opts => {},} );
83       Returns a hash reference (a dictionary) containing all keys and their
84       slurped contents as values. 'slurp_opts' is passed to text().
85
86   $obj->add_key( {key => "new_key", utf8_val => $utf8_text, } );
87       Adds a new key with a file with the new UTF-8 contents encoded as
88       $utf8_text .  (Added in version 0.4.0).
89
90   $obj->remove_key( {key => "existing_key_id", } );
91       Removes the key from the dictionary while deleting its associated file.
92       (Added in version 0.4.0).
93

DEDICATION

95       This code is dedicated to the memory of Jonathan Scott Duff
96       <https://metacpan.org/author/DUFF> a.k.a PerlJam and perlpilot who
97       passed away some days before the first release of this code. For more
98       about him, see:
99
100       ·   <https://p6weekly.wordpress.com/2018/12/30/2018-53-goodbye-perljam/>
101
102       ·   <https://www.facebook.com/groups/perl6/permalink/2253332891599724/>
103
104       ·   <https://www.mail-archive.com/perl6-users@perl.org/msg06390.html>
105
106       ·   <https://www.shlomifish.org/humour/fortunes/sharp-perl.html>
107

MEDIA RECOMMENDATION

109       kristian vuljar <https://www.jamendo.com/artist/441226/kristian-vuljar>
110       used to have a jamendo track called "Keys" based on Shine 4U
111       <https://www.youtube.com/watch?v=B8ehY5tutHs> by Carmen and Camille.
112       You can find it at
113       <http://www.shlomifish.org/Files/files/dirs/kristian-vuljar--keys/> .
114

SUPPORT

116   Websites
117       The following websites have more information about this module, and may
118       be of help to you. As always, in addition to those websites please use
119       your favorite search engine to discover more resources.
120
121       ·   MetaCPAN
122
123           A modern, open-source CPAN search engine, useful to view POD in
124           HTML format.
125
126           <https://metacpan.org/release/Dir-Manifest>
127
128       ·   Search CPAN
129
130           The default CPAN search engine, useful to view POD in HTML format.
131
132           <http://search.cpan.org/dist/Dir-Manifest>
133
134       ·   RT: CPAN's Bug Tracker
135
136           The RT ( Request Tracker ) website is the default bug/issue
137           tracking system for CPAN.
138
139           <https://rt.cpan.org/Public/Dist/Display.html?Name=Dir-Manifest>
140
141       ·   CPAN Ratings
142
143           The CPAN Ratings is a website that allows community ratings and
144           reviews of Perl modules.
145
146           <http://cpanratings.perl.org/d/Dir-Manifest>
147
148       ·   CPANTS
149
150           The CPANTS is a website that analyzes the Kwalitee ( code metrics )
151           of a distribution.
152
153           <http://cpants.cpanauthors.org/dist/Dir-Manifest>
154
155       ·   CPAN Testers
156
157           The CPAN Testers is a network of smoke testers who run automated
158           tests on uploaded CPAN distributions.
159
160           <http://www.cpantesters.org/distro/D/Dir-Manifest>
161
162       ·   CPAN Testers Matrix
163
164           The CPAN Testers Matrix is a website that provides a visual
165           overview of the test results for a distribution on various
166           Perls/platforms.
167
168           <http://matrix.cpantesters.org/?dist=Dir-Manifest>
169
170       ·   CPAN Testers Dependencies
171
172           The CPAN Testers Dependencies is a website that shows a chart of
173           the test results of all dependencies for a distribution.
174
175           <http://deps.cpantesters.org/?module=Dir::Manifest>
176
177   Bugs / Feature Requests
178       Please report any bugs or feature requests by email to
179       "bug-dir-manifest at rt.cpan.org", or through the web interface at
180       <https://rt.cpan.org/Public/Bug/Report.html?Queue=Dir-Manifest>. You
181       will be automatically notified of any progress on the request by the
182       system.
183
184   Source Code
185       The code is open to the world, and available for you to hack on. Please
186       feel free to browse it and play with it, or whatever. If you want to
187       contribute patches, please send me a diff or prod me to pull from your
188       repository :)
189
190       <https://github.com/shlomif/Dir-Manifest>
191
192         git clone https://github.com/shlomif/Dir-Manifest.git
193

AUTHOR

195       Shlomi Fish <shlomif@cpan.org>
196

BUGS

198       Please report any bugs or feature requests on the bugtracker website
199       <https://github.com/shlomif/dir-manifest/issues>
200
201       When submitting a bug or request, please include a test-file or a patch
202       to an existing test-file that illustrates the bug or desired feature.
203
205       This software is Copyright (c) 2019 by Shlomi Fish.
206
207       This is free software, licensed under:
208
209         The MIT (X11) License
210
211
212
213perl v5.30.1                      2019-07-26                  Dir::Manifest(3)
Impressum