Conveyor/YAML/Marshall/Payload/InstructionContainer.pm

filter: Statementstmt 52.7% 19 / 36 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 77.7% 7 / 9 Podpod 100% 2 / 2 totaltotal 43.0% 28 / 65 CC 9 SCAR 32.4
CC
9
Cov
38%
yaml_load
56.0
word_complete
12.0
BEGIN
1.0
CRAP 25.6
« Conveyor/Ticket/Provider.pm ↑ Summary Conveyor/App/Exported/Launcher.pm »
1 2 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Data::Conveyor::YAML::Marshall::Payload::InstructionContainer;
6 2 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 $Data::Conveyor::YAML::Marshall::Payload::InstructionContainer::VERSION = '1.103130';
8 }
9 # ABSTRACT: Stage-based conveyor-belt-like ticket handling system
10 2 ▶use YAML::Marshall 'payload/instructioncontainer';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use YAML 'Dump';
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use parent 'Class::Scaffold::YAML::Marshall';
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 0 ▶sub yaml_load {
Subroutine yaml_load: not called CC=7 SCAR=40.3
Pod documented
15 0 my $self = shift;
16 0 my $node = $self->SUPER::yaml_load(@_);
17 0 my $instruction_container =
18 $self->delegate->make_obj('payload_instruction_container');
19 0 ▶ our $instruction_factory ||=
Condition0%0/3
our $instruction_factory ||= $self->delegate->make_obj("payload_instruction_factory")
l!l&&r!l&&!r
000
MC/DC0%0/2
our $instruction_factory ||= $self->delegate->make_obj("payload_instruction_factory")
our $instruction_factory $self->delegate->make_obj("payload_instruction_factory")
Truth table0%0/3
A ||= B
A= our $instruction_factoryB= $self->delegate->make_obj("payload_instruction_factory")
ABresult
1X1
011
000
20 $self->delegate->make_obj('payload_instruction_factory');
21  
22 # expect an ordered list of instructions, each with name and value. The
23 # YAML::Active plugin uses the payload_instruction_factory to
24 # generate the right instruction object, then sets the value on it
25 # and inserts it into the container. The name is prepended by 'u-'
26 # for IC_UPDATE, 'a-' for IC_ADD and 'd-' for IC_DELETE to provide a
27 # concise notation.
28 #
29 # Example:
30 #
31 # - u-value_person_company_no: &COMPANYNO 1234
32 # - u-value_person_name_title: &TITLE Grunz
33 # - u-value_person_name_firstname: &FIRSTNAME Franz
34 # - u-value_person_name_lastname: &LASTNAME Testler
35 # - a-value_person_email_address: &EMAIL fh@univie.ac.at
36 # - a-value_person_fax_number: &FAX1 '+4311234566'
37 # - a-value_person_fax_number: &FAX2 '+431242342343'
38 # - clear: 1
39 # - foo: 1
40 0 for my $spec (@$node) {
41 0 ▶ unless (ref $spec eq 'HASH' && scalar(keys %$spec) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $spec eq "HASH" and scalar keys %$spec == 1) 0 0 0
Condition0%0/3
ref $spec eq "HASH" and scalar keys %$spec == 1
!ll&&!rl&&r
000
MC/DC0%0/2
ref $spec eq "HASH" and scalar keys %$spec == 1
ref $spec eq "HASH" scalar keys %$spec == 1
Truth table0%0/3
A and B
A= ref $spec eq "HASH"B= scalar keys %$spec == 1
ABresult
0X0
100
111
42 0 throw Error::Hierarchy::Internal::CustomMessage(custom_message =>
43 "expected a single-item hash with the instruction, got:\n"
44 . Dump($spec));
45 }
46 0 my ($key, $value) = %$spec;
47 0 ▶ if ($key =~ /^([a-z])-(.*)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($key =~ /^([a-z])-(.*)/) { } 0 0 0
48 0 my ($abbrev_command, $type) = ($1, $2);
49 0 ▶ my $command = $self->word_complete($abbrev_command, $self->delegate->IC)
Branch: 1 branch
BranchTrueFalseTotal
my $command = $self->word_complete($abbrev_command, $self->delegate->IC) or "Error::Hierarchy::Internal::CustomMessage"->throw("custom_message", "can't determine instruction command from [$abbrev_command]") 0 0 0
50 or throw Error::Hierarchy::Internal::CustomMessage(custom_message =>
51 "can't determine instruction command from [$abbrev_command]");
52 0 $instruction_container->items_push(
53 $instruction_factory->gen_instruction(
54 $type,
55 command => $command,
56 value => $value,
57 )
58 );
59 } else {
60 0 $instruction_container->items_push(
61 $instruction_factory->gen_instruction($key, value => $value));
62 }
63 }
64 0 $instruction_container;
65 }
66  
67 0 ▶sub word_complete {
Subroutine word_complete: not called CC=3 SCAR=24.8
Pod documented
68 0 my ($self, $word, @candidates) = @_;
69 0 for (@candidates) {
70 0 ▶ return $_ if index($_, $word) == 0;
Branch: 1 branch
BranchTrueFalseTotal
if index($_, $word) == 0 0 0 0
71 }
72 }
73 2 1;
74  
75  
76 __END__
« Conveyor/Ticket/Provider.pm ↑ Summary Conveyor/App/Exported/Launcher.pm »