| 1 | package Langertha::Holmgang::Sim::Kueche; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: The answer world kueche — recipe collection, pantry, shopping list, week plan, units | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 40 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 40 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 40 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 40 | with 'Langertha::Holmgang::Role::AnswerWorld'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 40 | our $VERSION = '0.001'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 40 | our @DAYS = qw( Montag Dienstag Mittwoch Donnerstag Freitag Samstag Sonntag ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | # Masstabelle: Schreibweise -> [ Dimension, Faktor zur Grundeinheit ]. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | # Dimension g (Gewicht), ml (Raum), loeffel (g oder ml, je nach Zutat), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | # sonst eine Zaehleinheit (ihr eigener Name). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 40 | our %UNIT = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | g => [ g => 1 ], gr => [ g => 1 ], gramm => [ g => 1 ], kg => [ g => 1000 ], kilogramm => [ g => 1000 ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | ml => [ ml => 1 ], cl => [ ml => 10 ], dl => [ ml => 100 ], l => [ ml => 1000 ], liter => [ ml => 1000 ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | el => [ loeffel => 15 ], 'esslöffel' => [ loeffel => 15 ], 'eßlöffel' => [ loeffel => 15 ], 'eßl' => [ loeffel => 15 ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | tl => [ loeffel => 5 ], 'teelöffel' => [ loeffel => 5 ], 'teel' => [ loeffel => 5 ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | # englisch (nur metrisch) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | gram => [ g => 1 ], grams => [ g => 1 ], kilogram => [ g => 1000 ], kilograms => [ g => 1000 ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | milliliter => [ ml => 1 ], milliliters => [ ml => 1 ], millilitre => [ ml => 1 ], millilitres => [ ml => 1 ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | liters => [ ml => 1000 ], litre => [ ml => 1000 ], litres => [ ml => 1000 ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | tbsp => [ loeffel => 15 ], tablespoon => [ loeffel => 15 ], tablespoons => [ loeffel => 15 ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | tsp => [ loeffel => 5 ], teaspoon => [ loeffel => 5 ], teaspoons => [ loeffel => 5 ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | # Zaehleinheiten: Einzahl -> Mehrzahl (beide werden angenommen). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 40 | our %COUNT = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 'Stück' => 'Stück', Dose => 'Dosen', Zehe => 'Zehen', Bund => 'Bund', Becher => 'Becher', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | Packung => 'Packungen', 'Päckchen' => 'Päckchen', Scheibe => 'Scheiben', Glas => 'Gläser', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | Stange => 'Stangen', Zweig => 'Zweige', Blatt => 'Blätter', Knolle => 'Knollen', Kopf => 'Köpfe', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | Tafel => 'Tafeln', Beutel => 'Beutel', Flasche => 'Flaschen', Würfel => 'Würfel', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | Kugel => 'Kugeln', 'Tüte' => 'Tüten', 'Tütchen' => 'Tütchen', Stiel => 'Stiele', Paket => 'Pakete', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | Rolle => 'Rollen', Laib => 'Laibe', Schote => 'Schoten', Ecke => 'Ecken', Riegel => 'Riegel', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | # englisch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | clove => 'cloves', can => 'cans', slice => 'slices', sprig => 'sprigs', piece => 'pieces', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | stalk => 'stalks', head => 'heads', bunch => 'bunches', leaf => 'leaves', package => 'packages', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | sheet => 'sheets', stick => 'sticks', jar => 'jars', bottle => 'bottles', bag => 'bags', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | # Schreibweise (klein) -> Einzahl der Zaehleinheit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | our %COUNT_OF = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 1720 | ( map { ( lc $_ => $_, lc $COUNT{$_} => $_ ) } keys %COUNT ), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | stk => 'Stück', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 40 | ( map { ( $_ => 'Päckchen' ) } qw( pck pkg päck ) ), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | # Die Werkzeuge dieser Welt mit ihren Pflichtparametern (fuer den Lader). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 40 | our %TOOLS = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | rezepte_suchen => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | rezept_lesen => ['rezept'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | vorrat_lesen => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | liste_lesen => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | auf_liste_setzen => [qw( zutat menge )], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | von_liste_nehmen => ['zutat'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | plan_lesen => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | plan_setzen => [qw( tag rezept portionen )], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 40 | my %VULGAR = ( '½' => 0.5, '¼' => 0.25, '¾' => 0.75, '⅓' => 1 / 3, '⅔' => 2 / 3 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | #### Plugin contract | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 79 | ▶ | sub device_type { 'kueche' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
device_type: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 9 | ▶ | sub tools { return \%TOOLS } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tools: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 77 | ▶ | sub tool { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tool: called CC=5 SCAR=16.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 77 | my ( $self, $dev, $name, $args, $ctx ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 77 | ▶ | $name //= ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$name //= ""
MC/DC0%0/1
$name //= ""
$name
Truth table50%1/2
A
A= $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 77 | ▶ | my $code = $TOOLS{$name} && $self->can( '_t_'.$name ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$Langertha::Holmgang::Sim::Kueche::TOOLS{$name} && $self->can('_t_' . $name)
MC/DC50%1/2
$Langertha::Holmgang::Sim::Kueche::TOOLS{$name} && $self->can('_t_' . $name)
$Langertha::Holmgang::Sim::Kueche::TOOLS{$name}
$self->can('_t_' . $name)
Truth table66%2/3
A && B
A= $Langertha::Holmgang::Sim::Kueche::TOOLS{$name}B= $self->can('_t_' . $name)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | or return ( "Fehler: unbekanntes Werkzeug '".$name."'", 0 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 76 | ▶ | return $self->$code( $dev, $args || {} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args || {}
MC/DC0%0/1
$args || {}
$args
Truth table50%1/2
A
A= $args
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | #### Mengen (reine Funktionen, auch fuer Generatoren) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 35 | ▶ | sub number { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
number: called CC=7 SCAR=19.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 35 | my ( $s ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 35 | ▶ | return undef unless defined $s; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 33 | $s =~ s/\A\s+|\s+\z//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 33 | ▶ | return $VULGAR{$s} if exists $VULGAR{$s}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 32 | ▶ | return $1 + $VULGAR{$2} if $s =~ /\A(\d+)\s*([½¼¾⅓⅔])\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 32 | ▶ | return $2 ? $1 / $2 : undef if $s =~ m{\A(\d+)\s*/\s*(\d+)\z}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 31 | ▶ | return undef unless $s =~ /\A\d+(?:[.,]\d+)?\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 31 | $s =~ tr/,/./; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 31 | return 0 + $s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 28 | ▶ | sub show_number { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
show_number: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 28 | my ( $n ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 28 | my $s = sprintf '%.3f', $n; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 28 | $s =~ s/\.?0+\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 28 | $s =~ tr/./,/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 28 | return $s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 27 | ▶ | sub unit_of { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unit_of: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 27 | my ( $u ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 27 | ▶ | return () unless defined $u; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 27 | ( my $k = lc $u ) =~ s/\.\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 27 | ▶ | return @{ $UNIT{$k} } if $UNIT{$k}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 4 | ▶ | return ( $COUNT_OF{$k}, 1 ) if $COUNT_OF{$k}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 1 | return (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 35 | ▶ | sub parse_amount { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_amount: called CC=18 SCAR=29.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 35 | my ( $text, $base ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 35 | ▶ | $text = '' unless defined $text; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 35 | $text = "$text"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 35 | $text =~ s/\A\s+|\s+\z//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 35 | my ( $num, $unit ) = $text =~ /\A(\d+(?:[.,]\d+)?(?:\s*\/\s*\d+)?|\d*\s*[½¼¾⅓⅔])\s*(.*)\z/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 35 | my $n = number($num); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 35 | ▶ | return ( undef, undef, "Menge '".$text."' nicht lesbar (z. B. \"250 g\", \"2 EL\", \"3\")" ) unless defined $n && $n > 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $n and $n > 0
MC/DC50%1/2
defined $n and $n > 0
defined $n
$n > 0
Truth table66%2/3
A and B
A= defined $nB= $n > 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 33 | my ( $dim, $f ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 33 | ▶ | if ( !length $unit ) { ( $dim, $f ) = ( $base && ( $base eq 'g' || $base eq 'ml' ) ? undef : ( $base // 'Stück' ), 1 ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition87%7/8
$base and $base eq "g" || $base eq "ml"
$base eq "g" or $base eq "ml"
$base // "St\x{fc}ck"
MC/DC66%2/3
$base and $base eq "g" || $base eq "ml"
$base
$base eq "g"
$base eq "ml"
MC/DC100%1/1
$base // "St\x{fc}ck"
$base
Truth table75%3/4
A and B or C
A= $baseB= $base eq "g"C= $base eq "ml"
Truth table100%2/2
A
A= $base
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 27 | else { ( $dim, $f ) = unit_of($unit) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 33 | ▶ | return ( undef, undef, "Einheit '".$unit."' unbekannt" ) unless defined $dim || !length $unit; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $dim or not length $unit
MC/DC100%2/2
defined $dim or not length $unit
defined $dim
not length $unit
Truth table100%3/3
A or not(B)
A= defined $dimB= not length $unit
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 32 | ▶ | return ( undef, undef, "Menge '".$text."' ohne Einheit — bitte mit Einheit angeben (in ".$base.')' ) unless defined $dim; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 31 | ▶ | $base //= $dim eq 'loeffel' ? 'g' : $dim; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$base //= $dim eq "loeffel" ? "g" : $dim
MC/DC0%0/2
$base //= $dim eq "loeffel" ? "g" : $dim
$base
$dim eq "loeffel" ? "g" : $dim
Truth table66%2/3
A //= B
A= $baseB= $dim eq "loeffel" ? "g" : $dim
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 31 | ▶ | if ( $dim eq 'loeffel' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 6 | ▶ | return ( undef, undef, 'Löffelmaß passt nicht zu '.$base ) unless $base eq 'g' || $base eq 'ml'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$base eq "g" or $base eq "ml"
MC/DC100%2/2
$base eq "g" or $base eq "ml"
$base eq "g"
$base eq "ml"
Truth table100%3/3
A or B
A= $base eq "g"B= $base eq "ml"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 5 | $dim = $base; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 30 | ▶ | return ( undef, undef, "Einheit '".$unit."' passt nicht — wird in ".$base.' geführt' ) unless $dim eq $base; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 26 | return ( 0 + sprintf( '%.3f', $n * $f ), $base ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 15 | ▶ | sub portions { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
portions: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 15 | my ( $n ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 15 | ▶ | return !defined $n ? 'Portionen ohne Angabe' : $n == 1 ? '1 Portion' : $n.' Portionen'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | #### Zustand | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 31 | ▶ | sub _canon { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_canon: called CC=11 SCAR=24.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 31 | my ( $self, $dev, $name ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 31 | ▶ | return undef unless defined $name && !ref $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $name and not ref $name
MC/DC0%0/2
defined $name and not ref $name
defined $name
not ref $name
Truth table33%1/3
A and not(B)
A= defined $nameB= not ref $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 31 | ( my $want = lc $name ) =~ s/\A\s+|\s+\z//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 31 | ▶ | my $z = $dev->{zutaten} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$$dev{'zutaten'} || {}
MC/DC100%1/1
$$dev{'zutaten'} || {}
$$dev{'zutaten'}
Truth table100%2/2
A
A= $$dev{'zutaten'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 31 | for my $k ( sort keys %$z ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 45 | ▶ | return $k if lc $k eq $want || grep { lc $_ eq $want } @{ $z->{$k}{namen} || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%5/5
lc $k eq $want or grep {lc $_ eq $want;} @{$$z{$k}{"namen"} or [];}
$$z{$k}{'namen'} || []
MC/DC100%2/2
lc $k eq $want or grep {lc $_ eq $want;} @{$$z{$k}{"namen"} or [];}
lc $k eq $want
grep {lc $_ eq $want;} @{$$z{$k}{"namen"} or [];}
MC/DC100%1/1
$$z{$k}{'namen'} || []
$$z{$k}{'namen'}
Truth table100%3/3
A or B
A= lc $k eq $wantB= grep {lc $_ eq $want;} @{$$z{$k}{"namen"} or [];}
Truth table100%2/2
A
A= $$z{$k}{'namen'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 11 | ▶ | for my $k ( sort keys %{ $dev->{liste} || {} } ) { return $k if lc $k eq $want } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$$dev{'liste'} || {}
MC/DC100%1/1
$$dev{'liste'} || {}
$$dev{'liste'}
Truth table100%2/2
A
A= $$dev{'liste'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 9 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | # "2 Eier" oder "30 g Mehl" als Menge: der Name der Zutat am Ende faellt weg. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 21 | ▶ | sub _strip_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_strip_name: called CC=7 SCAR=19.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 21 | my ( $self, $dev, $z, $menge ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 21 | ▶ | return $menge unless defined $menge && !ref $menge; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $menge and not ref $menge
MC/DC0%0/2
defined $menge and not ref $menge
defined $menge
not ref $menge
Truth table33%1/3
A and not(B)
A= defined $mengeB= not ref $menge
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 21 | my $known = $self->_zutat( $dev, $z ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 21 | ▶ | for my $n ( sort { length $b <=> length $a } $z, @{ $known ? $known->{namen} || [] : [] } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$$known{"namen"} or []
MC/DC100%1/1
$$known{"namen"} or []
$$known{"namen"}
Truth table100%2/2
A
A= $$known{"namen"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 25 | ▶ | return $1 if $menge =~ /\A(.*?\S)\s+\Q$n\E\s*\z/i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 20 | return $menge; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | # lesen, ohne den Zustand anzulegen: ein Lesebefehl aendert nichts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 67 | ▶ | sub _zutat { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_zutat: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 67 | my ( $self, $dev, $z ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 67 | my $all = $dev->{zutaten}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 67 | ▶ | return ref $all eq 'HASH' && defined $z ? $all->{$z} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $all eq "HASH" and defined $z
MC/DC50%1/2
ref $all eq "HASH" and defined $z
ref $all eq "HASH"
defined $z
Truth table66%2/3
A and B
A= ref $all eq "HASH"B= defined $z
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 46 | ▶ | sub _base { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_base: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 46 | my ( $self, $dev, $z ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 46 | my $e = $self->_zutat( $dev, $z ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 46 | ▶ | return ref $e eq 'HASH' ? $e->{einheit} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 27 | ▶ | sub _show_amount { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_show_amount: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 27 | my ( $self, $dev, $z, $n ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 27 | ▶ | my $u = $self->_base( $dev, $z ) // 'Stück'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->_base($dev, $z) // "St\x{fc}ck"
MC/DC100%1/1
$self->_base($dev, $z) // "St\x{fc}ck"
$self->_base($dev, $z)
Truth table100%2/2
A
A= $self->_base($dev, $z)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 27 | ▶ | $u = $COUNT{$u} if $COUNT{$u} && $n != 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$Langertha::Holmgang::Sim::Kueche::COUNT{$u} and $n != 1
MC/DC100%2/2
$Langertha::Holmgang::Sim::Kueche::COUNT{$u} and $n != 1
$Langertha::Holmgang::Sim::Kueche::COUNT{$u}
$n != 1
Truth table100%3/3
A and B
A= $Langertha::Holmgang::Sim::Kueche::COUNT{$u}B= $n != 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 27 | return show_number($n).' '.$u; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 14 | ▶ | sub _recipe { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_recipe: called CC=7 SCAR=20.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 14 | my ( $self, $dev, $ref ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 14 | ▶ | my $r = $dev->{rezepte} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$$dev{'rezepte'} || {}
MC/DC100%1/1
$$dev{'rezepte'} || {}
$$dev{'rezepte'}
Truth table100%2/2
A
A= $$dev{'rezepte'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 14 | ▶ | return undef unless defined $ref && !ref $ref; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $ref and not ref $ref
MC/DC0%0/2
defined $ref and not ref $ref
defined $ref
not ref $ref
Truth table33%1/3
A and not(B)
A= defined $refB= not ref $ref
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 14 | ( my $want = lc $ref ) =~ s/\A\s+|\s+\z//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 14 | ▶ | return $want if $r->{$want}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 10 | ▶ | my @hit = grep { lc( $r->{$_}{titel} // '' ) eq $want } sort keys %$r; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$r{$_}{"titel"} // ""
MC/DC0%0/1
$$r{$_}{"titel"} // ""
$$r{$_}{"titel"}
Truth table50%1/2
A
A= $$r{$_}{"titel"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 10 | ▶ | return @hit == 1 ? $hit[0] : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 7 | ▶ | sub _veg { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_veg: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 7 | my ( $self, $v ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 7 | ▶ | return { vegan => 'vegan', ja => 'vegetarisch', nein => 'nicht vegetarisch' }->{ $v // '' } // 'unbekannt'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%4/4
{"vegan", "vegan", "ja", "vegetarisch", "nein", "nicht vegetarisch"}->{$v // ""} // "unbekannt"
$v // ""
MC/DC100%1/1
{"vegan", "vegan", "ja", "vegetarisch", "nein", "nicht vegetarisch"}->{$v // ""} // "unbekannt"
{"vegan", "vegan", "ja", "vegetarisch", "nein", "nicht vegetarisch"}->{$v // ""}
MC/DC100%1/1
$v // ""
$v
Truth table100%2/2
A
A= {"vegan", "vegan", "ja", "vegetarisch", "nein", "nicht vegetarisch"}->{$v // ""}
Truth table100%2/2
A
A= $v
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 7 | ▶ | sub _zeit { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_zeit: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 7 | my ( $self, $z ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 7 | ▶ | return defined $z ? $z.' min' : 'keine Angabe'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 11 | ▶ | sub _list_text { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_list_text: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 11 | my ( $self, $dev, $h, $empty ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 11 | ▶ | my @k = sort { lc $a cmp lc $b } grep { $h->{$_} } keys %{ $h || {} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$h || {}
MC/DC100%1/1
$h || {}
$h
Truth table100%2/2
A
A= $h
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 11 | ▶ | return $empty unless @k; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 7 | ▶ | return join "\n", map { '- '.$_.': '.( $h->{$_} =~ /\A\d/ ? $self->_show_amount( $dev, $_, $h->{$_} ) : $h->{$_} ) } @k; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | #### Werkzeuge | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 11 | ▶ | sub _t_rezepte_suchen { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_t_rezepte_suchen: called CC=8 SCAR=20.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 11 | my ( $self, $dev, $p ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 11 | ▶ | my $q = lc( $p->{suchbegriff} // '' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$$p{"suchbegriff"} // ""
MC/DC100%1/1
$$p{"suchbegriff"} // ""
$$p{"suchbegriff"}
Truth table100%2/2
A
A= $$p{"suchbegriff"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 11 | $q =~ s/\A\s+|\s+\z//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 11 | ▶ | my $r = $dev->{rezepte} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$$dev{'rezepte'} || {}
MC/DC100%1/1
$$dev{'rezepte'} || {}
$$dev{'rezepte'}
Truth table100%2/2
A
A= $$dev{'rezepte'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | my @ids = grep { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 10 | my $x = $r->{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 10 | ▶ | !length $q || index( lc $x->{titel}, $q ) >= 0 || grep { index( lc $_->{zutat}, $q ) >= 0 } @{ $x->{zutaten} || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition87%7/8
!length($q) || index(lc $$x{'titel'}, $q) != -1 || grep({index(lc $$_{'zutat'}, $q) != -1;} @{$$x{'zutaten'} or [];})
not length $q or index(lc $$x{"titel"}, $q) != -1
$$x{'zutaten'} || []
MC/DC100%3/3
!length($q) || index(lc $$x{'titel'}, $q) != -1 || grep({index(lc $$_{'zutat'}, $q) != -1;} @{$$x{'zutaten'} or [];})
not length $q
index(lc $$x{"titel"}, $q) != -1
grep({index(lc $$_{'zutat'}, $q) != -1;} @{$$x{'zutaten'} or [];})
MC/DC0%0/1
$$x{'zutaten'} || []
$$x{'zutaten'}
Truth table100%4/4
not(A) or B || C
A= not length $qB= index(lc $$x{"titel"}, $q) != -1C= grep({index(lc $$_{'zutat'}, $q) != -1;} @{$$x{'zutaten'} or [];})
Truth table50%1/2
A
A= $$x{'zutaten'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 11 | ▶ | } sort { lc $r->{$a}{titel} cmp lc $r->{$b}{titel} || $a cmp $b } keys %$r; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
lc $$r{$a}{'titel'} cmp lc $$r{$b}{'titel'} || $a cmp $b
MC/DC0%0/2
lc $$r{$a}{'titel'} cmp lc $$r{$b}{'titel'} || $a cmp $b
lc $$r{$a}{'titel'} cmp lc $$r{$b}{'titel'}
$a cmp $b
Truth table33%1/3
A || B
A= lc $$r{$a}{'titel'} cmp lc $$r{$b}{'titel'}B= $a cmp $b
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 11 | ▶ | return ( 'Keine Rezepte gefunden.', 1 ) unless @ids; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | return ( join( "\n", scalar(@ids).' Rezepte:', map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 4 | my $x = $r->{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 5 | '- '.$_.': '.$x->{titel}.' ('.portions( $x->{portionen} ).', '.$self->_zeit( $x->{zeit} ).', '.$self->_veg( $x->{vegetarisch} ).')'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | } @ids ), 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 8 | ▶ | sub _t_rezept_lesen { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_t_rezept_lesen: called CC=6 SCAR=18.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 8 | my ( $self, $dev, $p ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | my $id = $self->_recipe( $dev, $p->{rezept} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 8 | ▶ | or return ( "Rezept '".( $p->{rezept} // '' )."' nicht gefunden.", 0 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$$p{"rezept"} // ""
MC/DC0%0/1
$$p{"rezept"} // ""
$$p{"rezept"}
Truth table50%1/2
A
A= $$p{"rezept"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 2 | my $x = $dev->{rezepte}{$id}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | my @l = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | $x->{titel}.' (ID '.$id.')', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 'Portionen: '.( $x->{portionen} // 'keine Angabe' ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 'Zubereitungszeit: '.$self->_zeit( $x->{zeit} ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 2 | ▶ | 'Vegetarisch: '.$self->_veg( $x->{vegetarisch} ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$x{"portionen"} // "keine Angabe"
MC/DC0%0/1
$$x{"portionen"} // "keine Angabe"
$$x{"portionen"}
Truth table50%1/2
A
A= $$x{"portionen"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 'Zutaten:', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 2 | ▶ | push @l, map { '- '.$_->{text} } @{ $x->{zutaten} || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$x{'zutaten'} || []
MC/DC0%0/1
$$x{'zutaten'} || []
$$x{'zutaten'}
Truth table50%1/2
A
A= $$x{'zutaten'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 2 | ▶ | push @l, 'Quelle: '.$x->{quelle} if $x->{quelle}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 2 | return ( join( "\n", @l ), 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 6 | ▶ | sub _t_vorrat_lesen { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_t_vorrat_lesen: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 6 | my ( $self, $dev ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 6 | return ( $self->_list_text( $dev, $dev->{vorrat}, 'Der Vorrat ist leer.' ), 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 5 | ▶ | sub _t_liste_lesen { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_t_liste_lesen: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 5 | my ( $self, $dev ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 5 | return ( $self->_list_text( $dev, $dev->{liste}, 'Die Einkaufsliste ist leer.' ), 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 17 | ▶ | sub _t_auf_liste_setzen { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_t_auf_liste_setzen: called CC=9 SCAR=22.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 17 | my ( $self, $dev, $p ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 17 | ▶ | my $name = $p->{zutat} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$p{"zutat"} // ""
MC/DC0%0/1
$$p{"zutat"} // ""
$$p{"zutat"}
Truth table50%1/2
A
A= $$p{"zutat"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 17 | $name =~ s/\A\s+|\s+\z//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 17 | ▶ | return ( 'Fehler: Zutat fehlt.', 0 ) unless length $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 16 | my $z = $self->_canon( $dev, $name ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 16 | ▶ | my ( $n, $base, $err ) = parse_amount( $self->_strip_name( $dev, $z // $name, $p->{menge} ), $z ? $self->_base( $dev, $z ) : undef ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$z // $name
MC/DC0%0/2
$z // $name
$z
$name
Truth table66%2/3
A // B
A= $zB= $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 16 | ▶ | return ( 'Fehler: '.$err.'.', 0 ) if $err; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 13 | ▶ | if ( !$z ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 2 | $z = $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 2 | ▶ | $dev->{zutaten}{$z} = { einheit => $base } unless $dev->{zutaten}{$z}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 13 | ▶ | $dev->{liste}{$z} = 0 + sprintf '%.3f', ( $dev->{liste}{$z} // 0 ) + $n; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$$dev{"liste"}{$z} // 0
MC/DC100%1/1
$$dev{"liste"}{$z} // 0
$$dev{"liste"}{$z}
Truth table100%2/2
A
A= $$dev{"liste"}{$z}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 13 | return ( 'Auf der Liste: '.$z.' '.$self->_show_amount( $dev, $z, $dev->{liste}{$z} ), 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 15 | ▶ | sub _t_von_liste_nehmen { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_t_von_liste_nehmen: called CC=10 SCAR=23.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 15 | my ( $self, $dev, $p ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 15 | my $z = $self->_canon( $dev, $p->{zutat} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 15 | ▶ | return ( "Fehler: '".( $p->{zutat} // '' )."' steht nicht auf der Liste.", 0 ) unless $z && $dev->{liste} && $dev->{liste}{$z}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition87%7/8
$z and $$dev{"liste"} and $$dev{"liste"}{$z}
$z and $$dev{"liste"}
$$p{"zutat"} // ""
MC/DC100%3/3
$z and $$dev{"liste"} and $$dev{"liste"}{$z}
$z
$$dev{"liste"}
$$dev{"liste"}{$z}
MC/DC0%0/1
$$p{"zutat"} // ""
$$p{"zutat"}
Truth table100%4/4
A and B and C
A= $zB= $$dev{"liste"}C= $$dev{"liste"}{$z}
Truth table50%1/2
A
A= $$p{"zutat"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 6 | ▶ | if ( !defined $p->{menge} || $p->{menge} eq '' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $$p{"menge"} or $$p{"menge"} eq ""
MC/DC50%1/2
not defined $$p{"menge"} or $$p{"menge"} eq ""
not defined $$p{"menge"}
$$p{"menge"} eq ""
Truth table66%2/3
not(A) or B
A= not defined $$p{"menge"}B= $$p{"menge"} eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 1 | delete $dev->{liste}{$z}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 1 | return ( $z.' von der Liste gestrichen.', 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 5 | my ( $n, undef, $err ) = parse_amount( $self->_strip_name( $dev, $z, $p->{menge} ), $self->_base( $dev, $z ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 5 | ▶ | return ( 'Fehler: '.$err.'.', 0 ) if $err; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 4 | my $left = 0 + sprintf '%.3f', $dev->{liste}{$z} - $n; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 4 | ▶ | return ( 'Fehler: auf der Liste stehen nur '.$self->_show_amount( $dev, $z, $dev->{liste}{$z} ).'.', 0 ) if $left < 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 2 | ▶ | if ( $left == 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 1 | delete $dev->{liste}{$z}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 1 | return ( $z.' von der Liste gestrichen.', 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 1 | $dev->{liste}{$z} = $left; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 1 | return ( 'Auf der Liste: '.$z.' '.$self->_show_amount( $dev, $z, $left ), 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 7 | ▶ | sub _t_plan_lesen { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_t_plan_lesen: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 7 | my ( $self, $dev ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 7 | ▶ | my $p = $dev->{plan} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$$dev{'plan'} || {}
MC/DC100%1/1
$$dev{'plan'} || {}
$$dev{'plan'}
Truth table100%2/2
A
A= $$dev{'plan'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 7 | ▶ | my $r = $dev->{rezepte} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$$dev{'rezepte'} || {}
MC/DC100%1/1
$$dev{'rezepte'} || {}
$$dev{'rezepte'}
Truth table100%2/2
A
A= $$dev{'rezepte'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | my @l = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 7 | my $e = $p->{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 49 | ▶ | $e ? '- '.$_.': '.( ( $r->{ $e->{rezept} } || {} )->{titel} // $e->{rezept} ).' (ID '.$e->{rezept}.'), '.portions( $e->{portionen} ) : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
($$r{$$e{"rezept"}} || {})->{"titel"} // $$e{"rezept"}
$$r{$$e{'rezept'}} || {}
MC/DC0%0/2
($$r{$$e{"rezept"}} || {})->{"titel"} // $$e{"rezept"}
$$r{$$e{'rezept'}}
$$e{"rezept"}
Truth table66%2/3
A // B
A= $$r{$$e{'rezept'}}B= $$e{"rezept"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | } @DAYS; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 7 | ▶ | return ( @l ? join( "\n", @l ) : 'Der Wochenplan ist leer.', 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 7 | ▶ | sub _t_plan_setzen { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_t_plan_setzen: called CC=7 SCAR=19.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 7 | my ( $self, $dev, $p ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 7 | ▶ | my ($tag) = grep { lc $_ eq lc( $p->{tag} // '' ) } @DAYS; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$p{"tag"} // ""
MC/DC0%0/1
$$p{"tag"} // ""
$$p{"tag"}
Truth table50%1/2
A
A= $$p{"tag"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 7 | ▶ | return ( 'Fehler: Tag '.join( ', ', @DAYS ).'.', 0 ) unless $tag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | my $id = $self->_recipe( $dev, $p->{rezept} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 6 | ▶ | or return ( "Fehler: Rezept '".( $p->{rezept} // '' )."' nicht gefunden.", 0 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$$p{"rezept"} // ""
MC/DC0%0/1
$$p{"rezept"} // ""
$$p{"rezept"}
Truth table50%1/2
A
A= $$p{"rezept"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 2 | ▶ | my $por = $p->{portionen} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$p{"portionen"} // ""
MC/DC0%0/1
$$p{"portionen"} // ""
$$p{"portionen"}
Truth table50%1/2
A
A= $$p{"portionen"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 2 | ▶ | my ($n) = "$por" =~ /\A\s*([1-9]\d{0,2})\s*\z/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | or return ( 'Fehler: Portionen als ganze Zahl ab 1.', 0 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 1 | $dev->{plan}{$tag} = { rezept => $id, portionen => 0 + $n }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 1 | return ( $tag.': '.$dev->{rezepte}{$id}{titel}.', '.portions($n).'.', 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 40 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||