| 1 | 1 | ▶ | use 5.008; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | package Data::Conveyor::YAML::Active::Payload::Instruction::Container; | ||||||||||||||||||||||||||||
| 6 | 1 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 1 | $Data::Conveyor::YAML::Active::Payload::Instruction::Container::VERSION = '1.103130'; | |||||||||||||||||||||||||||
| 8 | } | ||||||||||||||||||||||||||||
| 9 | # ABSTRACT: Stage-based conveyor-belt-like ticket handling system | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use YAML::Active qw/assert_arrayref array_activate/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use YAML; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | # FIXME cleanup: this seems to generate an array reference. later on, somebody | ||||||||||||||||||||||||||||
| 15 | # tries to call ->__phase on that array reference, which doesn't work | ||||||||||||||||||||||||||||
| 16 | # (warning: pseudo-hashes are deprecated; error: no such element '__phase' in | ||||||||||||||||||||||||||||
| 17 | # pseudo-hash or something like that) | ||||||||||||||||||||||||||||
| 18 | # | ||||||||||||||||||||||||||||
| 19 | # it seems to work that way, but I don't know if it's perfect. | ||||||||||||||||||||||||||||
| 20 | # for my $spec ($self->__array) { | ||||||||||||||||||||||||||||
| 21 | # gr's version | ||||||||||||||||||||||||||||
| 22 | #use YAML::Active qw/assert_hashref hash_activate/; | ||||||||||||||||||||||||||||
| 23 | #use parent 'Class::Scaffold::YAML::Active::Array'; | ||||||||||||||||||||||||||||
| 24 | # | ||||||||||||||||||||||||||||
| 25 | #sub run_plugin { | ||||||||||||||||||||||||||||
| 26 | # my $self = shift; | ||||||||||||||||||||||||||||
| 27 | # $self->SUPER::run_plugin(@_); | ||||||||||||||||||||||||||||
| 28 | # | ||||||||||||||||||||||||||||
| 29 | # my $instruction_container = | ||||||||||||||||||||||||||||
| 30 | # $self->delegate->make_obj('payload_instruction_container'); | ||||||||||||||||||||||||||||
| 31 | # | ||||||||||||||||||||||||||||
| 32 | # my $instruction_factory = | ||||||||||||||||||||||||||||
| 33 | # $self->delegate->make_obj('payload_instruction_factory'); | ||||||||||||||||||||||||||||
| 34 | # my version | ||||||||||||||||||||||||||||
| 35 | 1 | ▶ | use parent 'Class::Scaffold::YAML::Active'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 0 | ▶ | sub yaml_activate { | ||||||||||||||||||||||||||
|
Subroutine
yaml_activate: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||
| 38 | 0 | my ($self, $phase) = @_; | |||||||||||||||||||||||||||
| 39 | 0 | assert_arrayref($self); | |||||||||||||||||||||||||||
| 40 | 0 | my $array = array_activate($self, $phase); | |||||||||||||||||||||||||||
| 41 | 0 | my $instruction_container = | |||||||||||||||||||||||||||
| 42 | $self->delegate->make_obj('payload_instruction_container'); | ||||||||||||||||||||||||||||
| 43 | 0 | ▶ | our $instruction_factory ||= | ||||||||||||||||||||||||||
|
Condition0%0/3
our $instruction_factory ||= $self->delegate->make_obj("payload_instruction_factory")
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")
| |||||||||||||||||||||||||||||
| 44 | $self->delegate->make_obj('payload_instruction_factory'); | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | # expect an ordered list of instructions, each with name and value. The | ||||||||||||||||||||||||||||
| 47 | # YAML::Active plugin uses the payload_instruction_factory to | ||||||||||||||||||||||||||||
| 48 | # generate the right instruction object, then sets the value on it | ||||||||||||||||||||||||||||
| 49 | # and inserts it into the container. The name is prepended by 'u-' | ||||||||||||||||||||||||||||
| 50 | # for IC_UPDATE, 'a-' for IC_ADD and 'd-' for IC_DELETE to provide a | ||||||||||||||||||||||||||||
| 51 | # concise notation. | ||||||||||||||||||||||||||||
| 52 | # | ||||||||||||||||||||||||||||
| 53 | # Example: | ||||||||||||||||||||||||||||
| 54 | # | ||||||||||||||||||||||||||||
| 55 | # - u-value_person_company_no: &COMPANYNO 1234 | ||||||||||||||||||||||||||||
| 56 | # - u-value_person_name_title: &TITLE Grunz | ||||||||||||||||||||||||||||
| 57 | # - u-value_person_name_firstname: &FIRSTNAME Franz | ||||||||||||||||||||||||||||
| 58 | # - u-value_person_name_lastname: &LASTNAME Testler | ||||||||||||||||||||||||||||
| 59 | # - a-value_person_email_address: &EMAIL fh@univie.ac.at | ||||||||||||||||||||||||||||
| 60 | # - a-value_person_fax_number: &FAX1 '+4311234566' | ||||||||||||||||||||||||||||
| 61 | # - a-value_person_fax_number: &FAX2 '+431242342343' | ||||||||||||||||||||||||||||
| 62 | 0 | for my $spec (@$array) { | |||||||||||||||||||||||||||
| 63 | 0 | ▶ | unless (ref $spec eq 'HASH' && scalar(keys %$spec) == 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $spec eq "HASH" and scalar keys %$spec == 1
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
| |||||||||||||||||||||||||||||
| 64 | 0 | throw Error::Hierarchy::Internal::CustomMessage(custom_message => | |||||||||||||||||||||||||||
| 65 | "expected a single-item hash with the instruction, got:\n" | ||||||||||||||||||||||||||||
| 66 | . Dump($spec)); | ||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | 0 | my ($key, $value) = %$spec; | |||||||||||||||||||||||||||
| 69 | 0 | ▶ | if ($key eq 'clear') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | 0 | $instruction_container->items_push( | |||||||||||||||||||||||||||
| 71 | $instruction_factory->gen_instruction('clear')); | ||||||||||||||||||||||||||||
| 72 | 0 | next; | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | 0 | ▶ | unless ($key =~ /^([a-z])-(.*)/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 75 | 0 | throw Error::Hierarchy::Internal::CustomMessage( | |||||||||||||||||||||||||||
| 76 | custom_message => "can't parse instruction key [$key]"); | ||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | 0 | my ($abbrev_command, $type) = ($1, $2); | |||||||||||||||||||||||||||
| 79 | 0 | ▶ | my $command = $self->word_complete($abbrev_command, $self->delegate->IC) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 80 | or throw Error::Hierarchy::Internal::CustomMessage(custom_message => | ||||||||||||||||||||||||||||
| 81 | "can't determine instruction command from [$abbrev_command]"); | ||||||||||||||||||||||||||||
| 82 | 0 | $instruction_container->items_push( | |||||||||||||||||||||||||||
| 83 | $instruction_factory->gen_instruction( | ||||||||||||||||||||||||||||
| 84 | $type, | ||||||||||||||||||||||||||||
| 85 | command => $command, | ||||||||||||||||||||||||||||
| 86 | value => $value, | ||||||||||||||||||||||||||||
| 87 | ) | ||||||||||||||||||||||||||||
| 88 | ); | ||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | 0 | $instruction_container; | |||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 0 | ▶ | sub word_complete { | ||||||||||||||||||||||||||
|
Subroutine
word_complete: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 94 | 0 | my ($self, $word, @candidates) = @_; | |||||||||||||||||||||||||||
| 95 | 0 | for (@candidates) { | |||||||||||||||||||||||||||
| 96 | 0 | ▶ | return $_ if index($_, $word) == 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | 1 | 1; | |||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | __END__ | ||||||||||||||||||||||||||||