HiD/File.pm

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