Skip to content

Commit 124e701

Browse files
authored
Merge pull request #2516 from ugexe/distribution-basics
Add basic Distribution docs This is in a branch, so no test has passed; I guess we'll check it more thoroughly when it's merged.
2 parents 6bee0a4 + b6dcaa0 commit 124e701

File tree

4 files changed

+135
-0
lines changed

4 files changed

+135
-0
lines changed

doc/Type/Distribution.pod6

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
=begin pod
2+
3+
=TITLE role Distribution
4+
5+
=SUBTITLE Distribution
6+
7+
role Distribution { }
8+
9+
Interface for objects that provide API access mapping META6 data to the files its represents.
10+
Objects that fulfill the C<Distribution> role can be read by e.g. L<CompUnit::Repository::Installation>.
11+
Generally a C<Distribution> provides read access to a set of modules and meta data. These
12+
may be backed by the file system (L<Distribution::Path>, L<Distribution::Hash>) but could
13+
also read from a e.g. tar file or socket.
14+
15+
=head1 Required Methods
16+
17+
=head2 method meta
18+
19+
method meta(--> Hash:D) { ... }
20+
21+
Returns a Hash with the representation of the meta data. Please note that an actual META6.json
22+
file does not need to exist, just a representation in that format.
23+
24+
=head2 method content
25+
26+
method content($name-path --> IO::Handle:D) { ... }
27+
28+
Returns an C<IO::Handle> to the file represented by C<$name-path>. C<$name-path> is a relative
29+
path as it would be found in the meta data such as C<lib/Foo.pm6> or C<resources/foo.txt>.
30+
31+
=end pod
32+
33+
# vim: expandtab softtabstop=4 shiftwidth=4 ft=perl6

doc/Type/Distribution/Hash.pod6

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
=begin pod
2+
3+
=TITLE class Distribution::Hash
4+
5+
=SUBTITLE Distribution::Hash
6+
7+
class Distribution::Hash does Distribution::Locally { }
8+
9+
A L<Distribution> implementation backed by the file system. It does not require a
10+
a C<META6.json> file, essentially providing a lower level C<Distribution::Path>.
11+
12+
=head1 Methods
13+
14+
=head2 method new
15+
16+
method new($hash, :$prefix)
17+
18+
Creates a new C<Distribution::Hash> instance from the meta data contained in C<$hash>.
19+
All paths in the meta data will be prefixed with C<:$prefix>.
20+
21+
=head2 method meta
22+
23+
method meta()
24+
25+
Returns a Hash with the representation of the meta data.
26+
27+
=head2 method content
28+
29+
L<Distribution::Locally#method_content>
30+
31+
Returns an C<IO::Handle> to the file represented by C<$name-path>. C<$name-path> is a relative
32+
path as it would be found in the meta data such as C<lib/Foo.pm6> or C<resources/foo.txt>.
33+
34+
=end pod
35+
36+
# vim: expandtab softtabstop=4 shiftwidth=4 ft=perl6

doc/Type/Distribution/Locally.pod6

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
=begin pod
2+
3+
=TITLE class Distribution::Locally
4+
5+
=SUBTITLE Distribution::Locally
6+
7+
role Distribution::Locally does Distribution { }
8+
9+
Provides read access to specific files pointed at by a distributions meta data,
10+
providing the L<Distribution#method_content> method for L<Distribution::Path>
11+
and L<Distribution::Hash>.
12+
13+
=head1 Methods
14+
15+
=head2 method prefix
16+
17+
A prefix path to be used in conjuncture with the paths found in the meta data.
18+
19+
=head2 method content
20+
21+
Provides L<Distribution#method_content>
22+
23+
Returns an C<IO::Handle> to the file represented by C<$name-path>. C<$name-path> is a relative
24+
path as it would be found in the meta data such as C<lib/Foo.pm6> or C<resources/foo.txt>, and
25+
these paths will be prefixed with L<Distribution#method_prefix>.
26+
27+
=end pod
28+
29+
# vim: expandtab softtabstop=4 shiftwidth=4 ft=perl6

doc/Type/Distribution/Path.pod6

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
=begin pod
2+
3+
=TITLE class Distribution::Path
4+
5+
=SUBTITLE Distribution::Path
6+
7+
class Distribution::Path does Distribution::Locally { }
8+
9+
A L<Distribution> implementation backed by the file system. It requires a
10+
C<META6.json> file at its root.
11+
12+
=head1 Methods
13+
14+
=head2 method new
15+
16+
method new(IO::Path $prefix, IO::Path :$meta-file = IO::Path)
17+
18+
Creates a new C<Distribution::Path> instance from the C<META6.json> file found at the given
19+
C<$prefix>, and from which all paths in the meta data will be prefixed with. C<:$meta-file>
20+
may optionally be passed if a filename other than C<META6.json> needs to be used.
21+
22+
=head2 method meta
23+
24+
method meta()
25+
26+
Returns a Hash with the representation of the meta data.
27+
28+
=head2 method content
29+
30+
L<Distribution::Locally#method_content>
31+
32+
Returns an C<IO::Handle> to the file represented by C<$name-path>. C<$name-path> is a relative
33+
path as it would be found in the meta data such as C<lib/Foo.pm6> or C<resources/foo.txt>.
34+
35+
=end pod
36+
37+
# vim: expandtab softtabstop=4 shiftwidth=4 ft=perl6

0 commit comments

Comments
 (0)