| 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 | 8 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 8 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | package Dist::Metadata::Struct; | ||||||||||
| 14 | 8 | our $AUTHORITY = 'cpan:RWSTAUNER'; | |||||||||
| 15 | # ABSTRACT: Enable Dist::Metadata for a data structure | ||||||||||
| 16 | 8 | $Dist::Metadata::Struct::VERSION = '0.927'; | |||||||||
| 17 | 8 | ▶ | use Carp qw(croak carp); # core | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | 8 | ▶ | use parent 'Dist::Metadata::Dist'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | |||||||||||
| 20 | 8 | push(@Dist::Metadata::CARP_NOT, __PACKAGE__); | |||||||||
| 21 | |||||||||||
| 22 | |||||||||||
| 23 | 48 | ▶ | sub required_attribute { 'files' } | ||||||||
|
Subroutine
required_attribute: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 24 | |||||||||||
| 25 | |||||||||||
| 26 | 17 | ▶ | sub default_file_spec { 'Unix' } | ||||||||
|
Subroutine
default_file_spec: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 27 | |||||||||||
| 28 | |||||||||||
| 29 | 51 | ▶ | sub file_content { | ||||||||
|
Subroutine
file_content: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 30 | 51 | my ($self, $file) = @_; | |||||||||
| 31 | # TODO: should we croak if not found? would be consistent with Dir | ||||||||||
| 32 | 51 | my $content = $self->{files}{ $self->full_path($file) }; | |||||||||
| 33 | |||||||||||
| 34 | # 5.10: given(ref($content)) | ||||||||||
| 35 | |||||||||||
| 36 | 51 | ▶ | if( my $ref = ref $content ){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | 3 | local $/; # do this here because of perl bug prior to perl 5.15 (7c2d9d0) | |||||||||
| 38 | 3 | ▶ | return $ref eq 'SCALAR' | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | # allow a scalar ref | ||||||||||
| 40 | ? $$content | ||||||||||
| 41 | # or an IO-like object | ||||||||||
| 42 | : $content->getline; | ||||||||||
| 43 | } | ||||||||||
| 44 | # else a simple string | ||||||||||
| 45 | 48 | return $content; | |||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | |||||||||||
| 49 | 32 | ▶ | sub find_files { | ||||||||
|
Subroutine
find_files: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 50 | 32 | my ($self) = @_; | |||||||||
| 51 | |||||||||||
| 52 | 32 | return keys %{ $self->{files} }; | |||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | 8 | 1; | |||||||||
| 56 | |||||||||||
| 57 | __END__ | ||||||||||