line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Toodledo::InfoCache; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
50
|
use Moose; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
63
|
|
4
|
8
|
|
|
8
|
|
46816
|
use MooseX::Method::Signatures; |
|
8
|
|
|
|
|
20
|
|
|
8
|
|
|
|
|
64
|
|
5
|
8
|
|
|
8
|
|
1563
|
use YAML qw(LoadFile DumpFile); |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
451
|
|
6
|
8
|
|
|
8
|
|
2272
|
use App::Toodledo::Util qw(debug); |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
426
|
|
7
|
8
|
|
|
8
|
|
54
|
use Log::Log4perl; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
71
|
|
8
|
|
|
|
|
|
|
with 'MooseX::Log::Log4perl'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has filename => ( is => 'rw', isa => 'Str', ); |
11
|
|
|
|
|
|
|
has password_ref => ( is => 'rw', isa => 'HashRef[Str]', |
12
|
|
|
|
|
|
|
default => sub { {} } ); |
13
|
|
|
|
|
|
|
has app_token_ref => ( is => 'rw', isa => 'HashRef[Str]', |
14
|
|
|
|
|
|
|
default => sub { {} } ); |
15
|
|
|
|
|
|
|
has default_user_id => ( is => 'rw', isa => 'Str' ); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
8
|
|
|
8
|
|
494390
|
method new_from_file ( $class: Str $file! ) { |
19
|
|
|
|
|
|
|
if ( -r $file && -f $file) |
20
|
|
|
|
|
|
|
{ |
21
|
|
|
|
|
|
|
my $ref = LoadFile( $file ); |
22
|
|
|
|
|
|
|
my ($password_ref, $app_token_ref, $default_user_id) |
23
|
|
|
|
|
|
|
= @{$ref}{qw(passwords app_tokens default_user_id)}; |
24
|
|
|
|
|
|
|
my $log = Log::Log4perl->get_logger(); |
25
|
|
|
|
|
|
|
$log->debug("Loaded info cache from $file"); |
26
|
|
|
|
|
|
|
return $class->new( filename => $file, |
27
|
|
|
|
|
|
|
password_ref => $password_ref, |
28
|
|
|
|
|
|
|
app_token_ref => $app_token_ref, |
29
|
|
|
|
|
|
|
default_user_id => $default_user_id ); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
else |
32
|
|
|
|
|
|
|
{ |
33
|
|
|
|
|
|
|
return $class->new( filename => $file ); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
8
|
|
|
8
|
|
341159
|
method save_to_file ( Str $filename! ) { |
39
|
|
|
|
|
|
|
my %params = ( passwords => $self->password_ref, |
40
|
|
|
|
|
|
|
app_tokens => $self->app_token_ref, |
41
|
|
|
|
|
|
|
default_user_id => $self->default_user_id ); |
42
|
|
|
|
|
|
|
DumpFile( $filename, \%params ); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
8
|
|
|
8
|
|
159140
|
method save () { |
47
|
|
|
|
|
|
|
$self->log->debug("test"); |
48
|
|
|
|
|
|
|
$self->save_to_file( $self->filename ); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
__END__ |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 NAME |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 SYNOPSIS |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 DESCRIPTION |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Store information for making calls easier. Used for storing |
63
|
|
|
|
|
|
|
username => password mapping and app_id => app_token mappings. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 AUTHOR |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Peter Scott C<cpan at psdt.com> |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=cut |