Repository/Mailrc.pm

filter: Statementstmt 93.3% 28 / 30 Branchbran 50.0% 4 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 6 / 7 Podpod 0.0% 0 / 4 totaltotal 77.5% 38 / 49 SCAR 19.7
CC
7
Cov
84%
get_alias
6.0
_build_aliases
4.0
generate_content
3.0
CRAP 7.2
« Repository/Role/File.pm ↑ Summary
1 package CPAN::Repository::Mailrc;
2 BEGIN {
3 2 ▶ $CPAN::Repository::Mailrc::AUTHORITY = 'cpan:GETTY';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 }
5 {
6 2 $CPAN::Repository::Mailrc::VERSION = '0.008';
7 }
8 # ABSTRACT: 01mailrc
9  
10 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 2 with qw(
13 CPAN::Repository::Role::File
14 );
15  
16 17 ▶sub file_parts { 'authors', '01mailrc.txt' }
Subroutine file_parts: called CC=1 SCAR=0.0
Pod undocumented
17  
18 2 has aliases => (
19 is => 'ro',
20 lazy => 1,
21 builder => '_build_aliases',
22 );
23  
24 sub _build_aliases {
25 2 ▶ my ( $self ) = @_;
Subroutine _build_aliases: called CC=4 SCAR=13.9
26 2 ▶ return {} unless $self->exist;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->exist 1 1 2
27 1 my @lines = $self->get_file_lines;
28 1 my %aliases;
29 1 for (@lines) {
30 2 ▶ if ($_ =~ m/^alias (\w+) "(.*)"$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_ =~ /^alias (\w+) "(.*)"$/) 2 0 2
31 2 $aliases{$1} = $2;
32 }
33 }
34 1 return \%aliases;
35 }
36  
37 sub set_alias {
38 2 ▶ my ( $self, $author, $alias ) = @_;
Subroutine set_alias: called CC=1 SCAR=0.0
Pod undocumented
39 2 $self->aliases->{$author} = $alias;
40 2 return $self;
41 }
42  
43 sub get_alias {
44 0 ▶ my ( $self, $author ) = @_;
Subroutine get_alias: not called CC=2 SCAR=17.9
Pod undocumented
45 return defined $self->aliases->{$author}
46 0 ▶ ? $self->aliases->{$author}
Branch: 1 branch
BranchTrueFalseTotal
defined $self->aliases->{$author} ? : 0 0 0
47 : ();
48 }
49  
50 sub generate_content {
51 3 ▶ my ( $self ) = @_;
Subroutine generate_content: called CC=3 SCAR=11.0
Pod undocumented
52 3 my $content = "";
53 3 for (sort { $a cmp $b } keys %{$self->aliases}) {
54 3 ▶ $content .= 'alias '.$_.' "'.( $self->aliases->{$_} ? $self->aliases->{$_} : $_ ).'"'."\n";
Branch: 1 branch
BranchTrueFalseTotal
$self->aliases->{$_} ? : 0 3 3
55 }
56 3 return $content;
57 }
58  
59 2 1;
60  
61  
62  
63 __END__
64 =pod
65  
66 =head1 NAME
67  
68 CPAN::Repository::Mailrc - 01mailrc
69  
70 =head1 VERSION
71  
72 version 0.008
73  
74 =head1 SYNOPSIS
75  
76 use CPAN::Repository::Mailrc;
77  
78 my $mailrc = CPAN::Repository::Mailrc->new({
79 repository_root => $fullpath_to_root,
80 });
81  
82 =encoding utf8
83  
84 =head1 SEE ALSO
85  
86 L<CPAN::Repository>
87  
88 =head1 SUPPORT
89  
90 IRC
91  
92 Join #duckduckgo on irc.freenode.net. Highlight Getty for fast reaction :).
93  
94 Repository
95  
96 http://github.com/Getty/p5-cpan-repository
97 Pull request and additional contributors are welcome
98  
99 Issue Tracker
100  
101 http://github.com/Getty/p5-cpan-repository/issues
102  
103 =head1 AUTHOR
104  
105 Torsten Raudssus <torsten@raudss.us> L<http://raudss.us/>
106  
107 =head1 COPYRIGHT AND LICENSE
108  
109 This software is copyright (c) 2012 by DuckDuckGo, Inc. L<http://duckduckgo.com/>.
110  
111 This is free software; you can redistribute it and/or modify it under
112 the same terms as the Perl 5 programming language system itself.
113  
114 =cut
115  
« Repository/Role/File.pm ↑ Summary