root/lang/perl/HTTP-MobileAttribute/trunk/lib/HTTP/MobileAttribute.pm @ 9059

Revision 9059, 3.7 kB (checked in by tokuhirom, 5 years ago)

lang/perl/HTTP-MobileAttribute?: Checking in changes prior to tagging of version 0.05. Changelog diff is:

=== Changes
==================================================================
--- Changes (revision 10477)
+++ Changes (local)
@@ -1,5 +1,12 @@

Revision history for Perl extension HTTP::MobileAttribute?


+0.05 It's beta.
+
+ - added Plugin::IS::DoCoMo?, Plugin::IS::EZweb(by clouder++)
+ - Plugin::Carrier was renamed to Plugin::CarrierLetter?
+ - added docs!
+ - added Agent::* and removed Plugin::Parser::*
+

0.04 still alpha.


  • default plugin is only Parser::*

Unknown target: CHANGES.

Line 
1package HTTP::MobileAttribute;
2use strict;
3use warnings;
4our $VERSION = '0.05';
5use HTTP::MobileAttribute::Request;
6use HTTP::MobileAttribute::CarrierDetector;
7use UNIVERSAL::require;
8
9# XXX: This really affects the first time H::MobileAttribute gets loaded
10sub import {
11    my $class   = shift;
12    my %args    = @_;
13    my $plugins = delete $args{plugins} || [ 'Core' ];
14
15    if (ref $plugins ne 'ARRAY') {
16        $plugins = [ $plugins ];
17    }
18    $class->load_plugins(@$plugins);
19}
20
21sub carriers { qw/DoCoMo AirHPhone ThirdForce EZweb NonMobile/ }
22
23BEGIN {
24    for (carriers()) {
25        "HTTP::MobileAttribute::Agent::$_"->use or die $@;
26    }
27};
28
29sub new {
30    my ($class, $stuff) = @_;
31
32    my $request = HTTP::MobileAttribute::Request->new($stuff);
33
34    # XXX carrier name detection is actually simple, so instead of
35    # going through the hassle of doing Detector->detect, we simply
36    # create a function that does the right thing and use it
37    my $carrier_longname = HTTP::MobileAttribute::CarrierDetector::detect($request->get('User-Agent'));
38
39    my $self = $class->agent_class($carrier_longname)->new({
40        request          => $request,
41        carrier_longname => $carrier_longname,
42    });
43    $self->parse;
44    return $self;
45}
46
47sub agent_class { 'HTTP::MobileAttribute::Agent::' . $_[1] }
48
49sub load_plugins {
50    my ($class, @plugins) = @_;
51
52    for my $carrier (carriers()) {
53        $class->agent_class($carrier)->load_plugins(@plugins);
54    }
55}
56
57
581;
59__END__
60
61=encoding UTF-8
62
63=for stopwords aaaatttt gmail dotottto commmmm Kazuhiro Osawa Plaggable DoCoMo ThirdForce Vodafone docs Daisuke Maki
64
65=head1 NAME
66
67HTTP::MobileAttribute - Yet Another HTTP::MobileAgent
68
69=head1 SYNOPSIS
70
71  use HTTP::MobileAttribute;
72
73  HTTP::MobileAttribute->load_plugins(qw/Flash Image CarrierName/);
74
75  my $agent = HTTP::MobileAttribute->new;
76  $agent->is_supported_flash();
77  $agent->is_supported_gif();
78
79=head1 WARNINGS
80
81WE ARE NOW TESTING THE CONCEPT.
82
83DO NOT USE THIS MODULE.
84
85=head1 DESCRIPTION
86
87HTTP::MobileAttribute is Plaggable version of HTTP::MobileAgent.
88
89っていうか、まあ日本人しかつかわないだろうから日本語で docs かくね。
90
91現時点では、とりあえずキャリヤ判定がデキルッポイ。
92
93=head1 コンセプト
94
95    - キャリヤ判別もプラグァーブル
96    - トニカクぷらぐぁーぶる
97    - HTTP::MobileAgent とできるだけ互換性をもたす。かも。
98
99=head1 非互換メモ
100
101当たり前のことながら、$agent->isa はつかえないね。
102
103carrier_longname が Vodafone じゃなくて ThirdForce を返すよ
104
105=head2 廃止したメソッド
106
107可能な限り、HTTP::MobileAgent とメソッド名に互換性を持たせてある。
108ただし、今時どうみてもつかわんだろうというようなものは削ってある。
109
110具体的には
111
112    DoCoMo: series
113
114なんだけど、つかってないよね?もし使ってる人いたら実装してください。
115
116あと、 DoCoMo の、たぶん当時はつかってたんだろうけど今はつかってないっぽいものも消してある(もともとつけられるからつけただけなのかもしらんけど)。
117
118    vendor
119    cache_size
120    html_version
121
122=head1 気になってること
123
124=head2 メモリつかいすぎ疑惑
125
126まあ、たしょうメモリはいっぱいつかうよね。
127
128=head1 AUTHOR
129
130Tokuhiro Matsuno E<lt>tokuhirom aaaatttt gmail dotottto commmmmE<gt>
131
132Kazuhiro Osawa
133
134Daisuke Maki
135
136=head1 THANKS TO
137
138    Tatsuhiko Miyagawa(original author of HTTP::MobileAgent)
139    Satoshi Tanimoto
140    Yoshiki Kurihara(Current mentainer of HTTP::MobileAgent)
141
142=head1 SEE ALSO
143
144L<HTTP::MobileAgent>
145
146=head1 LICENSE
147
148This library is free software; you can redistribute it and/or modify
149it under the same terms as Perl itself.
150
151=cut
Note: See TracBrowser for help on using the browser.