App-Pm2Port
view release on metacpan or search on metacpan
lib/App/Pm2Port.pm view on Meta::CPAN
package App::Pm2Port;
#===============================================================================
#
# FILE: portupload.pl
#
# USAGE: ./portupload.pl
#
# DESCRIPTION: upload
#
# OPTIONS: ---
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: ---
# AUTHOR: Andrey Kostenko (), <andrey@kostenko.name>
# COMPANY: Rambler Internet Holding
# VERSION: 1.0
# CREATED: 26.06.2009 02:13:30 MSD
# REVISION: ---
#===============================================================================
$ENV{LC_ALL} = 'C';
our $VERSION=0.29;
use 5.010;
use strict;
use warnings;
use ExtUtils::MakeMaker();
use Net::FTP;
use Getopt::Long;
use File::Temp qw(tempdir);
use YAML qw(Dump LoadFile DumpFile);
use JSON::XS;
use version;
use File::Basename qw(dirname);
use CPAN;
use CPANPLUS::Backend;
use Config;
use FreeBSD::Ports::INDEXhash qw/INDEXhash/;
=head2 new
=cut
sub new {
my $class = shift;
my %params = @_;
$params{INDEX} = { INDEXhash() };
$params{cpan} = CPANPLUS::Backend->new;
bless {%params}, $class;
}
=head2 prompt
Asks something
=cut
sub prompt {
my ( $text, $default ) = @_;
require Term::ReadLine;
state $term = Term::ReadLine->new('perl2port');
$term->readline( $text, $default );
}
=head2 perl_version_parse
Args: $version
Converts perl version number to something understandable by FreeBSD
=cut
sub perl_version_parse {
my ( $self, $version ) = @_;
my $b = 0;
return join '.', map { int $_ }
grep { defined }
( $version =~ /^(\d+)\.(\d{1,3})(?:\.(\d{1,3})|(\d{3}))?$/ );
}
=head2 get_dependencies
Returns FreeBSD-style list of dependencies.
=cut
sub get_dependencies {
my $self = shift;
my $requires = shift;
my $ports = shift;
return '' unless $requires;
my @deps;
lib/App/Pm2Port.pm view on Meta::CPAN
return $man1, $man3, @plist, reverse sort keys %dlist;
}
sub _get_dlist {
my $self = shift;
my $file = shift;
my $root = shift;
my @dlist;
do {
$file = dirname($file);
die "Can't get directory list for $file from $root" if $file eq '.';
push @dlist, '@dirrmtry ' . $file . "\n";
} while ( $file ne $root );
pop @dlist;
return @dlist;
}
=head2 suggest_category
Tries to find category for module name.
=cut
sub suggest_category {
my $self = shift;
my $module = shift;
my ($root) = split /-/, $module;
my $categories = shift;
if ($categories) {
return grep !/^perl$/, @$categories;
}
given ($root) {
when (/^DBI(x)?|DBD$/) {
return 'databases';
}
when (/^Catalyst|HTML|WWW$/) {
return 'www';
}
when (/^Net$/) {
return 'net';
}
when (/^CSS$/) {
return 'textproc';
}
}
return undef, 'devel';
}
=head2 load_meta
Loads META.yml or META.json
=cut
sub load_meta {
my $self = shift;
if ( -e 'META.json' ) {
open +( my $f ), '<', 'META.json' or die $!;
local $/ = undef;
local $\ = undef;
return JSON::XS::decode_json(<$f>);
}
else {
return LoadFile('META.yml');
}
}
1;
__END__
=head1 NAME
App::Pm2Port - Creates FreeBSD port from Perl module
=head1 SYNOPSYS
cd port-directory
pm2port Variable::Eject
=head1 LICENSE
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
=head1 AUTHOR
Andrey Kostenko E<lt>andrey@kostenko.nameE<gt>
=cut
( run in 2.080 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )