line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::HTTP::Spore::Role; |
2
|
|
|
|
|
|
|
$Net::HTTP::Spore::Role::VERSION = '0.08'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Role to easily add multiples Spore clients to your class |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
2095
|
use MooseX::Role::Parameterized 1.01; |
|
1
|
|
|
|
|
80671
|
|
|
1
|
|
|
|
|
5
|
|
6
|
1
|
|
|
1
|
|
31844
|
use Net::HTTP::Spore; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
188
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
parameter spore_clients => (isa => 'ArrayRef[HashRef]', required => 1); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
role { |
11
|
|
|
|
|
|
|
my $p = shift; |
12
|
|
|
|
|
|
|
my $clients = $p->spore_clients; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
foreach my $client (@$clients) { |
15
|
|
|
|
|
|
|
my $name = $client->{name}; |
16
|
|
|
|
|
|
|
my $config = $client->{config}; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has $name => ( |
19
|
|
|
|
|
|
|
is => 'rw', |
20
|
|
|
|
|
|
|
isa => 'Object', |
21
|
|
|
|
|
|
|
lazy => 1, |
22
|
|
|
|
|
|
|
default => sub { |
23
|
|
|
|
|
|
|
my $self = shift; |
24
|
|
|
|
|
|
|
my $client_config = $self->$config; |
25
|
|
|
|
|
|
|
my $client = Net::HTTP::Spore->new_from_spec( |
26
|
|
|
|
|
|
|
$client_config->{spec}, |
27
|
|
|
|
|
|
|
%{ $client_config->{options} }, |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
foreach my $mw ( @{ $client_config->{middlewares} } ) { |
30
|
|
|
|
|
|
|
my %options = %{$mw->{options} || {}}; |
31
|
|
|
|
|
|
|
$client->enable( $mw->{name}, %options); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
$client; |
34
|
|
|
|
|
|
|
}, |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
has $config => ( |
38
|
|
|
|
|
|
|
is => 'rw', |
39
|
|
|
|
|
|
|
isa => 'HashRef', |
40
|
|
|
|
|
|
|
lazy => 1, |
41
|
|
|
|
|
|
|
default => sub { {} }, |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
}; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__END__ |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=pod |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=encoding UTF-8 |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 NAME |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Net::HTTP::Spore::Role - Role to easily add multiples Spore clients to your class |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 VERSION |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
version 0.08 |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 SYNOPSIS |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
package my::app; |
65
|
|
|
|
|
|
|
use Moose; |
66
|
|
|
|
|
|
|
with Net::HTTP::Spore::Role => |
67
|
|
|
|
|
|
|
{ spore_clients => [ name => 'twitter', config => 'twitter_config' ] }; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
... |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
my $app = my::app->new(twitter_config => $config->{spore}->{twitter_config}); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 DESCRIPTION |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
This is a role you can apply to your class. This role let you create a Spore client with a specific configuration. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 AUTHORS |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=over 4 |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=item * |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Franck Cuny <franck.cuny@gmail.com> |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=item * |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Ash Berlin <ash@cpan.org> |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=item * |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Ahmad Fatoum <athreef@cpan.org> |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=back |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
This software is copyright (c) 2012 by Linkfluence. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
100
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |