Skip to content

Commit f84b6d2

Browse files
committed
Add POD
1 parent 5cf0975 commit f84b6d2

File tree

1 file changed

+98
-0
lines changed

1 file changed

+98
-0
lines changed

lib/META6.pm

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,99 @@
11
use v6;
22

3+
=begin pod
4+
5+
=head1 NAME
6+
7+
META6 - Read, Parse, Generate Perl 6 META files.
8+
9+
10+
11+
=head1 SYNOPSIS
12+
13+
The below will generate the C<META.info> for this module.
14+
15+
=begin code
16+
17+
use META6;
18+
19+
my $m = META6.new( name => 'META6',
20+
description => 'Work with Perl 6 META files',
21+
version => Version.new('0.0.1'),
22+
perl => Version.new('6'),
23+
depends => <JSON::Class>,
24+
test-depends => <Test>,
25+
tags => <devel meta utils>,
26+
authors => ['Jonathan Stowe <jns+git@gellyfish.co.uk>'],
27+
auth => 'github:jonathanstowe',
28+
source-url => 'git://github.com/jonathanstowe/META6.git',
29+
support => META6::Support.new(
30+
source => 'git://github.com/jonathanstowe/META6.git'
31+
),
32+
provides => {
33+
META6 => 'lib/META6.pm',
34+
},
35+
license => 'Artistic',
36+
production => False,
37+
38+
);
39+
40+
print $m.to-json;
41+
42+
=end code
43+
44+
=head1 DESCRIPTION
45+
46+
This provides a representation of the Perl 6 L<META
47+
files|http://design.perl6.org/S22.html#META6.json> specification -
48+
the META file data can be read, created , parsed and written in a manner
49+
that is conformant with the specification.
50+
51+
Where they are known about it also makes allowance for "customary"
52+
usage in existing software (such as installers and so forth.)
53+
54+
The intent of this is allow the generation and testing of META files for
55+
module authors, so it can provide meta-information whether the attributes
56+
are mandatory as per the spec and where known the places that "customary"
57+
attributes are used, though this doesn't preclude it being used for other
58+
purposes.
59+
60+
=head1 METHODS
61+
62+
All of the available attributes are documented in the specification so I
63+
won't duplicate here, only documenting the methods provided by the
64+
module.
65+
66+
=head2 method new
67+
68+
multi method new(Str :$file!)
69+
multi method new(IO::Path :$file!)
70+
multi method new(IO::Handle :$file!)
71+
multi method new(Str:D :$json!)
72+
73+
This is the contructor of the class, it can take a named argument C<file>
74+
which can be the name of a file, an L<IO::Path> representing or a
75+
L<IO::Handle> opened to a file containing the META json. Alternatively an
76+
argument C<json> can be supplied which should contain the JSON string to
77+
be parsed as META info.
78+
79+
If the file doesn't exist, cannot be opened, cannot be read or does not
80+
contain valid JSON and exception will be thrown.
81+
82+
Additionally there still is the default constructor (as shown in the
83+
L<SYNOPSIS|#SYNOPSIS>,) that allows the population of the attributes
84+
directly (which may be useful when generating a META file.)
85+
86+
=head2 method to-json
87+
88+
method to-json() returns Str
89+
90+
This is provided by L<JSON::Class>. It will return the JSON string
91+
representation of the META info. The class should prevent there being
92+
anything that can't be represented as JSON so it shouldn't throw an
93+
exception.
94+
95+
=end pod
96+
397
use JSON::Class;
498

599
# Need to import here to get the traits
@@ -43,6 +137,10 @@ class META6 does JSON::Class {
43137

44138
multi method new(IO::Handle :$file!) {
45139
my $json = $file.slurp-rest;
140+
self.new(:$json);
141+
}
142+
143+
multi method new(Str:D :$json!) {
46144
self.from-json($json);
47145
}
48146

0 commit comments

Comments
 (0)