blib/lib/File/Sticker/Derive/Title.pm

filter: Statementstmt 45.8% 11 / 24 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 3 / 6 Podpod 100% 3 / 3 totaltotal 45.9% 17 / 37 CC 3 SCAR 16.8
CC
3
Cov
39%
derive
12.0
whoami
2.0
order
2.0
CRAP 5.4
« blib/lib/File/Sticker/Database.pm ↑ Summary blib/lib/File/Sticker/Derive.pm »
1 package File::Sticker::Derive::Title;
2 1 $File::Sticker::Derive::Title::VERSION = '4.605';
3 =head1 NAME
4  
5 File::Sticker::Derive::Title - derive values from existing meta-data
6  
7 =head1 VERSION
8  
9 version 4.605
10  
11 =head1 SYNOPSIS
12  
13 use File::Sticker::Derive::Title;
14  
15 my $deriver = File::Sticker::Derive::Title->new(%args);
16  
17 my $derived_meta = $deriver->derive(filename=>$filename,meta=>$meta);
18  
19 =head1 DESCRIPTION
20  
21 This will derive values from existing meta-data.
22 This is the Title plugin, which derives a "title" from the file name
23 if there isn't already a title.
24  
25 =cut
26  
27 1 ▶use common::sense;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 1 ▶use String::CamelCase qw(wordsplit);
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 1 ▶use parent qw(File::Sticker::Derive);
Subroutine BEGIN: called CC=1 SCAR=0.0
31  
32 =head1 DEBUGGING
33  
34 =head2 whoami
35  
36 Used for debugging info
37  
38 =cut
39 0 ▶sub whoami { ( caller(1) )[3] }
Subroutine whoami: not called CC=1 SCAR=6.9
Pod documented
40  
41 =head1 METHODS
42  
43 =head2 order
44  
45 The order of this deriver, ranging from 0 to 99.
46 This makes sure that the deriver is applied in order;
47 useful because a later deriver may depend on data created
48 by an earlier deriver.
49  
50 =cut
51  
52 sub order {
53 0 ▶ return 90;
Subroutine order: not called CC=1 SCAR=6.9
Pod documented
54 } # order
55  
56 =head2 derive
57  
58 Derive common values from the existing meta-data.
59 This is expected to update the given meta-data.
60  
61 $deriver->derive(filename=>$filename, meta=>$meta);
62  
63 =cut
64  
65 sub derive {
66 0 ▶ my $self = shift;
Subroutine derive: not called CC=3 SCAR=24.8
Pod documented
67 0 my %args = @_;
68 0 ▶ say STDERR whoami() if $self->{verbose} > 2;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"verbose"} > 2 0 0 0
69  
70 0 my $filename = $args{filename};
71 0 my $meta = $args{meta};
72  
73 # title
74 0 ▶ if (!$meta->{title})
Branch: 1 branch
BranchTrueFalseTotal
if (not $meta->{"title"}) 0 0 0
75 {
76 0 my @words = wordsplit($meta->{id_name});
77 0 my $title = join(' ', @words);
78 0 $title =~ s/(\w+)/\u\L$1/g; # title case
79 0 $title =~ s/(\d+)$/ $1/; # trailing numbers
80 0 $meta->{title} = $title;
81 }
82  
83 } # derive
84  
85 =head1 BUGS
86  
87 Please report any bugs or feature requests to the author.
88  
89 =cut
90  
91 1 1; # End of File::Sticker::Derive::Title
92 __END__
« blib/lib/File/Sticker/Database.pm ↑ Summary blib/lib/File/Sticker/Derive.pm »