File Coverage

blib/lib/Devel/PerlySense/Home.pm
Criterion Covered Total %
statement 55 56 98.2
branch 3 6 50.0
condition n/a
subroutine 17 17 100.0
pod 4 4 100.0
total 79 83 95.1


line stmt bran cond sub pod time code
1             =head1 NAME
2              
3             Devel::PerlySense::Home - A User Home root directory
4              
5              
6             =head1 DESCRIPTION
7              
8             The User Home is the place where User specific settings/cache,
9             etc. are kept.
10              
11             =cut
12              
13              
14              
15              
16              
17 69     69   614 use strict;
  69         80  
  69         1625  
18 69     69   204 use warnings;
  69         72  
  69         1353  
19 69     69   619 use utf8;
  69         81  
  69         237  
20              
21             package Devel::PerlySense::Home;
22             $Devel::PerlySense::Home::VERSION = '0.0217';
23              
24              
25 69     69   3776 use Spiffy -Base;
  69         11292  
  69         432  
26 69     69   42815 use Carp;
  69     69   83  
  69     69   1062  
  69         195  
  69         64  
  69         1392  
  69         184  
  69         68  
  69         2646  
27 69     69   217 use Data::Dumper;
  69         79  
  69         2009  
28 69     69   217 use File::Basename;
  69         77  
  69         2487  
29 69     69   234 use File::Path;
  69         77  
  69         2431  
30 69     69   563 use Path::Class;
  69         25395  
  69         2056  
31              
32 69     69   956 use Devel::PerlySense::Util;
  69         72  
  69         20015  
33              
34              
35              
36              
37              
38             =head1 PROPERTIES
39              
40             =head2 aDirHomeCandidate
41              
42             List of candidates for User Home root dirs.
43              
44             Readonly.
45              
46             =cut
47 5     5 1 1340 sub aDirHomeCandidate {
48             return(
49 35         38 grep { $_ } (
50             $ENV{APPDATA},
51             $ENV{ALLUSERSPROFILE},
52             $ENV{USERPROFILE},
53             $ENV{HOME},
54             $ENV{TEMP},
55             $ENV{TMP},
56 5         13 "/",
57             ),
58             );
59             }
60              
61              
62              
63              
64              
65             =head2 dirHome
66              
67             The User Home root dir, or "" if no home dir could be identified.
68              
69             Readonly.
70              
71             =cut
72 3     3 1 2 sub dirHome {
73              
74 3         6 for my $dirHome( $self->aDirHomeCandidate ) {
75 3         7 my $dir = dir($dirHome, ".PerlySense");
76 3         177 mkpath([$dir]);
77 3 50       19315 -d $dir and return $dir;
78             }
79              
80 0         0 return "";
81             }
82              
83              
84              
85              
86              
87             =head2 dirHomeCache
88              
89             The User Home cache dir, or "" if no home dir could be identified.
90              
91             Readonly.
92              
93             =cut
94 2     2   2 sub _dirSubHomeCreate {
95 2         2 my ($dirSub) = @_;
96              
97 2 50       4 my $dirHome = $self->dirHome or return "";
98 2         41 my $dir = dir($dirHome, $dirSub);
99 2         62 mkpath([$dir]);
100 2 50       272 -d $dir or return "";
101              
102 2         53 return $dir;
103             }
104 1     1 1 2 sub dirHomeCache {
105 1         2 $self->_dirSubHomeCreate("cache");
106             }
107              
108              
109              
110              
111              
112             =head2 dirHomeLog
113              
114             The User Home log dir, or "" if no home dir could be identified.
115              
116             Readonly.
117              
118             =cut
119 1     1 1 2 sub dirHomeLog {
120 1         2 $self->_dirSubHomeCreate("log");
121             }
122              
123              
124              
125              
126              
127             1;
128              
129              
130              
131              
132              
133             __END__
134              
135             =encoding utf8
136              
137             =head1 AUTHOR
138              
139             Johan Lindstrom, C<< <johanl@cpan.org> >>
140              
141             =head1 BUGS
142              
143             Please report any bugs or feature requests to
144             C<bug-devel-perlysense@rt.cpan.org>, or through the web interface at
145             L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Devel-PerlySense>.
146             I will be notified, and then you'll automatically be notified of progress on
147             your bug as I make changes.
148              
149             =head1 ACKNOWLEDGEMENTS
150              
151             =head1 COPYRIGHT & LICENSE
152              
153             Copyright 2005 Johan Lindstrom, All Rights Reserved.
154              
155             This program is free software; you can redistribute it and/or modify it
156             under the same terms as Perl itself.
157              
158             =cut