Build::Daily - module to update daily versions for Module::Build and ExtUtils::MakeMaker


Build-Daily documentation Contained in the Build-Daily distribution.

Index


Code Index:

NAME

Top

Build::Daily - module to update daily versions for Module::Build and ExtUtils::MakeMaker

SYNOPSIS

Top

    perl -MBuild::Daily Build.PL
    perl -MBuild::Daily Makefile.PL

    # force version append, useful when not building daily but based on ex. SVN revisions
    perl -MBuild::Daily=version,12345 Build.PL
    perl -MBuild::Daily=version,12345 Build
    perl -MBuild::Daily=version,12345 Build distmeta
    perl -MBuild::Daily=version,12345 Build dist

DESCRIPTION

Top

Updates $VERSION string based on current date or forced string. This allows to create daily/commit builds.

FUNCTIONS

import()

    use Build::Daily 'version' => '12345';

Forces string that will be appended.

version($original_version)

For original version returns new version.

    $original_version.($original_version =~ m/_/ ? '' : '_').$append

$append is either YearMonthDay or the forced string.

AUTHOR

Top

Jozef Kutej, <jkutej at cpan.org>

BUGS

Top

Please report any bugs or feature requests to bug-build-daily at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Build-Daily. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

Top

You can find documentation for this module with the perldoc command.

    perldoc Build::Daily




You can also look for information at:

* RT: CPAN's request tracker

http://rt.cpan.org/NoAuth/Bugs.html?Dist=Build-Daily

* AnnoCPAN: Annotated CPAN documentation

http://annocpan.org/dist/Build-Daily

* CPAN Ratings

http://cpanratings.perl.org/d/Build-Daily

* Search CPAN

http://search.cpan.org/dist/Build-Daily

ACKNOWLEDGEMENTS

Top

COPYRIGHT & LICENSE

Top


Build-Daily documentation Contained in the Build-Daily distribution.
package Build::Daily;

use warnings;
use strict;

our $VERSION = '0.01';

use Module::Build 0.2808;
use Module::Build::ModuleInfo;
use ExtUtils::MakeMaker;
use DateTime;

# a references to the original methods
my $MODULE_BUILD_NEW;
my $EXTUTILS_MM_NEW;
BEGIN {
	$MODULE_BUILD_NEW = \&Module::Build::Base::new;
	$EXTUTILS_MM_NEW  = \&ExtUtils::MakeMaker::new;
}
our $FORCED_VERSION;
our $BUILD_DAILY_VERSION = \&version;

sub import {
    my $class = shift;
    my %args  = @_;
    
    $FORCED_VERSION = $args{'version'};
}

sub version {
    my $original_version = shift;
        
    my $append = (
        defined $FORCED_VERSION
        ? $FORCED_VERSION
        : DateTime->now('time_zone' => 'local')->ymd("")
    );
    
    return $original_version.($original_version =~ m/_/ ? '' : '_').$append;
}

no warnings 'redefine';

package Module::Build::Base;

sub new {
    my $class = shift;
    my %args  = @_;
    
    if (defined $args{'dist_version_from'}) {
        my $info = eval { Module::Build::ModuleInfo->new_from_file($args{'dist_version_from'}) };
        die 'failed to get VERSION from '.$args{'dist_version_from'}
            if not defined $info;
        
        delete $args{'dist_version_from'};
        $args{'dist_version'} = $info->{'version'}->{'original'};
    }
    if (defined $args{'dist_version'}) {
        $args{'dist_version'} = $BUILD_DAILY_VERSION->($args{'dist_version'});
    }
    
    return $MODULE_BUILD_NEW->($class, %args);
}

package ExtUtils::MakeMaker;

sub new {
    my $class = shift;
    my $args  = shift;
    
    if (defined $args->{'VERSION_FROM'}) {
        my $info = eval { Module::Build::ModuleInfo->new_from_file($args->{'VERSION_FROM'}) };
        die 'failed to get VERSION from '.$args->{'VERSION_FROM'}
            if not defined $info;
        
        delete $args->{'VERSION_FROM'};        
        $args->{'VERSION'} = $info->{'version'}->{'original'};
    }
    if (defined $args->{'VERSION'}) {
        $args->{'VERSION'} = $BUILD_DAILY_VERSION->($args->{'VERSION'});
    }
    
    return $EXTUTILS_MM_NEW->($class, $args);
}

'SUPERMAN gesucht';



__END__