NAME

Nephia::Setup - Base class of setup tool

DESCRIPTION

This class is used in setup tool internally.

SYNOPSIS

my $setup = Nephia::Setup->new(
    appname => 'YourApp::Web',
    plugins => ['Normal'],
);
$setup->do_task;

ATTRIBUTES

appname

Application name. This attribute is required when instantiate.

approot

Application root directory. Default is "./Appname".

plugins

Plugins for using when setup. Default is [] .

deps

Dependencies for application as hashref. Default is following.

{
    requires => ['Nephia' => 0],
    test => {
        requires => ['Test::More' => 0],
    },
};

METHODS

appname

Returns application name.

approot

Returns application root as array.

deps

Returns dependencies as hashref.

classfile

Returns path for classfile as array.

Example.

my $setup = Nephia::Setup->new(appname => 'MyApp::Web');
my @path = $setup->classfile; # ( 'lib', 'MyApp', 'Web.pm' );

action_chain

Returns action chain as Nephia::Chain object.

meta_tmpl

Returns Nephia::MetaTemplate object.

makepath

Create specified directory recursively.

Example.

my $setup = Nephia::Setup->new(
    appname => 'MyApp::Web'
);
$setup->makepath('misc', 'data', 'xml'); # create ./MyApp-Web/misc/data/xml

spew

Create specified file with specified content.

Example.

my $xmldata = ...; # read some xml data...
$setup->spew('misc', 'data', 'xml', 'foo.xml', $xmldata); # create ./MyApp-Web/misc/data/xml/foo.xml

process_template

Process file-template.

Example.

my $setup     = Nephia::Setup->new(appname => 'MyApp::Web');
my $str       = 'Application name is "{{$self->appname}}"';
my $processed = $setup->process_template($str); # 'Application name is "MyApp::Web"'

do_task

Run actions in action chain.

diag

Output some message to STDERR.

stop

Output some message to STDERR and exit setup.

cpanfile

Output cpanfile script.

Example.

my $cpanfile_data = $setup->cpanfile;

assets

Download a file from url and save to specified file.

Example.

# download somefile-0.1.2.js as ./MyApp-Web/static/js/somefile.js
$setup->assets(
    'http://example.com/files/somefile-0.1.2.js', 
    qw/static js somefile.js/
); 

assets_archive

Download an archive-file from url and extract into specified path.

Example.

# download somearch-0.1.2.tar.gz and extract into ./MyApp-Web/static/foo/
$setup->assets_archive(
    'ftp://example.com/files/somearch-0.1.2.tar.gz',
    qw/static foo/
);

extract_archive

Extract an archive-file into specified path.

Example.

# extract ./somearch-0.1.2.tar.gz into ./MyApp-Web/static/foo/
$setup->extract_archive(
    './somearch-0.1.2.tar.gz',
    qw/static foo/
);

AUTHOR

ytnobody <ytnobody@gmail.com>