| 1 | package App::SocialSKK::Plugin; | ||
| 2 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use base qw(App::SocialSKK::Base); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 1 | __PACKAGE__->mk_accessors(qw(ua)); | |
| 7 | |||
| 8 | 0 | ▶ | sub get_candidates { |
|
Subroutine
get_candidates: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 9 | 0 | die 'This method must be overridden by subclass'; | |
| 10 | } | ||
| 11 | |||
| 12 | 1 | 1; | |
| 13 | |||
| 14 | __END__ | ||
| 15 | |||
| 16 | =head1 NAME | ||
| 17 | |||
| 18 | App::SocialSKK::Plugin - Baseclass of Social SKK Plugins | ||
| 19 | |||
| 20 | =head1 SYNOPSIS | ||
| 21 | |||
| 22 | package App::SocialSKK::Plugin::YourPlugin; | ||
| 23 | use strict; | ||
| 24 | use warnings; | ||
| 25 | use base qw(App::SocialSKK::Plugin); | ||
| 26 | |||
| 27 | sub get_candidates { | ||
| 28 | my ($self, $text) = @_; | ||
| 29 | my $res = $self->ua->get('http://example.com/'); | ||
| 30 | if ($res->is_success) { | ||
| 31 | my @candidates; | ||
| 32 | |||
| 33 | # Do some formatting against $res->content and push results | ||
| 34 | # into @candidates | ||
| 35 | |||
| 36 | return @candidates; | ||
| 37 | } | ||
| 38 | } | ||
| 39 | |||
| 40 | 1; | ||
| 41 | |||
| 42 | # Then, add a line like below into your .socialskk: | ||
| 43 | plugins: | ||
| 44 | - name: YourPlugin | ||
| 45 | config: | ||
| 46 | foo: bar | ||
| 47 | baz: qux | ||
| 48 | |||
| 49 | =head1 DESCRIPTION | ||
| 50 | |||
| 51 | App::SocialSKK::Plugin is a baseclass of Social SKK plugins. It offers | ||
| 52 | get_candidates() interface and built-in useragent object to retrieve | ||
| 53 | some data from the Web. | ||
| 54 | |||
| 55 | =head1 METHODS | ||
| 56 | |||
| 57 | =head2 nwe ( I<\%config> ) | ||
| 58 | |||
| 59 | =over 4 | ||
| 60 | |||
| 61 | my $plugin = App::SocialSKK::Plugin::YourPlugin->new(\%config); | ||
| 62 | |||
| 63 | Creates and returns new object of the plugin. | ||
| 64 | |||
| 65 | =back | ||
| 66 | |||
| 67 | =head2 get_candidates ( I<$text> ) | ||
| 68 | |||
| 69 | =over 4 | ||
| 70 | |||
| 71 | my @candidates = $plugin->get_candidates($text); | ||
| 72 | |||
| 73 | Takes a EUC-JP string as an input and processes and returns candidates | ||
| 74 | for the string. | ||
| 75 | |||
| 76 | This method must be overridden by subclass. | ||
| 77 | |||
| 78 | =back | ||
| 79 | |||
| 80 | =head2 ua () | ||
| 81 | |||
| 82 | =over 4 | ||
| 83 | |||
| 84 | # In your plugin: | ||
| 85 | my $res = $self->ua->get('http://example.com/'); | ||
| 86 | |||
| 87 | Returns LWP::UserAgent::POE object for non-blocking network | ||
| 88 | retrieval. You can use it to do with the data on the Web. | ||
| 89 | |||
| 90 | =back | ||
| 91 | |||
| 92 | =head1 SEE ALSO | ||
| 93 | |||
| 94 | =over 4 | ||
| 95 | |||
| 96 | =item * LWP::UserAgent::POE | ||
| 97 | |||
| 98 | =item * App::SocialSKK::Plugin::SocialIME | ||
| 99 | |||
| 100 | =item * App::SocialSKK::Plugin::Wikipedia | ||
| 101 | |||
| 102 | =item * App::SocialSKK::Plugin::HatenaBookmark | ||
| 103 | |||
| 104 | =back | ||
| 105 | |||
| 106 | =head1 AUTHOR | ||
| 107 | |||
| 108 | Kentaro Kuribayashi E<lt>kentaro@cpan.orgE<gt> | ||