File Coverage

blib/lib/Dist/Zilla/Plugin/DOAP.pm
Criterion Covered Total %
statement 7 9 77.7
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 10 12 83.3


line stmt bran cond sub pod time code
1 1     1   14906 use strict;
  1         1  
  1         30  
2 1     1   3 use warnings;
  1         1  
  1         49  
3              
4             package Dist::Zilla::Plugin::DOAP;
5             # ABSTRACT: create a doap.xml file for your project
6              
7             our $AUTHORITY = 'cpan:TOBYINK';
8             our $VERSION = '0.003';
9              
10 1     1   855 use Moose;
  0            
  0            
11             with qw(
12             Dist::Zilla::Role::FileGatherer
13             );
14              
15             use namespace::autoclean;
16             use CPAN::Changes;
17             use CPAN::Meta;
18             use Dist::Zilla::File::InMemory;
19             use Dist::Zilla::Types qw(OneZero);
20             use RDF::DOAP::Lite;
21              
22             has xml_filename => (
23             is => 'ro',
24             isa => 'Maybe[Str]',
25             default => 'doap.xml',
26             );
27              
28             has ttl_filename => (
29             is => 'ro',
30             isa => 'Maybe[Str]',
31             );
32              
33             has process_changes => (
34             is => 'ro',
35             isa => OneZero,
36             default => 0,
37             coerce => 1,
38             );
39              
40             sub gather_files
41             {
42             my $self = shift;
43            
44             my $zilla = $self->zilla;
45             my $doap = 'RDF::DOAP::Lite'->new(
46             meta => 'CPAN::Meta'->new( {%{$zilla->distmeta}} ),
47             (($self->process_changes and -f 'Changes')
48             ? (changes => 'CPAN::Changes'->load('Changes'))
49             : ()),
50             );
51            
52             if ($self->xml_filename)
53             {
54             my $data;
55             open my $fh, '>', \$data;
56             $doap->doap_xml($fh);
57             close $fh;
58            
59             $self->add_file('Dist::Zilla::File::InMemory'->new(
60             name => $self->xml_filename,
61             content => $data,
62             ));
63             }
64              
65             if ($self->ttl_filename)
66             {
67             my $data;
68             open my $fh, '>', \$data;
69             $doap->doap_ttl($fh);
70             close $fh;
71            
72             $self->add_file('Dist::Zilla::File::InMemory'->new(
73             name => $self->ttl_filename,
74             content => $data,
75             ));
76             }
77             }
78            
79             __PACKAGE__->meta->make_immutable;
80              
81             1;
82              
83             __END__
84              
85             =pod
86              
87             =encoding utf-8
88              
89             =head1 NAME
90              
91             Dist::Zilla::Plugin::DOAP - create a doap.xml file for your project
92              
93             =head1 SYNOPSIS
94              
95             In dist.ini:
96              
97             [DOAP]
98              
99             Or even:
100              
101             [DOAP]
102             xml_filename = project.xml
103             ttl_filename = project.ttl
104              
105             =head1 DESCRIPTION
106              
107             This is a small plugin for L<Dist::Zilla>, enabling you to bundle a
108             DOAP file with your distribution.
109              
110             =head2 The Straight DOAP
111              
112             So what is DOAP? This explanation is lifted from
113             L<Wikipedia|http://en.wikipedia.org/wiki/DOAP>.
114              
115             I<< DOAP (Description of a Project) is an RDF Schema and XML vocabulary
116             to describe software projects, in particular free and open source
117             software. >>
118              
119             I<< It was created and initially developed by Edd Dumbill to convey
120             semantic information associated with open source software projects. >>
121              
122             I<< It is currently used in the Mozilla Foundation's project page and
123             in several other software repositories, notably the Python Package
124             Index. >>
125              
126             =head2 Configuration
127              
128             This plugin has three settings that you can tweak in your C<dist.ini> file:
129              
130             =over
131              
132             =item C<< xml_filename >>
133              
134             The filename for DOAP output, serialized as XML. Defaults to "doap.xml".
135             Set this to the empty string to disable XML output.
136              
137             =item C<< ttl_filename >>
138              
139             The filename for DOAP output, serialized in the slightly more readable
140             Turtle format. Defaults to undef. Set this to a filename to output some
141             Turtle.
142              
143             =item C<< process_changes >>
144              
145             A boolean indicating whether your C<Changes> file should be processed
146             to generate a release history. Defaults to 0 (no).
147              
148             =back
149              
150             =head2 Hints
151              
152             For the most part, everything should "just work". The plugin will figure
153             out everything it needs from your C<distmeta> (i.e. META.json) and
154             C<Changes> file (if it exists). Here are a few hints though...
155              
156             =over
157              
158             =item *
159              
160             For this module to have the best chance of reading your changelog, format
161             it as per L<CPAN::Changes::Spec>.
162              
163             =item *
164              
165             DOAP represents people as structured resources, while META.json represents
166             them as strings. This module expects authors and contributors listed in
167             META.json to conform to one of the following formats:
168              
169             Joe Bloggs (JOEB) <joe.bloggs@example.net>
170             Joe Bloggs <joe.bloggs@example.net>
171             Joe Bloggs
172              
173             (Assuming that "JOEB" is Joe's PAUSE login.)
174              
175             =back
176              
177             =head1 BUGS
178              
179             Please report any bugs to
180             L<http://rt.cpan.org/Dist/Display.html?Queue=Dist-Zilla-Plugin-DOAP>.
181              
182             =head1 SEE ALSO
183              
184             L<RDF::DOAP>, L<RDF::DOAP::Lite>.
185              
186             =head1 AUTHOR
187              
188             Toby Inkster E<lt>tobyink@cpan.orgE<gt>.
189              
190             =head1 COPYRIGHT AND LICENCE
191              
192             This software is copyright (c) 2014 by Toby Inkster.
193              
194             This is free software; you can redistribute it and/or modify it under
195             the same terms as the Perl 5 programming language system itself.
196              
197             =head1 DISCLAIMER OF WARRANTIES
198              
199             THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
200             WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
201             MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
202              
203             =cut