| 1 | package Module::Changes::Formatter::YAML; |
|---|
| 2 | |
|---|
| 3 | use warnings; |
|---|
| 4 | use strict; |
|---|
| 5 | use YAML; |
|---|
| 6 | use DateTime::Format::W3CDTF; |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | our $VERSION = '0.02'; |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | use base 'Module::Changes::Formatter'; |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | sub 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 | |
|---|
| 35 | 1; |
|---|
| 36 | |
|---|
| 37 | __END__ |
|---|
| 38 | |
|---|
| 39 | =head1 NAME |
|---|
| 40 | |
|---|
| 41 | Module::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 | |
|---|
| 51 | This class can format a Changes object as YAML. The layout of the YAML file is |
|---|
| 52 | documented in L<Module::Changes>. |
|---|
| 53 | |
|---|
| 54 | =head1 METHODS |
|---|
| 55 | |
|---|
| 56 | This class inherits all methods from L<Module::Changes::Formatter>. |
|---|
| 57 | |
|---|
| 58 | =over 4 |
|---|
| 59 | |
|---|
| 60 | =item format |
|---|
| 61 | |
|---|
| 62 | print $formatter->format($changes); |
|---|
| 63 | |
|---|
| 64 | Takes a changes object and formats it as YAML, then returns the result string. |
|---|
| 65 | |
|---|
| 66 | =back |
|---|
| 67 | |
|---|
| 68 | =head1 TAGS |
|---|
| 69 | |
|---|
| 70 | If you talk about this module in blogs, on del.icio.us or anywhere else, |
|---|
| 71 | please use the C<modulechanges> tag. |
|---|
| 72 | |
|---|
| 73 | =head1 BUGS AND LIMITATIONS |
|---|
| 74 | |
|---|
| 75 | No bugs have been reported. |
|---|
| 76 | |
|---|
| 77 | Please report any bugs or feature requests to |
|---|
| 78 | C<bug-module-changes@rt.cpan.org>, or through the web interface at |
|---|
| 79 | L<http://rt.cpan.org>. |
|---|
| 80 | |
|---|
| 81 | =head1 INSTALLATION |
|---|
| 82 | |
|---|
| 83 | See perlmodinstall for information and options on installing Perl modules. |
|---|
| 84 | |
|---|
| 85 | =head1 AVAILABILITY |
|---|
| 86 | |
|---|
| 87 | The latest version of this module is available from the Comprehensive Perl |
|---|
| 88 | Archive Network (CPAN). Visit <http://www.perl.com/CPAN/> to find a CPAN |
|---|
| 89 | site near you. Or see <http://www.perl.com/CPAN/authors/id/M/MA/MARCEL/>. |
|---|
| 90 | |
|---|
| 91 | =head1 AUTHOR |
|---|
| 92 | |
|---|
| 93 | Marcel GrE<uuml>nauer, C<< <marcel@cpan.org> >> |
|---|
| 94 | |
|---|
| 95 | =head1 COPYRIGHT AND LICENSE |
|---|
| 96 | |
|---|
| 97 | Copyright 2007 by Marcel GrE<uuml>nauer |
|---|
| 98 | |
|---|
| 99 | This library is free software; you can redistribute it and/or modify |
|---|
| 100 | it under the same terms as Perl itself. |
|---|
| 101 | |
|---|
| 102 | =cut |
|---|
| 103 | |
|---|