File Coverage

blib/lib/Cogit/Object/Tag.pm
Criterion Covered Total %
statement 9 25 36.0
branch 0 4 0.0
condition 0 3 0.0
subroutine 3 4 75.0
pod 0 1 0.0
total 12 37 32.4


line stmt bran cond sub pod time code
1             package Cogit::Object::Tag;
2             $Cogit::Object::Tag::VERSION = '0.001001';
3 4     4   19 use Moo;
  4         6  
  4         28  
4 4     4   8114 use MooX::Types::MooseLike::Base 'Str', 'InstanceOf';
  4         6  
  4         253  
5 4     4   17 use namespace::clean;
  4         4  
  4         32  
6              
7             extends 'Cogit::Object';
8              
9             has '+kind' => ( default => sub { 'tag' } );
10              
11             has object => (
12             is => 'rw',
13             isa => Str,
14             );
15              
16             has tag => (
17             is => 'rw',
18             isa => Str,
19             );
20              
21             has tagger => (
22             is => 'rw',
23             isa => InstanceOf['Cogit::Actor'],
24             );
25              
26             has tagged_time => (
27             is => 'rw',
28             isa => InstanceOf['DateTime'],
29             );
30              
31             has comment => (
32             is => 'rw',
33             isa => Str,
34             );
35              
36             has object_kind => (
37             is => 'rw',
38             isa => sub {
39             die "$_[0] is not a valid object type" unless $_[0] =~ m/commit|tree|blob|tag/
40             },
41             );
42              
43             my %method_map = (type => 'object_kind');
44              
45             sub BUILD {
46 0     0 0   my $self = shift;
47 0           my @lines = split "\n", $self->content;
48 0           while ( my $line = shift @lines ) {
49 0 0         last unless $line;
50 0           my ( $key, $value ) = split ' ', $line, 2;
51              
52 0 0         if ($key eq 'tagger') {
53 0           my @data = split ' ', $value;
54 0           my ($email, $epoch, $tz) = splice(@data, -3);
55 0           my $name = join(' ', @data);
56 0           my $actor =
57             Cogit::Actor->new( name => $name, email => $email );
58 0           $self->tagger($actor);
59 0           my $dt= DateTime->from_epoch( epoch => $epoch, time_zone => $tz );
60 0           $self->tagged_time($dt);
61             } else {
62 0   0       my $method = $method_map{$key} || $key;
63 0           $self->$method($value);
64             }
65             }
66 0           $self->comment( join "\n", @lines );
67             }
68              
69             1;
70              
71             __END__
72              
73             =pod
74              
75             =encoding UTF-8
76              
77             =head1 NAME
78              
79             Cogit::Object::Tag
80              
81             =head1 VERSION
82              
83             version 0.001001
84              
85             =head1 AUTHOR
86              
87             Arthur Axel "fREW" Schmidt <cogit@afoolishmanifesto.com>
88              
89             =head1 COPYRIGHT AND LICENSE
90              
91             This software is copyright (c) 2017 by Arthur Axel "fREW" Schmidt.
92              
93             This is free software; you can redistribute it and/or modify it under
94             the same terms as the Perl 5 programming language system itself.
95              
96             =cut