Metalgate/ReviewIndex.pm untested

filter: Statementstmt 0.0% 0 / 35 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 45 CC 2 SCAR 11.0
CC
2
Cov
0%
artists
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 3.0
1 package WWW::Metalgate::ReviewIndex;
2  
3 use warnings;
4 use strict;
5  
6 use Moose;
7 use MooseX::Types::URI qw(Uri FileUri DataUri);
8 use Web::Scraper;
9 use WWW::Metalgate::Artist;
10  
11 =head1 NAME
12  
13 WWW::Metalgate::ReviewIndex
14  
15 =head1 VERSION
16  
17 Version 0.01
18  
19 =cut
20  
21 our $VERSION = '0.01';
22  
23 =head1 FUNCTIONS
24  
25 =head2 uri
26  
27 =head2 html
28  
29 =cut
30  
31 has 'uri' => (is => 'rw', isa => Uri, coerce => 1, default => "http://www.metalgate.jp/reviewindex.htm");
32  
33 with 'WWW::Metalgate::Role::Html';
34  
35 =head2 artists
36  
37 =cut
38  
39 sub artists {
40 my $self = shift;
41  
42 #<a href="R_accept.htm">ACCEPT</a>
43 my $artist_link = sub {
44 my $node = shift;
45 return () unless $node->attr('href') =~ m/^R_/;
46 return {
47 name => $node->string_value,
48 href => URI->new_abs( $node->attr('href'), $self->uri ),
49 };
50 };
51 my $artists = scraper {
52 process 'td>a',
53 'links[]' => $artist_link;
54 };
55  
56 my $data = $artists->scrape( $self->html );
57  
58 my @artists;
59 for (@{$data->{links}}) {
60 my $artist = WWW::Metalgate::Artist->new( name => $_->{name}, uri => $_->{href} );
61 push @artists, $artist;
62 }
63  
64 return @artists;
65 }
66  
67 =head1 AUTHOR
68  
69 Tomohiro Hosaka, C<< <bokutin at cpan.org> >>
70  
71 =head1 COPYRIGHT & LICENSE
72  
73 Copyright 2008 Tomohiro Hosaka, all rights reserved.
74  
75 This program is free software; you can redistribute it and/or modify it
76 under the same terms as Perl itself.
77  
78 =cut
79  
80 1;