Acme-CPANAuthors-BackPAN-OneHundred

 view release on metacpan or  search on metacpan

examples/update100.pl  view on Meta::CPAN


# create lists
for my $inx (sort {$new{$a}{pause} cmp $new{$b}{pause}} keys %new) {
    my $pad = $max - length $new{$inx}{pause};
    push @{$tvars{LIST1}}, sprintf "    '%s'%s=> '%s',", $new{$inx}{pause}, (' ' x $pad), $new{$inx}{name};
}

my $cnt = 1;
for my $inx (sort {$new{$b}{count} <=> $new{$a}{count} || $new{$a}{pause} cmp $new{$b}{pause}} keys %new) {
    my $pad = $max - length $new{$inx}{pause};
    push @{$tvars{LIST2}}, sprintf "  %2d.  %3d  %s%s%s", $cnt++, $new{$inx}{count}, $new{$inx}{pause}, (' ' x $pad), $new{$inx}{name};
}

# calculate copyright
$tvars{COPYRIGHT} = '2014';
my $year = DateTime->now->year;
$tvars{COPYRIGHT} .= "-$year"  if($year > 2014);

# calculate version
$file = '../Changes';
my $changes = CPAN::Changes->load( $file );

my @releases = $changes->releases();
my $version  = $releases[-1]->{version};
$version += 0.01;
$tvars{VERSION} = sprintf "%.2f", $version;

# update Changes file
my $release = CPAN::Changes::Release->new( version => $tvars{VERSION}, date => DateTime->now->ymd );
for my $group (qw(insert update delete)) {
    next    unless($changes{$group});

    $release->add_changes(
        { group => $groups{$group} },
        join(', ',@{$changes{$group}})
    );

    push @releases, $release;
}

$changes->releases( @releases );

$fh = IO::File->new($file,'w+') or die "Cannot open file [$file]: $!\n";
my $content = $changes->serialize;
my @content = split(/\n/,$content);
$content = '';
for my $line (@content) {
    $line =~ s/^([\d.]+)\s+(.*?)$/$1    $2/;
    $line =~ s/^\s+(.*?)/        $1/;
    $line =~ s/^\s+(.*?)/        - $1/ unless($line =~ /^\s+[\[\-]/);
    $content .= "$line\n";
}
print $fh $content;
$fh->close;

# update other files
my $parser = Template->new(\%config);        # initialise parser
for my $template (@files) {
    eval {
        # parse to text
        $parser->process($template,\%tvars,$template) or die $parser->error();
    };

    die "TT PARSER ERROR: eval=$@, error=" . $parser->error  if($@);
}

# now store new data
system("cp data/backpan100.csv data/backpan100.old.csv ");
system("mv backpan100.csv data");

if($options{build}) {
    # build tarball
    system("perl Makfile.PL");
    system("make dist");

    if($options{release}) {
        # submit tarball
        system("cpan-upload Acme-CPANAuthors-BackPAN-OneHundred-$tvars{VERSION}.tar.gz");
    }
}

print "Done!\n";

__END__

=head1 BUGS, PATCHES & FIXES

There are no known bugs at the time of this release. However, if you spot a
bug or are experiencing difficulties, that is not explained within the POD
documentation, please send bug reports and patches to the RT Queue (see below).

Fixes are dependent upon their severity and my availability. Should a fix not
be forthcoming, please feel free to (politely) remind me.

RT Queue -
http://rt.cpan.org/Public/Dist/Display.html?Name=Acme-CPANAuthors-BackPAN-OneHundred

=head1 AUTHOR

  Barbie, <barbie@cpan.org>
  for Miss Barbell Productions <http://www.missbarbell.co.uk>.

=head1 COPYRIGHT AND LICENSE

  Copyright (C) 2014 Barbie for Miss Barbell Productions.

  This distribution is free software; you can redistribute it and/or
  modify it under the Artistic Licence v2.

=cut



( run in 1.438 second using v1.01-cache-2.11-cpan-39bf76dae61 )