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   1267 use strict;
  6         7  
  6         162  
4 6     6   20 use warnings;
  6         6  
  6         1800  
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 92631 my $pkg = shift;
17              
18 36         138 $feature = {
19             force => undef,
20             make_test => undef,
21             deploy => undef,
22             current => undef,
23             @_,
24             };
25              
26 36 100       184 $pkg->set_deploy_mode( $feature->{deploy} ) if $feature->{deploy};
27             }
28              
29             sub set_deploy_mode {
30 7     7 0 583 my $pkg = shift;
31 7         10 my $path = shift;
32              
33 7         23 $pkg->_validate_deploy_path( $path );
34              
35 6         19 $feature->{deploy} = $path;
36             }
37              
38             sub _validate_deploy_path {
39 7     7   10 my $pkg = shift;
40 7         11 my $deploy_path = shift;
41            
42 7 100       54 if ( ! -d $deploy_path ) {
43 1         3 my $err = "'$deploy_path' is nonexistent directory.";
44 1         5 die( Enbld::Error->new( $err ));
45             }
46              
47 6 50       109 if ( ! -w $deploy_path ) {
48 0         0 my $err = "no permission to write directory:$deploy_path";
49 0         0 die( Enbld::Error->new( $err ));
50             }
51              
52 6         70 return $deploy_path;
53             }
54              
55             sub is_deploy_mode {
56 90     90 0 357 return $feature->{deploy};
57             }
58              
59             sub deploy_path {
60 6     6 0 17 return $feature->{deploy};
61             }
62              
63             sub is_force_install {
64 29     29 0 122 return $feature->{force};
65             }
66              
67             sub is_make_test_all {
68 29     29 0 275 return $feature->{make_test};
69             }
70              
71             sub is_current_mode {
72 5     5 0 17 return $feature->{current};
73             }
74              
75             sub reset {
76              
77 32     32 0 515 $feature = {
78             force => undef,
79             make_test => undef,
80             deploy => undef,
81             current => undef,
82             };
83              
84             }
85              
86             1;