Module-OTRS-CoreList
view release on metacpan or search on metacpan
scripts/get_modules.pl view on Meta::CPAN
MODULE:
for my $module ( @modules ) {
next MODULE if $module =~ m{/scripts/};
my ($otrs,$modfile) = $module =~ m{ \A otrs-(\d+\.\d+\.\d+)/(.*) }xms;
next MODULE if !$modfile;
my $is_cpan = $modfile =~ m{cpan-lib}xms;
my $key = $is_cpan ? 'cpan' : 'core';
next MODULE if !$modfile;
(my $modulename = $modfile) =~ s{/}{::}g;
next MODULE if !$modulename;
$modulename =~ s{\.pm}{}g;
$modulename =~ s{Kernel::cpan-lib::}{}g if $is_cpan;
$version = $otrs;
next MODULE if !$otrs;
next MODULE if !$modulename;
$insert_sth->execute( $modulename, $otrs, $key );
}
}
my $versions_sth = $dbh->prepare( 'SELECT COUNT( DISTINCT otrs ) FROM modules' );
$versions_sth->execute;
my $versions_count;
while (my $count = $versions_sth->fetchrow_array ) {
$versions_count = $count;
}
print STDERR "# Versions: $versions_count\n";
my %global;
my $global_sth = $dbh->prepare( 'SELECT modname, modtype, COUNT(otrs) AS versions FROM modules GROUP BY modname HAVING versions = ' . $versions_count ) or die $dbh->errstr;
$global_sth->execute( ) or die $dbh->errstr;
while ( my ($name,$type,$count) = $global_sth->fetchrow_array ) {
$global{$type}->{$name} = 1;
}
my %hash;
my $local_sth = $dbh->prepare( 'SELECT modname, modtype, otrs FROM modules' );
$local_sth->execute;
while ( my ($name,$type,$otrs) = $local_sth->fetchrow_array ) {
next if $global{$type}->{$name};
$hash{$otrs}->{$type}->{$name} = 1;
}
$Data::Dumper::Sortkeys = 1;
my $dist_ini_content = do{ local (@ARGV,$/) = File::Spec->catfile( dirname( __FILE__ ), '..', 'dist.ini' ); <> };
my ($dist_version) = $dist_ini_content =~ m{version \s* = \s* (.*?)\n}xms;
my ($dist_author) = $dist_ini_content =~ m{author \s* = \s* (.*?)\n}xms;
my ($dist_license) = $dist_ini_content =~ m{license \s* = \s* (.*?)\n}xms;
my ($dist_c_holder) = $dist_ini_content =~ m{copyright_holder \s* = \s* (.*?)\n}xms;
my ($dist_c_year) = $dist_ini_content =~ m{copyright_year \s* = \s* (.*?)\n}xms;
my $license_class = 'Software::License::' . $dist_license;
eval "require $license_class;";
my $license_obj = $license_class->new({ holder => $dist_c_holder, year => $dist_c_year });
my $dist_copyright = $license_obj->notice;
if ( open my $fh, '>', 'corelist' ) {
print $fh q~package Module::OTRS::CoreList;
# ABSTRACT: what modules shipped with versions of OTRS (>= 2.3.x)
use strict;
use warnings;
~;
print $fh "\n\n";
print $fh "our \$VERSION = $dist_version;\n\n";
$Data::Dumper::Indent = 0;
my $global_dump = Data::Dumper->Dump( [\%global], ['global'] );
$global_dump =~ s{\$global}{my \$global};
print $fh $global_dump;
print $fh "\n";
my $modules_dump = Data::Dumper->Dump( [\%hash], ['modules'] );
$modules_dump =~ s{\$modules}{my \$modules};
print $fh $modules_dump;
print $fh "\n\n";
print $fh q#sub shipped {
my ($class,$version,$module) = @_;
return if !$version;
return if $version !~ m{ \A [0-9]+\.[0-9]\.(?:[0-9]+|x) \z }xms;
$version =~ s{\.}{\.}g;
$version =~ s{x}{.*};
my $version_re = qr{ \A $version \z }xms;
my @versions_with_module;
OTRSVERSION:
for my $otrs_version ( sort keys %{$modules} ) {
next unless $otrs_version =~ $version_re;
if ( $modules->{$otrs_version}->{core}->{$module} ||
$modules->{$otrs_version}->{cpan}->{$module} ||
( run in 0.757 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )