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   1627 use strict;
  7         10  
  7         198  
11 7     7   28 use warnings;
  7         8  
  7         407  
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.927';
17 7     7   26 use Carp qw(croak carp); # core
  7         10  
  7         427  
18 7     7   1428 use parent 'Dist::Metadata::Dist';
  7         827  
  7         44  
19              
20             push(@Dist::Metadata::CARP_NOT, __PACKAGE__);
21              
22              
23 48     48 1 99 sub required_attribute { 'files' }
24              
25              
26 17     17 1 357 sub default_file_spec { 'Unix' }
27              
28              
29             sub file_content {
30 51     51 1 1051 my ($self, $file) = @_;
31             # TODO: should we croak if not found? would be consistent with Dir
32 51         213 my $content = $self->{files}{ $self->full_path($file) };
33              
34             # 5.10: given(ref($content))
35              
36 51 100       2948 if( my $ref = ref $content ){
37 3         8 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         275 return $content;
46             }
47              
48              
49             sub find_files {
50 32     32 1 40 my ($self) = @_;
51              
52 32         31 return keys %{ $self->{files} };
  32         219  
53             }
54              
55             1;
56              
57             __END__