HiD/File.pm

filter: Statementstmt 100% 41 / 41 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 11 / 11 Podpod 100% 1 / 1 totaltotal 98.2% 56 / 57 CC 3 SCAR 3.8
CC
3
Cov
98%
publish
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.5
« HiD/App/Command/config.pm ↑ Summary HiD/Plugin.pm »
1 # ABSTRACT: Regular files that are only copied, not processed (e.g., CSS, JS, etc.)
2  
3  
4 package HiD::File;
5 18 our $AUTHORITY = 'cpan:GENEHACK';
6 18 $HiD::File::VERSION = '1.96';
7 18 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 18 with 'HiD::Role::IsPublished';
9 18 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 18 ▶use 5.014; # strict, unicode_strings
Subroutine BEGIN: called CC=1 SCAR=0.0
12 18 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 18 ▶use autodie;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 18 ▶use warnings qw/ FATAL utf8 /;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 18 ▶use open qw/ :std :utf8 /;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 18 ▶use charnames qw/ :full /;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 18 ▶use Path::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20  
21 sub publish {
22 23 ▶ my $self = shift;
Subroutine publish: called CC=3 SCAR=11.0
Pod documented
23  
24 23 my $out = path( $self->output_filename );
25 23 my $dir = $out->parent;
26  
27 23 ▶ $dir->mkpath unless $dir->is_dir;
Branch: 1 branch
BranchTrueFalseTotal
unless $dir->is_dir 2 21 23
28  
29 23 ▶ path( $self->input_filename )->copy( $out )
Branch: 1 branch
BranchTrueFalseTotal
path($self->input_filename)->copy($out) or die $! 0 23 23
30 or die $!;
31 }
32  
33 # used to populate the 'url' attr in Role::IsPublished
34 sub _build_url {
35 23 ▶ my $self = shift;
Subroutine _build_url: called CC=1 SCAR=0.0
36  
37 23 my $source = $self->source;
38  
39 23 my $path_frag = $self->input_filename;
40 23 $path_frag =~ s/^$source//;
41  
42 23 return path( $path_frag )->stringify;
43 }
44  
45  
46 18 __PACKAGE__->meta->make_immutable;
47 18 1;
48  
49 __END__
50  
51 =pod
52  
53 =encoding UTF-8
54  
55 =head1 NAME
56  
57 HiD::File - Regular files that are only copied, not processed (e.g., CSS, JS, etc.)
58  
59 =head1 SYNOPSIS
60  
61 my $file = HiD::File->new({
62 dest_dir => 'directory/for/output'
63 input_filename => $file_filename ,
64 });
65  
66 =head1 DESCRIPTION
67  
68 Object class representing "normal" files (ones that HiD just copies from
69 source to destination, without further processing).
70  
71 =head1 METHODS
72  
73 =head2 publish
74  
75 Publishes (in this case, copies) the input file to the output file.
76  
77 =head1 NOTE
78  
79 Also consumes L<HiD::Role::IsPublished>; see documentation for that role as
80 well if you're trying to figure out how an object from this class works.
81  
82 =head1 VERSION
83  
84 version 1.96
85  
86 =head1 AUTHOR
87  
88 John SJ Anderson <genehack@genehack.org>
89  
90 =head1 COPYRIGHT AND LICENSE
91  
92 This software is copyright (c) 2015 by John SJ Anderson.
93  
94 This is free software; you can redistribute it and/or modify it under
95 the same terms as the Perl 5 programming language system itself.
96  
97 =cut
« HiD/App/Command/config.pm ↑ Summary HiD/Plugin.pm »