App-Changelog2x
view release on metacpan or search on metacpan
author:
- 'Randy J. Ray <rjray@blackperl.com>'
abstract: A script to generate XHTML and text from ChangeLogML XML
license: perl
resources:
license: http://dev.perl.org/licenses/
build_requires:
Module::Build: 0.28
Test::More: 0.80
requires:
DateTime: 0.45
DateTime::Format::ISO8601: 0.06
Exporter: 5.57
File::Spec: 0.8
XML::LibXML: 1.60
XML::LibXSLT: 1.60
perl: 5.008
recommends:
Test::Pod: 0
Test::Pod::Coverage: 0
configure_requires:
Module::Build: 0.34
Makefile.PL view on Meta::CPAN
# Note: this file was auto-generated by Module::Build::Compat version 0.34
require 5.008;
use ExtUtils::MakeMaker;
WriteMakefile
(
'NAME' => 'App::Changelog2x',
'VERSION_FROM' => 'lib/App/Changelog2x.pm',
'PREREQ_PM' => {
'DateTime' => '0.45',
'DateTime::Format::ISO8601' => '0.06',
'Exporter' => '5.57',
'File::Spec' => '0.8',
'Module::Build' => '0.28',
'Test::More' => '0.80',
'XML::LibXML' => '1.60',
'XML::LibXSLT' => '1.60'
},
'INSTALLDIRS' => 'site',
'EXE_FILES' => [
'bin/changelog2x'
bin/changelog2x view on Meta::CPAN
# modules to format a ChangeLogML file into some form of
# human-readable output.
#
# Functions: formats_list
#
# Libraries: App::Changelog2x
# File::Spec
# Getopt::Long
# XML::LibXML
# XML::LibXSLT
# DateTime
# DateTime::Format::ISO8601
#
# Globals: $VERSION
# $revision
# $cmd
#
###############################################################################
use 5.008;
use strict;
use warnings;
use vars qw($dir $cmd $USAGE $VERSION %opts $app);
use subs qw(formats_list);
use constant STYLESHEET_OPTS => qw(notoc versions order css color javascript
headcontent bodycontent class);
use File::Spec;
use Getopt::Long;
use XML::LibXML;
use XML::LibXSLT;
use DateTime;
use DateTime::Format::ISO8601;
use App::Changelog2x;
$VERSION = '0.11';
($dir, $cmd) = (File::Spec->splitpath($0))[1, 2];
$USAGE = "$cmd [ --input file ] [ --output file ] [ --format date-format ]
\t[ --template template ] [ --templateroot dir ]
\t[ --headcontentfile file ] [ --bodycontentfile file ]
\t[ stylesheet opts ... ]
bin/changelog2x view on Meta::CPAN
=item --output FILE
If this option is passed, it specifies the file to write the transformed
content out to. If the value of this string is C<->, or if the option is not
passed at all, then the STDOUT file-handle is used.
=item --format STRING
=item -f STRING
This option specifies an alternate format pattern for the B<DateTime>
C<strftime> method to use when formatting the dates in the C<< <release> >>
tags. Note that B<< DateTime->strftime >> formatting is sensitive to your
locale setting. The format is also used for those output templates that
include "generated on" comments.
This option may be abbreviated as C<-f> for convenience.
=item --template NAME
=item -t NAME
Specifies the XSLT template to use. This may be a filename path or a string.
lib/App/Changelog2x.pm view on Meta::CPAN
# default_date_format
# date_format
# xslt_path
# application_tokens
# format_date
# credits
# transform_changelog
#
# Libraries: XML::LibXML
# XML::LibXSLT
# DateTime
# DateTime::Format::ISO8601
# File::Spec
#
# Global Consts: $VERSION
# URI
#
###############################################################################
package App::Changelog2x;
use 5.008;
lib/App/Changelog2x.pm view on Meta::CPAN
use vars qw($VERSION $FORMAT $DEFAULT_XSLT_PATH);
use subs qw(new version default_xslt_path default_date_format date_format
xslt_path application_tokens format_date credits
transform_changelog);
use constant URI => 'http://www.blackperl.com/2009/01/ChangeLogML';
use File::Spec;
use XML::LibXML;
use XML::LibXSLT;
use DateTime;
use DateTime::Format::ISO8601;
BEGIN
{
$VERSION = '0.11';
$DEFAULT_XSLT_PATH = (File::Spec->splitpath(__FILE__))[1];
$DEFAULT_XSLT_PATH = File::Spec->catdir($DEFAULT_XSLT_PATH, 'changelog2x');
}
###############################################################################
lib/App/Changelog2x.pm view on Meta::CPAN
# $to_utc in scalar Boolean flag, whether to
# convert times to GMT/UTC
#
# Returns: Formatted date/time
#
###############################################################################
sub format_date
{
my ($self, $date, $to_utc) = @_;
my $dt = DateTime::Format::ISO8601->parse_datetime($date);
$dt->set_time_zone('UTC') if $to_utc;
my $string = $dt->strftime($self->date_format);
if ($string =~ /TZ_/)
{
my %tz_edit = ( TZ_LONG => $dt->time_zone->name,
TZ_SHORT => $dt->time_zone->short_name_for_datetime );
$string =~ s/(TZ_LONG|TZ_SHORT)/$tz_edit{$1}/ge;
}
lib/App/Changelog2x.pm view on Meta::CPAN
Any other key/value pairs are stored on the hash reference unchanged.
=item version
Returns the current version of this module (used in the C<credits> method,
below).
=item default_date_format
Returns the default date format, a string that is passed to the C<strftime>
method of B<DateTime>. The default format is a slightly more-verbose
version of the UNIX "date" format, with full day- and month-names and a
12-hour clock rather than 24-hour. A typical date formatted this way would
look like this:
Friday September 19, 2008, 02:23:12 AM -0700
=item default_xslt_path
Returns the default path to use when searching for XSLT stylesheets that are
not already absolute-path filenames. The default path for this module is a
directory called C<changelog2x> that resides in the same directory as this
module.
=item date_format [FORMAT]
Get or set the date-format to use when C<format_date> is called. If the user
does not explicitly set a format, the value returned by C<default_date_format>
is used.
See L<DateTime/"strftime Patterns"> for a description of the formatting
codes to use in a format string.
One special value is recognized: C<unix>. If C<date_format> is called with
this value as a format string, a pre-defined format is used that emulates the
UNIX C<date> command as closely as possible (but see L</CAVEATS> for notes
on B<DateTime> limitations with regards to timezone names and the special
patterns recognized in date format strings to try and work around this). A
string formatted this way looks like this:
Mon Aug 10 09:21:46 -0700 2009
=item xslt_path [DIRS]
Get or set the directories to use when searching for XSLT stylesheets that are
not specified by absolute pathname.
lib/App/Changelog2x.pm view on Meta::CPAN
If no match is found for TEMPLATE, a null string is returned. If TEMPLATE is
already an absolute path, or if the first character of the string is C<.>,
then it is considered to already be an absolute path and is returned
unchanged.
=back
=head1 CAVEATS
The B<DateTime> package does not attempt to map timezone values to the old
3-letter codes that were once the definitive representation of timezones.
Because timezones are now much more granular in definition, a timezone offset
cannot be canonically mapped to a specific name. The only timezone that can be
canonically mapped is UTC. Thus, for now, timezones in dates are given as their
offsets from UTC, unless the date is being rendered in UTC directly.
=head1 SEE ALSO
L<changelog2x>, L<https://sourceforge.net/projects/changelogml>
( run in 0.295 second using v1.01-cache-2.11-cpan-05444aca049 )