line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::Google::Docs::Upload; |
2
|
1
|
|
|
1
|
|
498
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use WWW::Mechanize; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has email => ( is => 'rw', required => 1 ); |
9
|
|
|
|
|
|
|
has passwd => ( is => 'rw', required => 1 ); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has mech => ( |
12
|
|
|
|
|
|
|
is => 'rw', |
13
|
|
|
|
|
|
|
isa => 'WWW::Mechanize', |
14
|
|
|
|
|
|
|
default => sub { |
15
|
|
|
|
|
|
|
my $mech = WWW::Mechanize->new( stack_depth => 1 ); |
16
|
|
|
|
|
|
|
$mech->env_proxy; |
17
|
|
|
|
|
|
|
$mech->agent_alias('Windows IE 6'); |
18
|
|
|
|
|
|
|
$mech->timeout(10); |
19
|
|
|
|
|
|
|
$mech; |
20
|
|
|
|
|
|
|
}, |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub upload { |
24
|
|
|
|
|
|
|
my ($self, $file, $option) = @_; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
confess q{required filename to upload} unless $file; |
27
|
|
|
|
|
|
|
confess qq{no such file "$file"} unless -e $file && -f _; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my $mech = $self->mech; |
30
|
|
|
|
|
|
|
$mech->get('http://docs.google.com/DocAction?action=updoc&hl=en'); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
if ($mech->res->base =~ /ServiceLogin/) { |
33
|
|
|
|
|
|
|
$mech->submit_form( |
34
|
|
|
|
|
|
|
fields => { |
35
|
|
|
|
|
|
|
Email => $self->email, |
36
|
|
|
|
|
|
|
Passwd => $self->passwd, |
37
|
|
|
|
|
|
|
}, |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
$mech->follow_link( tag => 'meta' ); |
40
|
|
|
|
|
|
|
confess 'login failed' unless $mech->res->base->host eq 'docs.google.com'; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
$mech->submit_form( |
44
|
|
|
|
|
|
|
fields => { |
45
|
|
|
|
|
|
|
uploadedFile => $file, |
46
|
|
|
|
|
|
|
$option->{name} ? (DocName => $option->{name}) : (), |
47
|
|
|
|
|
|
|
}, |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
$mech->res; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 NAME |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
WWW::Google::Docs::Upload - Upload documents to Google Docs |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 SYNOPSIS |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
use WWW::Google::Docs::Upload; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
my $docs = WWW::Google::Docs::Upload->new( |
62
|
|
|
|
|
|
|
email => 'your email', |
63
|
|
|
|
|
|
|
passwd => 'your password' |
64
|
|
|
|
|
|
|
); |
65
|
|
|
|
|
|
|
$docs->upload('/path/to/yourfile.doc'); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 DESCRIPTION |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
This module helps you to upload your local document files to Google Docs. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 METHODS |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head2 upload($filename, \%option) |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Upload document file (named $filename) to Google Docs. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
\%option is hashref and allowed key is: |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=over 4 |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=item name |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Filename what you want to call (if different than the filename) |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=back |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 AUTHOR |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Daisuke Murase <typester@cpan.org> |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 COPYRIGHT |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
This program is free software; you can redistribute |
94
|
|
|
|
|
|
|
it and/or modify it under the same terms as Perl itself. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
The full text of the license can be found in the |
97
|
|
|
|
|
|
|
LICENSE file included with this module. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=cut |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
1; |