| 1 | package App::Standby::Cmd::Command; | ||
| 2 | 4 | $App::Standby::Cmd::Command::VERSION = '0.04'; | |
| 3 | 4 | ▶ | BEGIN { |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 4 | $App::Standby::Cmd::Command::AUTHORITY = 'cpan:TEX'; | |
| 5 | } | ||
| 6 | # ABSTRACT: Base class for any command | ||
| 7 | |||
| 8 | 4 | ▶ | use 5.010_000; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 4 | ▶ | use mro 'c3'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | 4 | ▶ | use feature ':5.10'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | |||
| 12 | 4 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | 4 | ▶ | use namespace::autoclean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 14 | |||
| 15 | # use IO::Handle; | ||
| 16 | # use autodie; | ||
| 17 | # use MooseX::Params::Validate; | ||
| 18 | # use Carp; | ||
| 19 | # use English qw( -no_match_vars ); | ||
| 20 | # use Try::Tiny; | ||
| 21 | 4 | ▶ | use DBI; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 22 | 4 | ▶ | use Config::Yak; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 23 | 4 | ▶ | use Log::Tree; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 24 | 4 | ▶ | use App::Standby::DB; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 25 | |||
| 26 | # extends ... | ||
| 27 | 4 | extends 'MooseX::App::Cmd::Command'; | |
| 28 | # has ... | ||
| 29 | 4 | has '_config' => ( | |
| 30 | 'is' => 'rw', | ||
| 31 | 'isa' => 'Config::Yak', | ||
| 32 | 'lazy' => 1, | ||
| 33 | 'builder' => '_init_config', | ||
| 34 | 'accessor' => 'config', | ||
| 35 | ); | ||
| 36 | |||
| 37 | 4 | has '_logger' => ( | |
| 38 | 'is' => 'rw', | ||
| 39 | 'isa' => 'Log::Tree', | ||
| 40 | 'lazy' => 1, | ||
| 41 | 'builder' => '_init_logger', | ||
| 42 | 'accessor' => 'logger', | ||
| 43 | ); | ||
| 44 | |||
| 45 | 4 | has '_dbh' => ( | |
| 46 | 'is' => 'rw', | ||
| 47 | 'isa' => 'App::Standby::DB', | ||
| 48 | 'lazy' => 1, | ||
| 49 | 'builder' => '_init_dbh', | ||
| 50 | 'accessor' => 'dbh', | ||
| 51 | ); | ||
| 52 | # with ... | ||
| 53 | # initializers ... | ||
| 54 | 2 | ▶ | sub _init_dbh { |
|
Subroutine
_init_dbh: called CC=1 SCAR=0.0
| |||
| 55 | 2 | my $self = shift; | |
| 56 | |||
| 57 | 2 | my $DBH = App::Standby::DB::->new({ | |
| 58 | 'config' => $self->config(), | ||
| 59 | 'logger' => $self->logger(), | ||
| 60 | }); | ||
| 61 | |||
| 62 | 2 | return $DBH; | |
| 63 | } | ||
| 64 | |||
| 65 | 0 | ▶ | sub _init_config { |
|
Subroutine
_init_config: not called CC=1 SCAR=6.9
| |||
| 66 | 0 | my $self = shift; | |
| 67 | |||
| 68 | 0 | my $Config = Config::Yak::->new({ | |
| 69 | 'locations' => [qw(conf/standby-mgm.conf /etc/standby-mgm)], | ||
| 70 | }); | ||
| 71 | |||
| 72 | 0 | return $Config; | |
| 73 | } | ||
| 74 | |||
| 75 | 0 | ▶ | sub _init_logger { |
|
Subroutine
_init_logger: not called CC=1 SCAR=6.9
| |||
| 76 | 0 | my $self = shift; | |
| 77 | |||
| 78 | 0 | my $Logger = Log::Tree::->new('standby'); | |
| 79 | |||
| 80 | 0 | return $Logger; | |
| 81 | } | ||
| 82 | |||
| 83 | # your code here ... | ||
| 84 | |||
| 85 | 4 | ▶ | no Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 86 | 4 | __PACKAGE__->meta->make_immutable; | |
| 87 | |||
| 88 | 4 | 1; | |
| 89 | |||
| 90 | __END__ | ||
| 91 | |||
| 92 | =pod | ||
| 93 | |||
| 94 | =encoding utf-8 | ||
| 95 | |||
| 96 | =head1 NAME | ||
| 97 | |||
| 98 | App::Standby::Cmd::Command - Base class for any command | ||
| 99 | |||
| 100 | =head1 NAME | ||
| 101 | |||
| 102 | App::Standby::Cmd::Command - Base class for any command | ||
| 103 | |||
| 104 | =head1 AUTHOR | ||
| 105 | |||
| 106 | Dominik Schulz <dominik.schulz@gauner.org> | ||
| 107 | |||
| 108 | =head1 COPYRIGHT AND LICENSE | ||
| 109 | |||
| 110 | This software is copyright (c) 2012 by Dominik Schulz. | ||
| 111 | |||
| 112 | This is free software; you can redistribute it and/or modify it under | ||
| 113 | the same terms as the Perl 5 programming language system itself. | ||
| 114 | |||
| 115 | =cut | ||