File Coverage

blib/lib/Dist/Metadata/Struct.pm
Criterion Covered Total %
statement 23 23 100.0
branch 4 4 100.0
condition n/a
subroutine 8 8 100.0
pod 4 4 100.0
total 39 39 100.0


line stmt bran cond sub pod time code
1             # vim: set ts=2 sts=2 sw=2 expandtab smarttab:
2             #
3             # This file is part of Dist-Metadata
4             #
5             # This software is copyright (c) 2011 by Randy Stauner.
6             #
7             # This is free software; you can redistribute it and/or modify it under
8             # the same terms as the Perl 5 programming language system itself.
9             #
10 7     7   2006 use strict;
  7         11  
  7         302  
11 7     7   31 use warnings;
  7         11  
  7         533  
12              
13             package Dist::Metadata::Struct;
14             our $AUTHORITY = 'cpan:RWSTAUNER';
15             # ABSTRACT: Enable Dist::Metadata for a data structure
16             $Dist::Metadata::Struct::VERSION = '0.926';
17 7     7   32 use Carp qw(croak carp); # core
  7         9  
  7         480  
18 7     7   1637 use parent 'Dist::Metadata::Dist';
  7         1135  
  7         44  
19              
20             push(@Dist::Metadata::CARP_NOT, __PACKAGE__);
21              
22              
23 48     48 1 120 sub required_attribute { 'files' }
24              
25              
26 17     17 1 271 sub default_file_spec { 'Unix' }
27              
28              
29             sub file_content {
30 51     51 1 679 my ($self, $file) = @_;
31             # TODO: should we croak if not found? would be consistent with Dir
32 51         262 my $content = $self->{files}{ $self->full_path($file) };
33              
34             # 5.10: given(ref($content))
35              
36 51 100       3927 if( my $ref = ref $content ){
37 3         7 local $/; # do this here because of perl bug prior to perl 5.15 (7c2d9d0)
38 3 100       29 return $ref eq 'SCALAR'
39             # allow a scalar ref
40             ? $$content
41             # or an IO-like object
42             : $content->getline;
43             }
44             # else a simple string
45 48         430 return $content;
46             }
47              
48              
49             sub find_files {
50 32     32 1 43 my ($self) = @_;
51              
52 32         32 return keys %{ $self->{files} };
  32         250  
53             }
54              
55             1;
56              
57             __END__