Burak Gürsoy avatar Burak Gürsoy committed c8da5a1

update builder

Comments (0)

Files changed (7)

 use strict;
-use Module::Build;
-use File::Spec;
-use IO::File;
+use lib qw( builder );
+use Build;
 
-my $class = Module::Build->subclass(
-                class => 'MBSubclass',
-                code  => raw_subclass(),
-            );
-
-my $mb = $class->new(
-    module_name    => 'GD::Thumbnail',
-    license        => 'perl',
-    requires       => {
-        'GD' => 0,
-    },
-    build_requires => {
-        'Test::More' => '0.40',
-    },
-    recommends     => {},
-    sign           => 0,
-    dist_author    => 'Burak Gursoy <burak@cpan.org>',
-    create_license => 1,
-    no_index       => {
-        directory => [
-            'tools',
-            't',
-        ]
-    },
-    meta_merge => {
-        resources => {
-            repository => 'http://bitbucket.org/burak/cpan-gd-thumbnail/',
-        },
-    },
-);
-
+my $mb = Build->new;
+$mb->change_versions(1);
 $mb->create_build_script;
-
-sub raw_subclass {
-    my $file = File::Spec->catfile( 'tools', 'Build.pm' );
-    my $FH   = IO::File->new;
-    $FH->open( $file, 'r' ) or die "Can not open($file): $!";
-    my $rv = do { local $/; <$FH> };
-    close $FH;
-    return $rv;
-}

META.yml

----
-name: GD-Thumbnail
-version: 1.10
-author:
-  - 'Burak Gursoy <burak@cpan.org>'
-abstract: Thumbnail maker for GD
-license: perl
-resources:
-  license: http://dev.perl.org/licenses/
-requires:
-  GD: 0
-provides:
-  GD::Thumbnail:
-    file: lib/GD/Thumbnail.pm
-    version: 1.10
-  GD::Thumbnail::Compat:
-    file: lib/GD/Thumbnail.pm
-generated_by: Module::Build version 0.2805
-meta-spec:
-  url: http://module-build.sourceforge.net/META-spec-v1.2.html
-  version: 1.2

Makefile.PL

-#!perl
-use ExtUtils::MakeMaker;
-
-WriteMakefile(
-   NAME         => 'GD::Thumbnail',
-   VERSION_FROM => 'lib/GD/Thumbnail.pm',
-   PREREQ_PM    => { 'GD' => 0, 'Test::More' => '0.40' },
-   ($] >= 5.005 ? (
-   AUTHOR       => 'Burak Gursoy <burak@cpan.org>',
-   ABSTRACT     => 'Thumbnail maker for GD',
-   ) : ()),
-   PL_FILES     => {},
-);
+{
+    module_name    => 'GD::Thumbnail',
+    requires       => {
+        'GD' => 0,
+    },
+    meta_merge => {
+        resources => {
+            repository => 'http://bitbucket.org/burak/cpan-gd-thumbnail/',
+        },
+    },
+}

t/1-pod.t

-#!/usr/bin/env perl -w
-use strict;
-use lib '..';
-use Test::More;
-
-my @errors;
-eval { require Test::Pod; };
-push @errors, "Test::Pod is required for testing POD"   if $@;
-eval { require Pod::Simple; };
-push @errors, "Pod::Simple is required for testing POD" if $@;
-
-if ( not @errors ) {
-   my $tpv = $Test::Pod::VERSION;
-   my $psv = $Pod::Simple::VERSION;
-
-   if ( $tpv < 1.26 ) {
-      push @errors, "Upgrade Test::Pod to 1.26 to run this test. "
-                   ."Detected version is: $tpv";
-   }
-
-   if ( $psv < 3.05 ) {
-      push @errors, "Upgrade Pod::Simple to 3.05 to run this test. "
-                   ."Detected version is: $psv";
-   }
-}
-
-if ( $] < 5.008 ) {
-   # Any older perl does not have Encode.pm. Thus, Pod::Simple
-   # can not handle utf8 encoding and it will die, the tests
-   # will fail. This skip part, skips an inevitable failure.
-   push @errors, "'=encoding utf8' directives in Pods don't work "
-                ."with legacy perl.";
-}
-
-if ( @errors ) {
-   plan skip_all => "Errors detected: @errors";
-}
-else {
-   Test::Pod::all_pod_files_ok();
-}

