root/lang/perl/Module-Changes/tags/Module-Changes-0.02/lib/Module/Changes/Formatter/YAML.pm @ 9784

Revision 9784, 2.2 kB (checked in by hanekomu, 5 years ago)

r6132@nbgr: marcel | 2008-04-18 16:47:20 +0200
lang/perl/Module-Changes: initial commit

Line 
1package Module::Changes::Formatter::YAML;
2
3use warnings;
4use strict;
5use YAML;
6use DateTime::Format::W3CDTF;
7
8
9our $VERSION = '0.02';
10
11
12use base 'Module::Changes::Formatter';
13
14
15sub format {
16    my ($self, $changes) = @_;
17    my @format;
18
19    push @format => { global => { name => $changes->name } };
20
21    for my $release ($changes->releases) {
22        my $version = $release->version_as_string;
23        my $version_spec = {};
24        $version_spec->{date} =
25            DateTime::Format::W3CDTF->new->format_datetime($release->date);
26        $version_spec->{$_} = $release->$_ for qw(author changes tags);
27
28        push @format => { $version => $version_spec };
29    }
30
31    Dump \@format;
32}
33
34
351;
36
37__END__
38
39=head1 NAME
40
41Module::Changes::Formatter::YAML - format a Changes object as YAML
42
43=head1 SYNOPSIS
44
45    use Module::Changes;
46    my $formatter = Module::Changes->make_object_for_type('formatter_yaml');
47    $formatter->format($changes);
48
49=head1 DESCRIPTION
50
51This class can format a Changes object as YAML. The layout of the YAML file is
52documented in L<Module::Changes>.
53
54=head1 METHODS
55
56This class inherits all methods from L<Module::Changes::Formatter>.
57
58=over 4
59
60=item format
61
62    print $formatter->format($changes);
63
64Takes a changes object and formats it as YAML, then returns the result string.
65
66=back
67
68=head1 TAGS
69
70If you talk about this module in blogs, on del.icio.us or anywhere else,
71please use the C<modulechanges> tag.
72
73=head1 BUGS AND LIMITATIONS
74
75No bugs have been reported.
76
77Please report any bugs or feature requests to
78C<bug-module-changes@rt.cpan.org>, or through the web interface at
79L<http://rt.cpan.org>.
80
81=head1 INSTALLATION
82
83See perlmodinstall for information and options on installing Perl modules.
84
85=head1 AVAILABILITY
86
87The latest version of this module is available from the Comprehensive Perl
88Archive Network (CPAN). Visit <http://www.perl.com/CPAN/> to find a CPAN
89site near you. Or see <http://www.perl.com/CPAN/authors/id/M/MA/MARCEL/>.
90
91=head1 AUTHOR
92
93Marcel GrE<uuml>nauer, C<< <marcel@cpan.org> >>
94
95=head1 COPYRIGHT AND LICENSE
96
97Copyright 2007 by Marcel GrE<uuml>nauer
98
99This library is free software; you can redistribute it and/or modify
100it under the same terms as Perl itself.
101
102=cut
103
Note: See TracBrowser for help on using the browser.