| 1 | package Mail::BIMI::Role::Data; | ||||||||||
| 2 | # ABSTRACT: Class to retrieve data files | ||||||||||
| 3 | 29 | our $VERSION = '3.20260302'; # VERSION | |||||||||
| 4 | 29 | ▶ | use 5.20.0; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 29 | ▶ | use Moose::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 29 | ▶ | use Mail::BIMI::Prelude; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 29 | ▶ | use File::Slurp qw{ read_file write_file }; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | |||||||||||
| 10 | |||||||||||
| 11 | ▶ | sub get_file_name($self,$file) { | |||||||||
|
Subroutine
get_file_name: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 12 | 12 | my $base_file = __FILE__; | |||||||||
| 13 | 12 | $base_file =~ s/\/Role\/Data.pm$/\/Data\/$file/; | |||||||||
| 14 | 12 | ▶ | if ( ! -e $base_file ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 15 | 1 | die "File $file is missing"; | |||||||||
| 16 | } | ||||||||||
| 17 | 11 | return $base_file; | |||||||||
| 18 | } | ||||||||||
| 19 | |||||||||||
| 20 | |||||||||||
| 21 | ▶ | sub get_data_from_file($self,$file) { | |||||||||
|
Subroutine
get_data_from_file: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 22 | 12 | my $base_file = $self->get_file_name($file); | |||||||||
| 23 | 11 | my $body = read_file($base_file); | |||||||||
| 24 | 11 | return $body; | |||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | 29 | 1; | |||||||||
| 28 | |||||||||||
| 29 | __END__ | ||||||||||
| 30 | |||||||||||
| 31 | =pod | ||||||||||
| 32 | |||||||||||
| 33 | =encoding UTF-8 | ||||||||||
| 34 | |||||||||||
| 35 | =head1 NAME | ||||||||||
| 36 | |||||||||||
| 37 | Mail::BIMI::Role::Data - Class to retrieve data files | ||||||||||
| 38 | |||||||||||
| 39 | =head1 VERSION | ||||||||||
| 40 | |||||||||||
| 41 | version 3.20260302 | ||||||||||
| 42 | |||||||||||
| 43 | =head1 DESCRIPTION | ||||||||||
| 44 | |||||||||||
| 45 | Role for classes which require access to locally packaged files | ||||||||||
| 46 | |||||||||||
| 47 | =head1 METHODS | ||||||||||
| 48 | |||||||||||
| 49 | =head2 I<get_file_name($file)> | ||||||||||
| 50 | |||||||||||
| 51 | Returns the full path and filename for included file $file | ||||||||||
| 52 | |||||||||||
| 53 | =head2 I<get_data_from_file($file)> | ||||||||||
| 54 | |||||||||||
| 55 | Returns the contents of included file $file | ||||||||||
| 56 | |||||||||||
| 57 | =head1 REQUIRES | ||||||||||
| 58 | |||||||||||
| 59 | =over 4 | ||||||||||
| 60 | |||||||||||
| 61 | =item * L<File::Slurp|File::Slurp> | ||||||||||
| 62 | |||||||||||
| 63 | =item * L<Mail::BIMI::Prelude|Mail::BIMI::Prelude> | ||||||||||
| 64 | |||||||||||
| 65 | =item * L<Moose::Role|Moose::Role> | ||||||||||
| 66 | |||||||||||
| 67 | =back | ||||||||||
| 68 | |||||||||||
| 69 | =head1 AUTHOR | ||||||||||
| 70 | |||||||||||
| 71 | Marc Bradshaw <marc@marcbradshaw.net> | ||||||||||
| 72 | |||||||||||
| 73 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 74 | |||||||||||
| 75 | This software is copyright (c) 2020 by Marc Bradshaw. | ||||||||||
| 76 | |||||||||||
| 77 | This is free software; you can redistribute it and/or modify it under | ||||||||||
| 78 | the same terms as the Perl 5 programming language system itself. | ||||||||||
| 79 | |||||||||||
| 80 | =cut | ||||||||||