File Coverage

blib/lib/Enbld/Feature.pm
Criterion Covered Total %
statement 26 28 92.8
branch 5 6 83.3
condition n/a
subroutine 11 11 100.0
pod 0 8 0.0
total 42 53 79.2


line stmt bran cond sub pod time code
1             package Enbld::Feature;
2              
3 6     6   2931 use strict;
  6         10  
  6         207  
4 6     6   31 use warnings;
  6         12  
  6         2917  
5              
6             require Enbld::Error;
7              
8             our $feature = {
9             force => undef,
10             make_test => undef,
11             deploy => undef,
12             current => undef,
13             };
14              
15             sub initialize {
16 36     36 0 115665 my $pkg = shift;
17              
18 36         243 $feature = {
19             force => undef,
20             make_test => undef,
21             deploy => undef,
22             current => undef,
23             @_,
24             };
25              
26 36 100       306 $pkg->set_deploy_mode( $feature->{deploy} ) if $feature->{deploy};
27             }
28              
29             sub set_deploy_mode {
30 7     7 0 910 my $pkg = shift;
31 7         21 my $path = shift;
32              
33 7         38 $pkg->_validate_deploy_path( $path );
34              
35 6         91 $feature->{deploy} = $path;
36             }
37              
38             sub _validate_deploy_path {
39 7     7   19 my $pkg = shift;
40 7         21 my $deploy_path = shift;
41            
42 7 100       84 if ( ! -d $deploy_path ) {
43 1         3 my $err = "'$deploy_path' is nonexistent directory.";
44 1         7 Enbld::Error->throw( $err );
45             }
46              
47 6 50       180 if ( ! -w $deploy_path ) {
48 0         0 my $err = "no permission to write directory:$deploy_path";
49 0         0 Enbld::Error->throw( $err );
50             }
51              
52 6         184 return $deploy_path;
53             }
54              
55             sub is_deploy_mode {
56 90     90 0 509 return $feature->{deploy};
57             }
58              
59             sub deploy_path {
60 6     6 0 29 return $feature->{deploy};
61             }
62              
63             sub is_force_install {
64 29     29 0 163 return $feature->{force};
65             }
66              
67             sub is_make_test_all {
68 29     29 0 370 return $feature->{make_test};
69             }
70              
71             sub is_current_mode {
72 4     4 0 21 return $feature->{current};
73             }
74              
75             sub reset {
76              
77 32     32 0 771 $feature = {
78             force => undef,
79             make_test => undef,
80             deploy => undef,
81             current => undef,
82             };
83              
84             }
85              
86             1;