Memoir44/Scenario.pm

filter: Statementstmt 64.7% 44 / 68 Branchbran 0.0% 0 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 47.0% 8 / 17 Podpod 100% 8 / 8 totaltotal 55.0% 60 / 109 CC 9 SCAR 18.2
CC
9
Cov
52%
_format
20.0
tp
6.0
ef
6.0
CRAP 6.2
« Memoir44/Filter.pm ↑ Summary Memoir44/App/Command/update.pm »
1 #
2 # This file is part of WWW-DaysOfWonder-Memoir44
3 #
4 # This software is copyright (c) 2009 by Jerome Quelin.
5 #
6 # This is free software; you can redistribute it and/or modify it under
7 # the same terms as the Perl 5 programming language system itself.
8 #
9 2 ▶use 5.012;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 package WWW::DaysOfWonder::Memoir44::Scenario;
14 # ABSTRACT: scenario object
15 2 $WWW::DaysOfWonder::Memoir44::Scenario::VERSION = '3.000';
16 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 2 ▶use MooseX::Has::Sugar;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 2 ▶use Text::Padding;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 2 ▶use WWW::DaysOfWonder::Memoir44::Types;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 2 ▶use overload q{""} => 'as_string';
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24  
25 # -- public attributes
26  
27  
28 2 has id => ( rw, isa=>'Int', required );
29 2 has name => ( rw, isa=>'Str', required );
30 2 has operation => ( rw, isa=>'Str' );
31 2 has updated => ( rw, isa=>'Str', required );
32 2 has rating => ( rw, isa=>'Int_0_3' );
33 2 has front => ( rw, isa=>'Str' );
34 2 has author => ( rw, isa=>'Str' );
35 2 has board => ( rw, isa=>'Board' );
36 2 has format => ( rw, isa=>'Format' );
37 2 has source => ( rw, isa=>'Source' );
38 2 has need_tp => ( rw, isa=>'Bool' );
39 2 has need_ef => ( rw, isa=>'Bool' );
40 2 has need_mt => ( rw, isa=>'Bool' );
41 2 has need_pt => ( rw, isa=>'Bool' );
42 2 has need_ap => ( rw, isa=>'Bool' );
43 2 has need_bm => ( rw, isa=>'Bool' );
44 2 has need_cb => ( rw, isa=>'Bool' );
45 2 has languages => ( rw, isa=>'ArrayRef[Str]', auto_deref );
46  
47  
48  
49 # -- public methods
50  
51  
52 0 ▶sub as_string {
Subroutine as_string: not called CC=1 SCAR=6.9
Pod documented
53 0 my $s = shift;
54  
55 0 my $out = join " ", qw{
56 R6id. L38name L34operation
57 C13front C8format C7board
58 C12author C10source L10updated C3rating_as_star
59 L2tp L2ef L2pt L2mt L2ap L8langs
60 };
61 0 $out =~ s/([RCL])(\d+)(\w+)/$s->_format($1,$2,$3)/eg;
62 0 return $out;
63 }
64  
65  
66 0 ▶sub langs { my $s=shift; return join ",", $s->languages; }
Subroutine langs: not called CC=1 SCAR=6.9
Pod documented
67 0 ▶sub rating_as_star { my $s=shift; '*'x$s->rating; }
Subroutine rating_as_star: not called CC=1 SCAR=6.9
Pod documented
68 0 ▶sub tp { my $s=shift; $s->need_tp ? 'tp' : ''; }
Subroutine tp: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$s->need_tp ? : 0 0 0
69 0 ▶sub ef { my $s=shift; $s->need_ef ? 'ef' : ''; }
Subroutine ef: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$s->need_ef ? : 0 0 0
70 0 ▶sub pt { my $s=shift; $s->need_pt ? 'pt' : ''; }
Subroutine pt: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$s->need_pt ? : 0 0 0
71 0 ▶sub mt { my $s=shift; $s->need_mt ? 'mt' : ''; }
Subroutine mt: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$s->need_mt ? : 0 0 0
72 0 ▶sub ap { my $s=shift; $s->need_ap ? 'ap' : ''; }
Subroutine ap: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$s->need_ap ? : 0 0 0
73  
74  
75 # -- private methods
76  
77 # $pad should not be re-created for each display
78 2 my $pad = Text::Padding->new;
79 0 ▶sub _format {
Subroutine _format: not called CC=4 SCAR=30.0
80 0 my ($self, $align, $maxlength, $method) = @_;
81 0 my $str = $self->$method;
82  
83 # fill up according to the requirements
84 0 ▶ return $pad->left ($str, $maxlength) if $align eq "L";
Branch: 1 branch
BranchTrueFalseTotal
if $align eq "L" 0 0 0
85 0 ▶ return $pad->right ($str, $maxlength) if $align eq "R";
Branch: 1 branch
BranchTrueFalseTotal
if $align eq "R" 0 0 0
86 0 ▶ return $pad->center($str, $maxlength) if $align eq "C";
Branch: 1 branch
BranchTrueFalseTotal
if $align eq "C" 0 0 0
87 }
88  
89 2 1;
90  
91 __END__
« Memoir44/Filter.pm ↑ Summary Memoir44/App/Command/update.pm »