line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Sweet::SFTP; |
2
|
1
|
|
|
1
|
|
2834952
|
use v5.12; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
65
|
|
3
|
1
|
|
|
1
|
|
282
|
use Moose; |
|
1
|
|
|
|
|
275921
|
|
|
1
|
|
|
|
|
6
|
|
4
|
1
|
|
|
1
|
|
4483
|
use namespace::autoclean; |
|
1
|
|
|
|
|
994
|
|
|
1
|
|
|
|
|
4
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
41
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
44
|
|
7
|
1
|
|
|
1
|
|
5
|
use Try::Tiny; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
39
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
607
|
use Net::SFTP::Foreign; |
|
1
|
|
|
|
|
32376
|
|
|
1
|
|
|
|
|
8
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has hostname => ( |
12
|
|
|
|
|
|
|
builder => '_build_hostname', |
13
|
|
|
|
|
|
|
is => 'ro', |
14
|
|
|
|
|
|
|
isa => 'Str', |
15
|
|
|
|
|
|
|
lazy => 1, |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has username => ( |
19
|
|
|
|
|
|
|
builder => '_build_username', |
20
|
|
|
|
|
|
|
is => 'ro', |
21
|
|
|
|
|
|
|
isa => 'Str', |
22
|
|
|
|
|
|
|
lazy => 1, |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has password => ( |
26
|
|
|
|
|
|
|
builder => '_build_username', |
27
|
|
|
|
|
|
|
is => 'ro', |
28
|
|
|
|
|
|
|
isa => 'Str', |
29
|
|
|
|
|
|
|
lazy => 1, |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
has session => ( |
33
|
|
|
|
|
|
|
builder => '_build_session', |
34
|
|
|
|
|
|
|
is => 'ro', |
35
|
|
|
|
|
|
|
isa => 'Net::SFTP::Foreign', |
36
|
|
|
|
|
|
|
lazy => 1, |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub _build_session { |
40
|
0
|
|
|
0
|
|
|
my $self = shift; |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
my $hostname = $self->hostname; |
43
|
0
|
|
|
|
|
|
my $username = $self->username; |
44
|
0
|
|
|
|
|
|
my $password = $self->password; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
my $session = try { |
47
|
0
|
|
|
0
|
|
|
Net::SFTP::Foreign->new( |
48
|
|
|
|
|
|
|
$hostname, |
49
|
|
|
|
|
|
|
user => $username, |
50
|
|
|
|
|
|
|
password => $password, |
51
|
|
|
|
|
|
|
autodie => 1, |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
catch { |
55
|
0
|
|
|
0
|
|
|
croak "Couldn't open SFTP session: $_"; |
56
|
0
|
|
|
|
|
|
}; |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
return $session; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
__END__ |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 NAME |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Sweet::SFTP |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 SYNOPSIS |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
use Sweet::SFTP; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
my $sftp = Sweet::SFTP->new( |
76
|
|
|
|
|
|
|
hostname => 'sftp.example.org', |
77
|
|
|
|
|
|
|
username => 'foo', |
78
|
|
|
|
|
|
|
password => 'secr3t', |
79
|
|
|
|
|
|
|
); |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
my $session = $sftp->session; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head2 session |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Instance of L<Net::SFTP::Foreign>. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head2 hostname |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Has builder C<_build_hostname>. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head2 username |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Has builder C<_build_username>. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 password |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Has builder C<_build_password>. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 PRIVATE METHODS |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head2 _build_session |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
The L</session> builder. To be overridden in subclasses, if needed. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=cut |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|