HiD/App/Command.pm

filter: Statementstmt 93.4% 43 / 46 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 91.6% 11 / 12 Podpod 100% 1 / 1 totaltotal 92.0% 58 / 63 CC 3 SCAR 4.2
CC
3
Cov
92%
execute
3.1
_build_hid
2.0
BEGIN
1.0
CRAP 1.5
« HiD/Role/IsPublished.pm ↑ Summary HiD/Processor/Handlebars.pm »
1 # ABSTRACT: Base class for HiD commands
2  
3  
4 package HiD::App::Command;
5 4 $HiD::App::Command::VERSION = '1.5';
6 4 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 extends 'MooseX::App::Cmd::Command';
8 4 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 4 ▶use 5.014;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 4 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 4 ▶use autodie;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 4 ▶use warnings qw/ FATAL utf8 /;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 4 ▶use open qw/ :std :utf8 /;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 4 ▶use charnames qw/ :full /;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 4 ▶use feature qw/ unicode_strings /;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 4 ▶use HiD;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20  
21 4 has config_file => (
22 is => 'ro' ,
23 isa => 'Str' ,
24 cmd_aliases => 'f' ,
25 traits => [ qw/ Getopt / ] ,
26 default => '_config.yml' ,
27 );
28  
29 4 has hid => (
30 is => 'ro' ,
31 isa => 'HiD' ,
32 traits => [ qw/ NoGetopt/ ] ,
33 init_arg => undef ,
34 writer => '_set_hid' ,
35 handles => [
36 'all_objects' ,
37 'config' ,
38 'destination' ,
39 'publish' ,
40 ] ,
41 );
42  
43 0 ▶sub _build_hid { return HiD->new }
Subroutine _build_hid: not called CC=1 SCAR=6.9
44  
45 sub execute {
46 24 ▶ my( $self , $opts , $args ) = @_;
Subroutine execute: called CC=3 SCAR=11.3
Pod documented
47  
48 24 ▶ if ( $opts->{help_flag} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{"help_flag"}) 0 24 24
49 0 print $self->usage->text;
50 0 exit;
51 }
52  
53 24 my $hid_config = { cli_opts => $opts };
54 24 ▶ if ( $self->isa( 'HiD::App::Command::init')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->isa('HiD::App::Command::init')) { } 4 20 24
55 $hid_config->{config} = {},
56 4 }
57 else {
58 20 $hid_config->{config_file} = $self->config_file
59 }
60  
61 24 $self->_set_hid( HiD->new($hid_config) );
62  
63 24 $self->_run( $opts , $args );
64 }
65  
66 4 __PACKAGE__->meta->make_immutable;
67 4 1;
68  
69 __END__
70  
71 =pod
72  
73 =encoding utf-8
74  
75 =head1 NAME
76  
77 HiD::App::Command - Base class for HiD commands
78  
79 =head1 SYNOPSIS
80  
81 package HiD::App::Command::my_awesome_command;
82 use Moose;
83 extends 'HiD::App::Command';
84  
85 sub _run {
86 my( $self , $opts , $args ) = @_;
87  
88 # do whatcha like
89 }
90  
91 1;
92  
93 =head1 DESCRIPTION
94  
95 Base class for implementing subcommands for L<hid>. Provides basic attributes
96 like C<--config_file>. If you're going to write a sub-command, you want to
97 base it on this class.
98  
99 =head1 ATTRIBUTES
100  
101 =head2 config_file
102  
103 Path to config file.
104  
105 Defaults to './_config.yml'
106  
107 =head1 VERSION
108  
109 version 1.5
110  
111 =head1 AUTHOR
112  
113 John SJ Anderson <genehack@genehack.org>
114  
115 =head1 COPYRIGHT AND LICENSE
116  
117 This software is copyright (c) 2014 by John SJ Anderson.
118  
119 This is free software; you can redistribute it and/or modify it under
120 the same terms as the Perl 5 programming language system itself.
121  
122 =cut
« HiD/Role/IsPublished.pm ↑ Summary HiD/Processor/Handlebars.pm »