Changeset 569

Show
Ignore:
Timestamp:
03/31/02 13:02:37
Author:
miyagawa
Message:

0.03

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • WWW-Baseball-NPB/trunk/Changes

    r567 r569  
    11Revision history for Perl extension WWW::Baseball::NPB 
     2 
     30.03   
     4        * Added bbgames script in eg/ directory 
     5        - Renamed Result class to Game class 
    26 
    370.02  Sun Mar 31 01:56:06 JST 2002 
  • WWW-Baseball-NPB/trunk/MANIFEST

    r567 r569  
    33Makefile.PL 
    44README 
     5eg/bbgames 
    56lib/WWW/Baseball/NPB.pm 
    6 lib/WWW/Baseball/NPB/Result.pm 
     7lib/WWW/Baseball/NPB/Game.pm 
    78t/00_compile.t 
    89t/01_baseball.t 
  • WWW-Baseball-NPB/trunk/README

    r564 r569  
    1919DESCRIPTION 
    2020    WWW::Baseball::NPB provides you a way to fetch and extract Japanese 
    21     baseball result via Yahoo! Baseball. 
     21    baseball result via Yahoo! Baseball. (NPB = Nippon Professional 
     22    Baseball) 
    2223 
    2324NOTE 
    24     Characters like team names, status and stadium are encoded in EUC-JP. 
    25     You can convert them to any encoding via Jcode. 
     25    *   Characters like team names, status and stadium are encoded in 
     26        EUC-JP. You can convert them to any encoding via Jcode. 
    2627 
    2728TODO 
  • WWW-Baseball-NPB/trunk/lib/WWW/Baseball/NPB.pm

    r567 r569  
    66 
    77use LWP::Simple; 
    8 use WWW::Baseball::NPB::Result
     8use WWW::Baseball::NPB::Game
    99 
    1010use vars qw($YahooURL); 
     
    1515sub new { 
    1616    my $class = shift; 
    17     my $self  = bless { results => [] }, $class; 
     17    my $self  = bless { games => [] }, $class; 
    1818    $self->_parse_body($YahooURL); 
    1919    return $self; 
    2020} 
    2121 
    22 sub results { 
     22sub games { 
    2323    my($self, $league) = @_; 
    2424    unless ($league) { 
    25         return @{$self->{results}}; 
     25        return @{$self->{games}}; 
    2626    } 
    27     return grep { $_->league eq $league } @{$self->{results}}; 
     27    return grep { $_->league eq $league } @{$self->{games}}; 
    2828} 
    2929 
     
    3333    my $re   = $self->_match_pattern; 
    3434    while ($body =~ m/$re/g) { 
    35         $self->_add_result($1, $2, $3, $4, $5, $6, $7); 
     35        $self->_add_game($1, $2, $3, $4, $5, $6, $7); 
    3636    } 
    3737} 
     
    3939my %league = (cl => 'central', pl => 'pacific'); 
    4040 
    41 sub _add_result
     41sub _add_game
    4242    my($self, $home, $home_score, $visitor_score, $league, $status, $visitor, $stadium) = @_; 
    4343    for ($home_score, $visitor_score) { 
    4444        s,<b>(.*)</b>,$1,; 
    4545    } 
    46     push @{$self->{results}}, WWW::Baseball::NPB::Result->new( 
     46    push @{$self->{games}}, WWW::Baseball::NPB::Game->new( 
    4747        home    => $home, 
    4848        visitor => $visitor, 
     
    8282=head1 NAME 
    8383 
    84 WWW::Baseball::NPB - Fetches Japanese baseball result 
     84WWW::Baseball::NPB - Fetches Japanese baseball games information 
    8585 
    8686=head1 SYNOPSIS 
     
    8989 
    9090  my $baseball = WWW::Baseball::NPB->new; 
    91   my @results  = $baseball->results; 
    92   # or @results = $baseball->results('central'); 
     91  my @games  = $baseball->games; 
     92  # or @games = $baseball->games('central'); 
    9393 
    94   for my $res (@results) { 
    95       my $home    = $res->home; 
    96       my $visitor = $res->visitor; 
     94  for my $game (@games) { 
     95      my $home    = $game->home; 
     96      my $visitor = $game->visitor; 
    9797      printf "%s %d - %d %s (%s) [%s]\n", 
    98           $home, $res->score($home), $res->score($visitor), $visitor, 
    99           $res->status, $res->stadium; 
     98          $home, $game->score($home), $game->score($visitor), $visitor, 
     99          $game->status, $game->stadium; 
    100100  } 
    101101 
     
    103103 
    104104WWW::Baseball::NPB provides you a way to fetch and extract Japanese 
    105 baseball result via Yahoo! Baseball. (NPB = Nippon Professional 
    106 Baseball) 
     105baseball games information via Yahoo! Baseball. (NPB = Nippon 
     106Professional Baseball) 
    107107 
    108108=head1 NOTE 
  • WWW-Baseball-NPB/trunk/t/01_baseball.t

    r567 r569  
    1717 
    1818{ 
    19     my @results = $baseball->results; 
    20     is @results, 6; 
     19    my @games = $baseball->games; 
     20    is @games, 6; 
    2121 
    22     isa_ok $_, 'WWW::Baseball::NPB::Result' for @results; 
     22    isa_ok $_, 'WWW::Baseball::NPB::Game' for @games; 
    2323 
    24     my $res = $results[0]; 
    25     is $res->league, 'central'; 
    26     is $res->home, 'µð¿Í'; 
    27     is $res->visitor, 'ºå¿À'; 
    28     is $res->score('µð¿Í'), 1; 
    29     is $res->score('ºå¿À'), 3; 
    30     is $res->status, 'œªÎ»'; 
    31     is $res->stadium, 'Åìµþ¥É¡Œ¥à'; 
     24    my $game = $games[0]; 
     25    is $game->league, 'central'; 
     26    is $game->home, 'µð¿Í'; 
     27    is $game->visitor, 'ºå¿À'; 
     28    is $game->score('µð¿Í'), 1; 
     29    is $game->score('ºå¿À'), 3; 
     30    is $game->status, 'œªÎ»'; 
     31    is $game->stadium, 'Åìµþ¥É¡Œ¥à'; 
    3232} 
    3333 
    3434{ 
    35     my @results = $baseball->results('pacific'); 
    36     is @results, 3; 
     35    my @games = $baseball->games('pacific'); 
     36    is @games, 3; 
    3737 
    38     isa_ok $_, 'WWW::Baseball::NPB::Result' for @results; 
     38    isa_ok $_, 'WWW::Baseball::NPB::Game' for @games; 
    3939 
    40     my $res = $results[0]; 
    41     is $res->league, 'pacific'; 
    42     is $res->home, '¶áÅŽ'; 
    43     is $res->visitor, '¥ª¥ê¥Ã¥¯¥¹'; 
    44     is $res->score('¶áÅŽ'), 6; 
    45     is $res->score('¥ª¥ê¥Ã¥¯¥¹'), 3; 
    46     is $res->status, 'œªÎ»'; 
    47     is $res->stadium, 'Âçºå¥É¡Œ¥à'; 
     40    my $game = $games[0]; 
     41    is $game->league, 'pacific'; 
     42    is $game->home, '¶áÅŽ'; 
     43    is $game->visitor, '¥ª¥ê¥Ã¥¯¥¹'; 
     44    is $game->score('¶áÅŽ'), 6; 
     45    is $game->score('¥ª¥ê¥Ã¥¯¥¹'), 3; 
     46    is $game->status, 'œªÎ»'; 
     47    is $game->stadium, 'Âçºå¥É¡Œ¥à'; 
    4848} 
    4949 
  • WWW-Baseball-NPB/trunk/t/02_pre.t

    r568 r569  
    11use strict; 
    2 use Test::More 'no_plan'
     2use Test::More tests => 14
    33 
    44use WWW::Baseball::NPB; 
     
    1717 
    1818{ 
    19     my @results = $baseball->results; 
    20     is @results, 6; 
     19    my @games = $baseball->games; 
     20    is @games, 6; 
    2121 
    22     isa_ok $_, 'WWW::Baseball::NPB::Result' for @results; 
     22    isa_ok $_, 'WWW::Baseball::NPB::Game' for @games; 
    2323 
    24     my $res = $results[0]; 
    25     is $res->league, 'central'; 
    26     is $res->home, 'µð¿Í'; 
    27     is $res->visitor, 'ºå¿À'; 
    28     is $res->score('µð¿Í'), ''; 
    29     is $res->score('ºå¿À'), ''; 
    30     is $res->status, '18»þ00ʬ'; 
    31     is $res->stadium, 'Åìµþ¥É¡Œ¥à'; 
     24    my $game = $games[0]; 
     25    is $game->league, 'central'; 
     26    is $game->home, 'µð¿Í'; 
     27    is $game->visitor, 'ºå¿À'; 
     28    is $game->score('µð¿Í'), ''; 
     29    is $game->score('ºå¿À'), ''; 
     30    is $game->status, '18»þ00ʬ'; 
     31    is $game->stadium, 'Åìµþ¥É¡Œ¥à'; 
    3232} 
    3333