File Coverage

blib/lib/Win32/IEFavorites/Item.pm
Criterion Covered Total %
statement 10 12 83.3
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 14 16 87.5


line stmt bran cond sub pod time code
1             package Win32::IEFavorites::Item;
2              
3 1     1   4377 use strict;
  1         2  
  1         37  
4 1     1   6 use warnings;
  1         2  
  1         45  
5              
6             our $VERSION = '0.06';
7              
8 1     1   1344 use Config::IniFiles;
  1         237127  
  1         39  
9 1     1   691 use Win32::IEFavorites::DateTime;
  0            
  0            
10              
11             sub new {
12             my ($class, $path) = @_;
13              
14             bless {
15             path => $path,
16             cached => 0,
17             datetime => undef,
18             }, $class;
19             }
20              
21             sub _value {
22             my ($self, $type) = @_;
23             $self->_load unless $self->{cached};
24              
25             $self->{$type};
26             }
27              
28             sub _load {
29             my $self = shift;
30             my $ini = Config::IniFiles->new( -file => $self->{path} );
31             foreach my $type (qw/URL Modified IconFile IconIndex/) {
32             if (defined $ini) {
33             $self->{lc($type)} = $ini->val('InternetShortcut',$type) || '';
34             } else {
35             $self->{lc($type)} = '';
36             }
37             }
38             $self->{cached} = 1;
39             }
40              
41             sub path { $_[0]->{path}; }
42             sub url { $_[0]->_value('url'); }
43             sub iconfile { $_[0]->_value('iconfile'); }
44             sub iconindex { $_[0]->_value('iconindex'); }
45              
46             sub modified {
47             my $self = shift;
48             unless ($self->{datetime}) {
49             my $modified = $self->_value('modified');
50             $self->{datetime} = Win32::IEFavorites::DateTime->new($modified);
51             }
52             $self->{datetime};
53             }
54              
55             1;
56             __END__