File Coverage

blib/lib/Business/UPS/Tracking/Role/Builder.pm
Criterion Covered Total %
statement 23 39 58.9
branch 0 8 0.0
condition 0 12 0.0
subroutine 8 12 66.6
pod 4 4 100.0
total 35 75 46.6


line stmt bran cond sub pod time code
1             # ============================================================================
2             package Business::UPS::Tracking::Role::Builder;
3             # ============================================================================
4 1     1   485 use utf8;
  1         3  
  1         7  
5 1     1   37 use 5.0100;
  1         4  
6              
7 1     1   5 use Moose::Role;
  1         2  
  1         11  
8             #requires('xml');
9              
10 1     1   6096 use Business::UPS::Tracking::Element::Address;
  1         6  
  1         45  
11 1     1   570 use Business::UPS::Tracking::Element::Weight;
  1         4  
  1         39  
12 1     1   526 use Business::UPS::Tracking::Element::ReferenceNumber;
  1         4  
  1         39  
13 1     1   9 use Business::UPS::Tracking::Element::Code;
  1         2  
  1         217  
14              
15             =encoding utf8
16              
17             =head1 NAME
18              
19             Business::UPS::Tracking::Role::Builder - Helper role
20              
21             =head1 DESCRIPTION
22              
23             This role provides methods that construct various objects (eg.
24             Business::UPS::Tracking::Element::Address).
25              
26             =head1 METHODS
27              
28             =head3 build_address
29              
30             my $address = $self->build_address($xpath_expression);
31              
32             Turns an address xml node into a L<Business::UPS::Tracking::Element::Address>
33             object.
34              
35             =cut
36              
37             sub build_address {
38 0     0 1   my ($self,$xpath) = @_;
39              
40 0           my $node = $self->xml->findnodes($xpath)->get_node(1);
41              
42             return
43 0 0 0       unless $node && ref $node;
44              
45 0           return Business::UPS::Tracking::Element::Address->new(
46             xml => $node,
47             );
48             }
49              
50             =head3 build_code
51              
52             my $address = $self->build_code($xpath_expression);
53              
54             Turns an address xml node into a L<Business::UPS::Tracking::Element::Address>
55             object.
56              
57             =cut
58              
59              
60             sub build_code {
61 0     0 1   my ($self,$xpath) = @_;
62              
63 0           my $node = $self->xml->findnodes($xpath)->get_node(1);
64              
65             return
66 0 0 0       unless $node && ref $node;
67              
68 0           return Business::UPS::Tracking::Element::Code->new(
69             xml => $node,
70             );
71             }
72              
73             =head3 build_weight
74              
75             my $weight = $self->build_weight($xpath_expression);
76              
77             Turns an weight xml node into a L<Business::UPS::Tracking::Element::Weight>
78             object.
79              
80             =cut
81              
82             sub build_weight {
83 0     0 1   my ($self,$xpath) = @_;
84              
85 0           my $node = $self->xml->findnodes($xpath)->get_node(1);
86              
87             return
88 0 0 0       unless $node && ref $node;
89              
90 0           return Business::UPS::Tracking::Element::Weight->new(
91             xml => $node,
92             );
93             }
94              
95             =head3 build_referencenumber
96              
97             my $weight = $self->build_referencenumber($xpath_expression);
98              
99             Turns an weight xml node into a
100             L<Business::UPS::Tracking::Element::ReferenceNumber> object.
101              
102             =cut
103              
104             sub build_referencenumber {
105 0     0 1   my ($self,$xpath) = @_;
106              
107 0           my $node = $self->xml->findnodes($xpath)->get_node(1);
108              
109             return
110 0 0 0       unless $node && ref $node;
111              
112 0           return Business::UPS::Tracking::Element::ReferenceNumber->new(
113             xml => $node,
114             );
115             }
116              
117 1     1   8 no Moose::Role;
  1         2  
  1         9  
118             1;