Crane
view release on metacpan or search on metacpan
lib/Crane.pm view on Meta::CPAN
# -*- coding: utf-8 -*-
package Crane;
use Crane::Base;
use Crane::Config;
use Crane::Options qw( :opts options );
use File::Basename qw( basename dirname );
use File::Find qw( find );
use File::Spec::Functions qw( catdir splitdir );
our $VERSION = '1.03.0011';
sub get_package_path {
my ( $package ) = @_;
my @path = split m{::}si, $package;
$path[-1] .= '.pm';
return catdir(@path);
}
sub create_package_alias {
my ( $original, $alias ) = @_;
eval qq{
package $alias;
use $original;
1;
} or do {
confess($EVAL_ERROR);
};
# Tell to Perl that module is read
$INC{ get_package_path($alias) } = $INC{ get_package_path($original) };
{
no strict 'refs';
# Create alias
*{ "${alias}::" } = \*{ "${original}::" };
}
return;
}
sub import {
my ( undef, %params ) = @_;
my $caller = caller;
Crane::Base->import(ref $params{'base'} eq 'ARRAY' ? @{ $params{'base'} } : ());
Crane::Base->export_to_level(1, $caller);
{
no strict 'refs';
push @{ "${caller}::ISA" }, @{ __PACKAGE__ . '::ISA' };
}
# Predefined options
my @options = (
[ 'daemon|M!', 'Run as daemon.', { 'default' => $params{'name'} ? 1 : 0 } ],
$OPT_SEPARATOR,
[ 'config|C=s', 'Path to configuration file.' ],
[ 'pid|P=s', 'Path to PID file.' ],
$OPT_SEPARATOR,
[ 'log|O=s', 'Path to log file.' ],
[ 'log-error|E=s', 'Path to error log file.' ],
$OPT_SEPARATOR,
( run in 0.481 second using v1.01-cache-2.11-cpan-71847e10f99 )