|
Revision 6705, 1.4 kB
(checked in by yappo, 5 years ago)
|
|
lang/perl/Plusen: import
|
| Line | |
|---|
| 1 | package Plusen; |
|---|
| 2 | |
|---|
| 3 | use strict; |
|---|
| 4 | use warnings; |
|---|
| 5 | our $VERSION = '0.01'; |
|---|
| 6 | |
|---|
| 7 | use Class::Component; |
|---|
| 8 | __PACKAGE__->load_components(qw/ Plaggerize /); |
|---|
| 9 | |
|---|
| 10 | use base 'Class::Accessor::Fast'; |
|---|
| 11 | __PACKAGE__->mk_accessors(qw/ script is_exit /); |
|---|
| 12 | |
|---|
| 13 | use Encode (); |
|---|
| 14 | use Plusen::Script; |
|---|
| 15 | |
|---|
| 16 | sub new { |
|---|
| 17 | my($class, $args) = @_; |
|---|
| 18 | my $self = $class->NEXT( new => $args ); |
|---|
| 19 | |
|---|
| 20 | $self->script( Plusen::Script->new({ c => $self }) ); |
|---|
| 21 | |
|---|
| 22 | $self->script->$_( Encode::encode('utf8', $self->conf->{meta}->{$_}) ) for qw/ title author email /; |
|---|
| 23 | $self->is_exit(0); |
|---|
| 24 | |
|---|
| 25 | $self; |
|---|
| 26 | } |
|---|
| 27 | |
|---|
| 28 | sub bootstrap { |
|---|
| 29 | my $class = shift; |
|---|
| 30 | my $self = $class->new( @_ ); |
|---|
| 31 | |
|---|
| 32 | $self->run_hook('script.load'); |
|---|
| 33 | $self->run_hook('device.init'); |
|---|
| 34 | |
|---|
| 35 | $self->script->top; |
|---|
| 36 | |
|---|
| 37 | $self->event_loop; |
|---|
| 38 | |
|---|
| 39 | $self; |
|---|
| 40 | } |
|---|
| 41 | |
|---|
| 42 | sub event_loop { |
|---|
| 43 | my $self = shift; |
|---|
| 44 | while (!$self->is_exit) { |
|---|
| 45 | $self->run_hook('device.read'); |
|---|
| 46 | sleep 0.2; |
|---|
| 47 | } |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | 1; |
|---|
| 51 | __END__ |
|---|
| 52 | |
|---|
| 53 | =head1 NAME |
|---|
| 54 | |
|---|
| 55 | Plusen - pluggable presentation framework |
|---|
| 56 | |
|---|
| 57 | =head1 SYNOPSIS |
|---|
| 58 | |
|---|
| 59 | use Plusen; |
|---|
| 60 | |
|---|
| 61 | =head1 DESCRIPTION |
|---|
| 62 | |
|---|
| 63 | Plusen is |
|---|
| 64 | |
|---|
| 65 | =head1 AUTHOR |
|---|
| 66 | |
|---|
| 67 | Kazuhiro Osawa E<lt>ko@yappo.ne.jpE<gt> |
|---|
| 68 | |
|---|
| 69 | =head1 SEE ALSO |
|---|
| 70 | |
|---|
| 71 | =head1 EXAMPLE |
|---|
| 72 | |
|---|
| 73 | L<http://svn.coderepos.org/share/docs/yappo/devsumi2008/devsumi2008.pl>, |
|---|
| 74 | L<http://svn.coderepos.org/share/docs/yappo/devsumi2008/devsumi2008.yaml>, |
|---|
| 75 | |
|---|
| 76 | =head1 LICENSE |
|---|
| 77 | |
|---|
| 78 | This library is free software; you can redistribute it and/or modify |
|---|
| 79 | it under the same terms as Perl itself. |
|---|
| 80 | |
|---|
| 81 | =cut |
|---|