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   1535 use strict;
  6         9  
  6         230  
4 6     6   23 use warnings;
  6         7  
  6         1909  
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 80446 my $pkg = shift;
17              
18 36         190 $feature = {
19             force => undef,
20             make_test => undef,
21             deploy => undef,
22             current => undef,
23             @_,
24             };
25              
26 36 100       244 $pkg->set_deploy_mode( $feature->{deploy} ) if $feature->{deploy};
27             }
28              
29             sub set_deploy_mode {
30 7     7 0 690 my $pkg = shift;
31 7         12 my $path = shift;
32              
33 7         21 $pkg->_validate_deploy_path( $path );
34              
35 6         15 $feature->{deploy} = $path;
36             }
37              
38             sub _validate_deploy_path {
39 7     7   16 my $pkg = shift;
40 7         16 my $deploy_path = shift;
41            
42 7 100       59 if ( ! -d $deploy_path ) {
43 1         5 my $err = "'$deploy_path' is nonexistent directory.";
44 1         6 Enbld::Error->throw( $err );
45             }
46              
47 6 50       119 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         84 return $deploy_path;
53             }
54              
55             sub is_deploy_mode {
56 90     90 0 453 return $feature->{deploy};
57             }
58              
59             sub deploy_path {
60 6     6 0 24 return $feature->{deploy};
61             }
62              
63             sub is_force_install {
64 29     29 0 140 return $feature->{force};
65             }
66              
67             sub is_make_test_all {
68 29     29 0 259 return $feature->{make_test};
69             }
70              
71             sub is_current_mode {
72 4     4 0 17 return $feature->{current};
73             }
74              
75             sub reset {
76              
77 32     32 0 581 $feature = {
78             force => undef,
79             make_test => undef,
80             deploy => undef,
81             current => undef,
82             };
83              
84             }
85              
86             1;