t/2-pod-coverage.t

-#!/usr/bin/env perl -w
-use strict;
-use Test::More;# qw(no_plan);
-
-eval "use Test::Pod::Coverage;1";
-if ( $@ ) {
-   plan skip_all => "Test::Pod::Coverage required for testing pod coverage";
-} else {
-   all_pod_coverage_ok();
-}

tools/Build.pm

-use strict;
-use vars qw( $VERSION );
-use warnings;
-use File::Find;
-use File::Spec;
-use File::Path;
-use constant RE_VERSION_LINE => qr{
-   \A \$VERSION \s+ = \s+ ["'] (.+?) ['"] ; (.+?) \z
-}xms;
-use constant RE_POD_LINE => qr{
-\A =head1 \s+ DESCRIPTION \s+ \z
-}xms;
-use constant VTEMP  => q{$VERSION = '%s';};
-use constant MONTHS => qw(
-   January February March     April   May      June
-   July    August   September October November December
-);
-
-$VERSION = '0.40';
-
-sub ACTION_dist {
-   my $self = shift;
-   warn  sprintf(
-            "RUNNING 'dist' Action from subclass %s v%s\n",
-            ref($self),
-            $VERSION
-         );
-   my @modules;
-   find {
-      wanted => sub {
-         my $file = $_;
-         return if $file !~ m{ \. pm \z }xms;
-         $file = File::Spec->catfile( $file );
-         push @modules, $file;
-         warn "FOUND Module: $file\n";
-      },
-      no_chdir => 1,
-   }, "lib";
-   $self->_change_versions( \@modules );
-   $self->SUPER::ACTION_dist( @_ );
-}
-
-sub _change_versions {
-   my $self  = shift;
-   my $files = shift;
-   my $dver  = $self->dist_version;
-
-   my($mday, $mon, $year) = (localtime time)[3, 4, 5];
-   my $date = join ' ', $mday, [MONTHS]->[$mon], $year + 1900;
-
-   warn "CHANGING VERSIONS\n";
-   warn "\tDISTRO Version: $dver\n";
-
-   foreach my $mod ( @{ $files } ) {
-      warn "\tPROCESSING $mod\n";
-      my $new = $mod . '.new';
-      open my $RO_FH, '<:raw', $mod or die "Can not open file($mod): $!";
-      open my $W_FH , '>:raw', $new or die "Can not open file($new): $!";
-
-      CHANGE_VERSION: while ( my $line = readline $RO_FH ) {
-         if ( $line =~ RE_VERSION_LINE ) {
-            my $oldv      = $1;
-            my $remainder = $2;
-            warn "\tCHANGED Version from $oldv to $dver\n";
-            printf $W_FH VTEMP . $remainder, $dver;
-            last CHANGE_VERSION;
-         }
-         print $W_FH $line;
-      }
-
-      my $ns  = $mod;
-         $ns  =~ s{ [\\/]     }{::}xmsg;
-         $ns  =~ s{ \A lib :: }{}xms;
-         $ns  =~ s{ \. pm \z  }{}xms;
-      my $pod = "\nThis document describes version C<$dver> of C<$ns>\n"
-              . "released on C<$date>.\n"
-              ;
-
-      if ( $dver =~ m{[_]}xms ) {
-         $pod .= "\nB<WARNING>: This version of the module is part of a\n"
-              .  "developer (beta) release of the distribution and it is\n"
-              .  "not suitable for production use.\n";
-      }
-
-      CHANGE_POD: while ( my $line = readline $RO_FH ) {
-         print $W_FH $line;
-         print $W_FH $pod if $line =~ RE_POD_LINE;
-      }
-
-      close $RO_FH or die "Can not close file($mod): $!";
-      close $W_FH  or die "Can not close file($new): $!";
-
-      unlink($mod) || die "Can not remove original module($mod): $!";
-      rename( $new, $mod ) || die "Can not rename( $new, $mod ): $!";
-      warn "\tRENAME Successful!\n";
-   }
-
-   return;
-}
-
-1;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.