Net-API-CPAN
view release on metacpan or search on metacpan
build/build_modules.pl view on Meta::CPAN
my $mod_file = $mod_dir->child( $module_path );
$mod_file->parent->mkpath if( !$mod_file->parent->exists );
( my $actual_mod_path = $module_class ) =~ s,::,/,g;
my $actual_mod_file = $lib_dir->child( "${actual_mod_path}.pm" );
my $module_version = $modules_version;
say "\tChecking actual module $module_class file $actual_mod_file for version change.";
if( $actual_mod_file->exists )
{
say "\tModule file $actual_mod_file exists, trying to get its version number.";
# try-catch
local $@;
my $this_version = eval
{
no strict 'refs';
require( "$actual_mod_file" );
return( ${"${module_class}::VERSION"} );
};
if( $@ )
{
say "\tModule ${module_class} file $actual_mod_file has some error: $@";
}
else
{
say "\tModule $module_name is using version $this_version, using it instead of $modules_version" if( $this_version ne $modules_version );
$module_version = $this_version;
}
}
my $parent = "${base_class}::Generic";
my $parent_specs;
my $object_plural = ( substr( $object, -1, 1 ) eq 's' ? $object : $object . 's' );
# if( index( $module_name, '::' ) != -1 )
# {
# my @parts = split( /::/, $module_name );
# # Skip the last one that forms our module name and retain the rest that constitutes the parent directory(ie)
# my $this_name = pop( @parts );
# my $module_parent_dir = $mod_dir->child( join( '/', @parts ) );
# $module_parent_dir->mkpath if( !$module_parent_dir->exists );
# $mod_file = $module_parent_dir->child( "${this_name}.pm" );
# }
if( exists( $extends->{ $object } ) )
{
$parent_specs = $specs->{ $extends->{ $object } } ||
die( "There is no object '", $extends->{ $object }, "' to extends object '$object' in CPAN API specifications ($api_specs)." );
$parent = "${base_class}::" . join( '', map( ucfirst( lc( $_ ) ), split( /_/, $extends->{ $object } ) ) );
say "\tClass $object inherits from ", $extends->{ $object };
}
my $methods = $specs->{ $object };
my $all_methods = Module::Generic::Array->new( [keys( %$methods )] );
if( exists( $other_methods->{ $object } ) )
{
$all_methods->push( keys( %{$other_methods->{ $object }} ) );
}
if( scalar( keys( %$core_methods ) ) )
{
$all_methods->push( keys( %$core_methods ) );
}
my $sample_file = $base_dir->child( "$object.json" );
my $sample_data;
$sample_data = $sample_file->load_json( boolean_values => [\0, \1] ) if( $sample_file->exists );
my $synop = Module::Generic::Array->new;
if( defined( $sample_data ) )
{
my $args_string = &dump_this( $sample_data );
$synop->push( "my \$obj = ${base_class}::${module_name}->new( $args_string ) || die( ${base_class}::${module_name}->error );\n" );
}
my $lines = Module::Generic::Array->new;
my $pod = Module::Generic::Array->new;
my $code = <<EOT;
##----------------------------------------------------------------------------
## Meta CPAN API - ~/lib/Net/API/CPAN/${module_path}
## Version ${module_version}
## Copyright(c) ${year} DEGUEST Pte. Ltd.
## Author: Jacques Deguest <jack\@deguest.jp>
## Created $modules_created
## Modified $today
## All rights reserved
##
##
## This program is free software; you can redistribute it and/or modify it
## under the same terms as Perl itself.
##----------------------------------------------------------------------------
# This module file has been automatically generated. Any change made here will be lost.
# Edit the script in ./build/build_modules.pl instead
package ${module_class};
BEGIN
{
use strict;
use warnings;
use parent qw( ${parent} );
use vars qw( \$VERSION );
our \$VERSION = '${module_version}';
};
use strict;
use warnings;
sub init
{
my \$self = shift( \@_ );
EOT
my $test_file = $test_dir->child( sprintf( '%03d_%s.t', ++$test_num, $object ) );
my $test_content = <<EOT;
#!perl
# This test file has been automatically generated. Any change made here will be lost.
# Edit the script in ./build/build_modules.pl instead
BEGIN
{
use strict;
use warnings;
use lib './lib';
use vars qw( \$DEBUG );
use Test::More qw( no_plan );
use Module::Generic;
use Scalar::Util ();
our \$DEBUG = exists( \$ENV{AUTHOR_TESTING} ) ? \$ENV{AUTHOR_TESTING} : 0;
};
( run in 2.062 seconds using v1.01-cache-2.11-cpan-81fc1098f69 )