PDF/File.pm

filter: Statementstmt 55.5% 20 / 36 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 60.0% 6 / 10 Podpod 100% 2 / 2 totaltotal 58.3% 28 / 48 CC 1 SCAR 3.4
CC
1
Cov
56%
new
2.0
save_to
2.0
_get_file
2.0
CRAP 1.4
« PDF.pm ↑ Summary
1 package WebService::Trynt::PDF::File;
2  
3 =head1 NAME
4  
5 WebService::Trynt::PDF::File - Interface to manage information about the file created with WebService::Trynt::PDF
6  
7 =head1 VERSION
8  
9 Version 0.01
10  
11 =cut
12  
13 2 our $VERSION = '0.01';
14  
15 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 2 ▶use XML::Simple;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 2 ▶use File::Temp;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 2 ▶use File::Copy;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 2 ▶use LWP::UserAgent;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 =head1 SYNOPSIS
23  
24 WebService::Trynt::PDF is an interface for Trynt Web Services, so you can convert an URL into a PDF file.
25  
26 use WebService::Trynt::PDF;
27  
28 my $trynt_ws = WebService::Trynt::PDF->new( url => "http://www.cnn.com", cache_flush => 0);
29 my $file = $trynt_ws->get();
30 $file->save_to("./cnn.pdf");
31  
32 or shortly
33  
34 my $trynt_ws = WebService::Trynt::PDF->new( url => "http://www.cnn.com");
35 $trynt_ws->get("./cnn.pdf");
36  
37 =cut
38  
39 =head1 FUNCTIONS
40  
41 =head2 new
42  
43 =cut
44  
45 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
46 0 my ( $class, $xml ) = @_;
47 0 my $self = bless {
48 _xml => $xml,
49 _tmp_file => File::Temp->new( UNLINK => 0 ),
50 }, $class;
51 0 $self->_parse_xml();
52 0 $self->_get_file();
53 0 $self;
54 }
55  
56 =head2 save_to
57  
58 =cut
59  
60 0 ▶sub save_to {
Subroutine save_to: not called CC=1 SCAR=6.9
Pod documented
61 0 my $self = shift;
62 0 my $filename = shift;
63  
64 0 move( $self->{_tmp_file}->filename, $filename );
65 }
66  
67 0 ▶sub _get_file {
Subroutine _get_file: not called CC=1 SCAR=6.9
68 0 my ($self) = @_;
69  
70 0 my $ua = LWP::UserAgent->new();
71 0 $ua->agent("WebService::Trynt::PDF/$VERSION");
72 0 $ua->get( $self->{url}, ':content_file' => $self->{_tmp_file}->filename );
73 }
74  
75 0 ▶sub _parse_xml {
Subroutine _parse_xml: not called CC=1 SCAR=6.9
76 0 my ($self) = @_;
77 0 my $xml = XMLin( $self->{_xml} );
78 0 $self->{md5} = $xml->{PDF}->{MD5};
79 0 $self->{url} = $xml->{PDF}->{PDF};
80 }
81  
82 =head1 AUTHOR
83  
84 Manu, C<< <<manu at bjornoya.net>> >>
85  
86 =head1 BUGS
87  
88 Please report any bugs or feature requests to
89 C<bug-webservice-trynt-pdf-file at rt.cpan.org>, or through the web interface at
90 L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WebService-Trynt-PDF>.
91 I will be notified, and then you'll automatically be notified of progress on
92 your bug as I make changes.
93  
94 =head1 SUPPORT
95  
96 You can find documentation for this module with the perldoc command.
97  
98 perldoc WebService::Trynt::PDF
99  
100 You can also look for information at:
101  
102 =over 4
103  
104 =item * AnnoCPAN: Annotated CPAN documentation
105  
106 L<http://annocpan.org/dist/WebService-Trynt-PDF>
107  
108 =item * CPAN Ratings
109  
110 L<http://cpanratings.perl.org/d/WebService-Trynt-PDF>
111  
112 =item * RT: CPAN's request tracker
113  
114 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=WebService-Trynt-PDF>
115  
116 =item * Search CPAN
117  
118 L<http://search.cpan.org/dist/WebService-Trynt-PDF>
119  
120 =back
121  
122 =head1 ACKNOWLEDGEMENTS
123  
124 =head1 COPYRIGHT & LICENSE
125  
126 Copyright 2006 Manu, all rights reserved.
127  
128 This program is free software; you can redistribute it and/or modify it
129 under the same terms as Perl itself.
130  
131 =cut
132  
133 2 1; # End of WebService::Trynt::PDF::File
« PDF.pm ↑ Summary