File Coverage

blib/lib/Acme/Resume/Moose.pm
Criterion Covered Total %
statement 57 57 100.0
branch 4 4 100.0
condition n/a
subroutine 17 17 100.0
pod 0 6 0.0
total 78 84 92.8


line stmt bran cond sub pod time code
1 1     1   13 use 5.14.0;
  1         4  
2 1     1   6 use strict;
  1         1  
  1         25  
3 1     1   5 use warnings;
  1         1  
  1         54  
4              
5             package Acme::Resume::Moose;
6              
7             # ABSTRACT: Imports methods and adds attributes
8             our $VERSION = '0.0104';
9              
10 1     1   594 use Moose::Exporter;
  1         153173  
  1         6  
11 1     1   503 use Acme::Resume::Types::Job;
  1         3  
  1         52  
12 1     1   560 use Acme::Resume::Types::Education;
  1         3  
  1         52  
13              
14 1     1   8 use Types::Standard -types;
  1         2  
  1         5  
15 1     1   5276 use Acme::Resume::Types -types;
  1         3  
  1         5  
16              
17             Moose::Exporter->setup_import_methods(with_meta => [qw/name email phone address education job/]);
18              
19             sub name {
20 1     1 0 50366 my $meta = shift;
21 1         11 $meta->add_attribute(name => (
22             is => 'ro',
23             isa => Str,
24             default => shift,
25             ));
26             }
27             sub email {
28 1     1 0 3843 my $meta = shift;
29 1         9 $meta->add_attribute(email => (
30             is => 'ro',
31             isa => Str,
32             default => shift,
33             ));
34             }
35             sub phone {
36 1     1 0 307808 my $meta = shift;
37 1         11 $meta->add_attribute(phone => (
38             is => 'ro',
39             isa => Str,
40             default => shift,
41             ));
42             }
43             sub address {
44 1     1 0 3498 my $meta = shift;
45 1         3 my $address = shift;
46              
47             $meta->add_attribute(address => (
48             is => 'ro',
49             isa => ArrayRef[Str],
50 1     1   274 default => sub { $address },
51 1         8 traits => ['Array'],
52             handles => {
53             add_address => 'push',
54             full_address => 'elements',
55             has_address => 'count',
56             get_address => 'get',
57             join_address => 'join',
58             },
59             ));
60             }
61              
62             sub education {
63 3     3 0 48529 my $meta = shift;
64 3         8 my $education = shift;
65              
66 3         10 my $current_educations = [];
67              
68 3 100       18 if($meta->has_attribute('educations')) {
69 2         35 push @$current_educations => @{ $meta->get_attribute('educations')->default->() };
  2         36  
70 2         15 $meta->remove_attribute('educations');
71             }
72              
73 3         1708 push @{ $current_educations } => Acme::Resume::Types::Education->new(%{ $education });
  3         27  
  3         47  
74              
75             $meta->add_attribute(educations => (
76             is => 'ro',
77             isa => Educations,
78             traits => ['Array'],
79 3     3   92 default => sub { $current_educations },
80 3         27 coerce => 1,
81             handles => {
82             add_education => 'push',
83             all_educations => 'elements',
84             has_education => 'count',
85             get_education => 'get',
86             },
87             ));
88             }
89              
90             sub job {
91 2     2 0 43526 my $meta = shift;
92 2         7 my $job = shift;
93              
94 2         6 my $current_jobs = [];
95              
96 2 100       13 if($meta->has_attribute('jobs')) {
97 1         17 push @$current_jobs => @{ $meta->get_attribute('jobs')->default->() };
  1         6  
98 1         6 $meta->remove_attribute('jobs');
99             }
100              
101 2         763 push @{ $current_jobs } => Acme::Resume::Types::Job->new(%{ $job });
  2         17  
  2         27  
102              
103             $meta->add_attribute(jobs => (
104             is => 'ro',
105             isa => Jobs,
106             traits => ['Array'],
107 2     2   80 default => sub { $current_jobs },
108 2         18 coerce => 1,
109             handles => {
110             add_job => 'push',
111             all_jobs => 'elements',
112             has_job_history => 'count',
113             get_job => 'get',
114             },
115             ));
116             }
117              
118             1;
119              
120             __END__
121              
122             =pod
123              
124             =encoding UTF-8
125              
126             =head1 NAME
127              
128             Acme::Resume::Moose - Imports methods and adds attributes
129              
130             =head1 VERSION
131              
132             Version 0.0104, released 2021-08-31.
133              
134             =head1 SOURCE
135              
136             L<https://github.com/Csson/p5-Acme-Resume>
137              
138             =head1 HOMEPAGE
139              
140             L<https://metacpan.org/release/Acme-Resume>
141              
142             =head1 AUTHOR
143              
144             Erik Carlsson <info@code301.com>
145              
146             =head1 COPYRIGHT AND LICENSE
147              
148             This software is copyright (c) 2021 by Erik Carlsson.
149              
150             This is free software; you can redistribute it and/or modify it under
151             the same terms as the Perl 5 programming language system itself.
152              
153             =cut