line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OAuth::Lite2::Formatters; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
1146
|
use strict; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
155
|
|
4
|
6
|
|
|
6
|
|
21
|
use warnings; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
137
|
|
5
|
|
|
|
|
|
|
|
6
|
6
|
|
|
6
|
|
2350
|
use OAuth::Lite2::Formatter::JSON; |
|
6
|
|
|
|
|
18
|
|
|
6
|
|
|
|
|
216
|
|
7
|
6
|
|
|
6
|
|
2868
|
use OAuth::Lite2::Formatter::XML; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use OAuth::Lite2::Formatter::FormURLEncoded; |
9
|
|
|
|
|
|
|
use OAuth::Lite2::Formatter::Text; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my %FORMATTERS_BY_TYPE; |
12
|
|
|
|
|
|
|
my %FORMATTERS_BY_NAME; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub add_formatter { |
15
|
|
|
|
|
|
|
my ($class, $formatter) = @_; |
16
|
|
|
|
|
|
|
$FORMATTERS_BY_NAME{$formatter->name} = $formatter; |
17
|
|
|
|
|
|
|
$FORMATTERS_BY_TYPE{$formatter->type} = $formatter; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
__PACKAGE__->add_formatter( OAuth::Lite2::Formatter::JSON->new ); |
21
|
|
|
|
|
|
|
__PACKAGE__->add_formatter( OAuth::Lite2::Formatter::XML->new ); |
22
|
|
|
|
|
|
|
__PACKAGE__->add_formatter( OAuth::Lite2::Formatter::FormURLEncoded->new ); |
23
|
|
|
|
|
|
|
__PACKAGE__->add_formatter( OAuth::Lite2::Formatter::Text->new ); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub get_formatter_by_name { |
26
|
|
|
|
|
|
|
my ($class, $name) = @_; |
27
|
|
|
|
|
|
|
return unless $name; |
28
|
|
|
|
|
|
|
return $FORMATTERS_BY_NAME{$name}; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub get_formatter_by_type { |
32
|
|
|
|
|
|
|
my ($class, $type) = @_; |
33
|
|
|
|
|
|
|
return unless $type; |
34
|
|
|
|
|
|
|
return $FORMATTERS_BY_TYPE{$type}; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 NAME |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
OAuth::Lite2::Formatters - OAuth 2.0 formatters store |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 SYNOPSIS |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my $formatter = OAuth::Lite2::Formatter->get_formatter_by_name("json"); |
44
|
|
|
|
|
|
|
my $formatter = OAuth::Lite2::Formatter->get_formatter_by_type("application/json"); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
my $obj = $formatter->parse( $string ); |
47
|
|
|
|
|
|
|
$string = $formatter->format( $obj ); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 DESCRIPTION |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
OAuth 2.0 formatters store. |
52
|
|
|
|
|
|
|
from draft-v8, specification requires only JSON format. |
53
|
|
|
|
|
|
|
This library leaves the other formatters for interop. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 METHODS |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 get_formatter_by_name( $name ) |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 get_formatter_by_type( $content_type ) |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 SEE ALSO |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
L |
64
|
|
|
|
|
|
|
L |
65
|
|
|
|
|
|
|
L |
66
|
|
|
|
|
|
|
L |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 AUTHOR |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Lyo Kato, Elyo.kato@gmail.comE |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Copyright (C) 2010 by Lyo Kato |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
77
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.8 or, |
78
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |