blib/lib/WebService/MyGengo/Revision.pm untested

filter: Statementstmt 0.0% 0 / 20 Branchbran n/a Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 30 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
id
2.0
BEGIN
2.0
CRAP 2.0
1 package WebService::MyGengo::Revision;
2  
3 use Moose;
4  
5 BEGIN { extends 'WebService::MyGengo::Base' };
6  
7 # Stringify to the comment body
8 use overload ( '""' => sub { shift->body_tgt } );
9  
10 =head1 NAME
11  
12 WebService::MyGengo::Revision - A Revision in the myGengo system.
13  
14 =head1 SYNOPSIS
15  
16 # Note: Revisions can't actually be submitted via API,
17 # so creating one by hand is only useful for testing
18 my $rev = WebService::MyGengo::Revision->new( { body_tgt => 'Hello.' } );
19 # or
20 $rev = WebService::MyGengo::Revision->new( 'Hello.' );
21  
22 # Elsewhere...
23 my @revs = $client->get_job_revisions( $job->id );
24  
25 # $body_tgt eq 'Hello.'
26 my $body_tgt = "$revs[0]"; # Overloads stringification to ->body_tgt
27  
28 =head1 ATTRIBUTES
29  
30 =head2 rev_id|id (Int)
31  
32 A unique identifier for this Revision.
33  
34 =cut
35 sub id { shift->rev_id }
36 has 'rev_id' => (
37 is => 'ro'
38 , isa => 'Int'
39 , required => 1
40 );
41  
42 =head2 body_tgt (Src)
43  
44 The translation results.
45  
46 Sometimes the API returns 'null' (undef) for this value. In this case
47 the value will be coerced into an empty string.
48  
49 =cut
50 has 'body_tgt' => (
51 is => 'ro'
52 , isa => 'WebService::MyGengo::body_tgt'
53 , coerce => 1
54 , required => 1
55 );
56  
57 =head2 ctime (DateTime)
58  
59 The L<DateTime> at which this Revision was created.
60  
61 This value is set by the API.
62  
63 =cut
64 has 'ctime' => (
65 is => 'ro'
66 , isa => 'WebService::MyGengo::DateTime'
67 , coerce => 1
68 );
69  
70 =head1 METHODS
71 =cut
72  
73 #=head2 around BUILDARGS
74 #
75 #Allow single-argument constructor for `body_tgt`
76 #
77 #=cut
78 around BUILDARGS => sub {
79 my ( $orig, $class, $val ) = ( @_ );
80 ref($val) eq 'HASH' and return $val;
81 return { body_tgt => $val };
82 };
83  
84  
85 no Moose;
86 __PACKAGE__->meta->make_immutable();
87  
88 1;
89  
90 =head2 SEE ALSO
91  
92 L<http://mygengo.com/api/developer-docs/methods/translate-job-id-revision-rev-id-get/>
93  
94 =head1 AUTHOR
95  
96 Nathaniel Heinrichs
97  
98 =head1 LICENSE
99  
100 Copyright (c) 2011, Nathaniel Heinrichs <nheinric-at-cpan.org>.
101 All rights reserved.
102  
103 This library is free software. You can redistribute it and/or modify
104 it under the same terms as Perl itself.
105  
106 =cut