Memoir44/App/Command/list.pm

filter: Statementstmt 66.6% 22 / 33 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 70.0% 7 / 10 Podpod 100% 3 / 3 totaltotal 69.5% 32 / 46 CC 2 SCAR 7.4
CC
2
Cov
67%
execute
6.0
description
2.0
opt_spec
2.0
CRAP 2.1
« Memoir44/DB/Params.pm ↑ Summary Memoir44/DB/Scenarios.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 1 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 package WWW::DaysOfWonder::Memoir44::App::Command::list;
14 # ABSTRACT: list scenarios according to various criterias
15 1 $WWW::DaysOfWonder::Memoir44::App::Command::list::VERSION = '3.000';
16 1 ▶use Encode qw{ encode };
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 1 ▶use WWW::DaysOfWonder::Memoir44::App -command;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use WWW::DaysOfWonder::Memoir44::DB::Scenarios;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶use WWW::DaysOfWonder::Memoir44::Filter;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22  
23 # -- public methods
24  
25 0 ▶sub description {
Subroutine description: not called CC=1 SCAR=6.9
Pod documented
26 0 'List the scenarios available in the database according to various
27 criterias. The database must exist - see the update command for
28 this action.';
29 }
30  
31 0 ▶sub opt_spec {
Subroutine opt_spec: not called CC=1 SCAR=6.9
Pod documented
32 0 my $self = shift;
33 return (
34 0 [],
35 [ 'scenario information:' ],
36 [ 'id|i=i' => 'scenario id (can be repeated)' ],
37 [ 'name|n=s' => 'scenario name (treated as a no-case regex)' ],
38 [ 'operation|o=s' => 'scenario operation (treated as a no-case regex)' ],
39 [ 'front|w=s' => 'scenario front (treated as a no-case regex)' ],
40 [ 'format|fmt|f=s' => 'scenario format' ],
41 [ 'board|b=s' => 'scenario board' ],
42 [],
43 [ 'extensions needed:' ],
44 [ 'tp!' => 'terrain pack (--notp to negate)' ],
45 [ 'ef!' => 'east front (--noef to negate)' ],
46 [ 'pt!' => 'pacific theater (--nopt to negate)' ],
47 [ 'mt!' => 'mediterranean theater (--nomt to negate)' ],
48 [ 'ap!' => 'air pack (--noap to negate)' ],
49 [],
50 [ 'scenario meta-information:' ],
51 [ 'rating|r=i' => 'minimum rating' ],
52 [ 'languages|lang|l=s' => 'languages of the scenario (can be repeated)' ],
53 );
54 }
55  
56 0 ▶sub execute {
Subroutine execute: not called CC=2 SCAR=17.9
Pod documented
57 0 my ($self, $opts, $args) = @_;
58  
59 # prepare the filter
60 0 my $filter = WWW::DaysOfWonder::Memoir44::Filter->new_with_options;
61 0 my $grep = $filter->as_grep_clause;
62  
63 # fetch the scenarios
64 0 my $db = WWW::DaysOfWonder::Memoir44::DB::Scenarios->instance;
65 0 $db->read;
66 0 my @scenarios = $db->grep( $grep );
67  
68 # display the results
69 0 foreach my $s ( @scenarios ) {
70 0 say encode( 'utf-8', $s );
71 }
72 }
73  
74 1 1;
75  
76 __END__
« Memoir44/DB/Params.pm ↑ Summary Memoir44/DB/Scenarios.pm »