File Coverage

blib/lib/Banal/Dist/Util/Pause.pm
Criterion Covered Total %
statement 17 27 62.9
branch 0 6 0.0
condition n/a
subroutine 6 7 85.7
pod 0 1 0.0
total 23 41 56.1


line stmt bran cond sub pod time code
1 1     1   408867 use 5.014; # because we use the 'state' and 'non-destructive substitution' feature (s///r)
  1         17  
2 1     1   14 use strict;
  1         3  
  1         74  
3 1     1   15 use warnings;
  1         10  
  1         188  
4              
5             package Banal::Dist::Util::Pause;
6             # vim: set ts=2 sts=2 sw=2 tw=115 et :
7             # ABSTRACT: General purpose utility collection for
8             # KEYWORDS: author utility
9              
10             our $VERSION = '0.005';
11             # AUTHORITY
12              
13 1     1   831 use Path::Tiny;
  1         12360  
  1         94  
14 1     1   460 use namespace::autoclean;
  1         17807  
  1         5  
15              
16 1         6 use Exporter::Shiny qw(
17             pause_config
18 1     1   491 );
  1         4082  
19              
20             # return username, password from ~/.pause
21             sub pause_config
22             {
23             # my $home = $ENV{HOME};
24             # return unless defined $home;
25             # my $file = path($home, '.pause')->realpath;
26             # # my $file = path('~/.pause')->realpath;
27             # return unless $file->exists();
28              
29 0     0 0   my %r;
30             FILE:
31 0           foreach my $fname (qw(~/.pause ~/.pause.conf)) {
32 0           my $file = path($fname)->realpath;
33 0 0         next FILE unless $file->exists;
34             LINE:
35 0           foreach ( $file->lines(chomp=>1) ) {
36             KEY:
37 0           foreach my $key (qw(user password)) {
38 0 0         m/^\s*${key}\s*(\s|[=])\s*(\S+)/ and do { $r{$key} = $1; next };
  0            
  0            
39             }
40             }
41             }
42              
43 0 0         wantarray ? (%r) : \%r;
44             }
45              
46              
47              
48             1;
49              
50             __END__