| 1 | # | ||||||||||||
| 2 | # $Id: Search.pm 9 2008-04-29 21:17:12Z esobchenko $ | ||||||||||||
| 3 | |||||||||||||
| 4 | package REST::Google::Search; | ||||||||||||
| 5 | |||||||||||||
| 6 | 2 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | 2 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | |||||||||||||
| 9 | 2 | ▶ | use version; our $VERSION = qv('1.0.8'); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | |||||||||||||
| 11 | 2 | ▶ | use constant { | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 12 | 2 | WEB => 'http://ajax.googleapis.com/ajax/services/search/web', | |||||||||||
| 13 | VIDEO => 'http://ajax.googleapis.com/ajax/services/search/video', | ||||||||||||
| 14 | NEWS => 'http://ajax.googleapis.com/ajax/services/search/news', | ||||||||||||
| 15 | LOCAL => 'http://ajax.googleapis.com/ajax/services/search/local', | ||||||||||||
| 16 | IMAGES => 'http://ajax.googleapis.com/ajax/services/search/images', | ||||||||||||
| 17 | BOOKS => 'http://ajax.googleapis.com/ajax/services/search/books', | ||||||||||||
| 18 | BLOGS => 'http://ajax.googleapis.com/ajax/services/search/blogs', | ||||||||||||
| 19 | PATENT => 'http://ajax.googleapis.com/ajax/services/search/patent', | ||||||||||||
| 20 | 2 | }; | |||||||||||
| 21 | |||||||||||||
| 22 | 2 | require Exporter; | |||||||||||
| 23 | 2 | require REST::Google; | |||||||||||
| 24 | 2 | ▶ | use base qw/Exporter REST::Google/; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 25 | |||||||||||||
| 26 | 2 | our @EXPORT_OK = qw/WEB VIDEO NEWS LOCAL IMAGES BOOKS BLOGS PATENT/; | |||||||||||
| 27 | |||||||||||||
| 28 | 2 | __PACKAGE__->service( WEB ); | |||||||||||
| 29 | |||||||||||||
| 30 | 0 | ▶ | sub responseData { | ||||||||||
|
Subroutine
responseData: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||
| 31 | 0 | my $self = shift; | |||||||||||
| 32 | 0 | ▶ | return undef unless defined $self->{responseData}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 33 | 0 | return bless $self->{responseData}, 'REST::Google::Search::Data'; | |||||||||||
| 34 | } | ||||||||||||
| 35 | |||||||||||||
| 36 | package # hide from CPAN | ||||||||||||
| 37 | REST::Google::Search::Data; | ||||||||||||
| 38 | |||||||||||||
| 39 | 0 | ▶ | sub results { | ||||||||||
|
Subroutine
results: not called CC=2 SCAR=17.9
| |||||||||||||
| 40 | 0 | my $self = shift; | |||||||||||
| 41 | 0 | ▶ | if ( wantarray ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 42 | 0 | return map { bless $_, $_->{GsearchResultClass} } @{ $self->{results} }; | |||||||||||
| 43 | } | ||||||||||||
| 44 | 0 | [ map { bless $_, $_->{GsearchResultClass} } @{ $self->{results} } ]; | |||||||||||
| 45 | } | ||||||||||||
| 46 | |||||||||||||
| 47 | 0 | ▶ | sub cursor { | ||||||||||
|
Subroutine
cursor: not called CC=1 SCAR=6.9
| |||||||||||||
| 48 | 0 | my $self = shift; | |||||||||||
| 49 | 0 | return bless $self->{cursor}, 'REST::Google::Search::Cursor'; | |||||||||||
| 50 | } | ||||||||||||
| 51 | |||||||||||||
| 52 | package # hide from CPAN | ||||||||||||
| 53 | REST::Google::Search::Cursor; | ||||||||||||
| 54 | |||||||||||||
| 55 | 2 | ▶ | use base qw/Class::Accessor/; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 56 | |||||||||||||
| 57 | { | ||||||||||||
| 58 | 2 | my @fields = qw( | |||||||||||
| 59 | moreResultsUrl | ||||||||||||
| 60 | currentPageIndex | ||||||||||||
| 61 | ); | ||||||||||||
| 62 | |||||||||||||
| 63 | 2 | __PACKAGE__->mk_ro_accessors( @fields ); | |||||||||||
| 64 | } | ||||||||||||
| 65 | |||||||||||||
| 66 | 0 | ▶ | sub estimatedResultCount { | ||||||||||
|
Subroutine
estimatedResultCount: not called CC=2 SCAR=17.9
| |||||||||||||
| 67 | 0 | my $self = shift; | |||||||||||
| 68 | 0 | my $count = $self->{estimatedResultCount}; | |||||||||||
| 69 | 0 | ▶ | defined $count ? $count : 0; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 70 | } | ||||||||||||
| 71 | |||||||||||||
| 72 | 0 | ▶ | sub pages { | ||||||||||
|
Subroutine
pages: not called CC=3 SCAR=24.8
| |||||||||||||
| 73 | 0 | my $self = shift; | |||||||||||
| 74 | 0 | ▶ | my $pages = $self->{pages} || []; | ||||||||||
|
Condition0%0/2
$self->{'pages'} || []
MC/DC0%0/1
$self->{'pages'} || []
$self->{'pages'}
Truth table0%0/2
A
A= $self->{'pages'}
| |||||||||||||
| 75 | 0 | ▶ | if (wantarray) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 76 | 0 | return map { bless $_, 'REST::Google::Search::Pages' } @{ $pages }; | |||||||||||
| 77 | } | ||||||||||||
| 78 | 0 | [ map { bless $_, 'REST::Google::Search::Pages' } @{ $pages } ]; | |||||||||||
| 79 | } | ||||||||||||
| 80 | |||||||||||||
| 81 | package # hide from CPAN | ||||||||||||
| 82 | REST::Google::Search::Pages; | ||||||||||||
| 83 | |||||||||||||
| 84 | 2 | ▶ | use base qw/Class::Accessor/; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 85 | |||||||||||||
| 86 | { | ||||||||||||
| 87 | 2 | my @fields = qw( | |||||||||||
| 88 | start | ||||||||||||
| 89 | label | ||||||||||||
| 90 | ); | ||||||||||||
| 91 | |||||||||||||
| 92 | 2 | __PACKAGE__->mk_ro_accessors( @fields ); | |||||||||||
| 93 | } | ||||||||||||
| 94 | |||||||||||||
| 95 | # | ||||||||||||
| 96 | # Search Result Classes | ||||||||||||
| 97 | # | ||||||||||||
| 98 | |||||||||||||
| 99 | package # hide from CPAN | ||||||||||||
| 100 | GwebSearch; | ||||||||||||
| 101 | |||||||||||||
| 102 | 2 | ▶ | use base qw/Class::Accessor/; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 103 | |||||||||||||
| 104 | { | ||||||||||||
| 105 | 2 | my @fields = qw( | |||||||||||
| 106 | unescapedUrl | ||||||||||||
| 107 | url | ||||||||||||
| 108 | visibleUrl | ||||||||||||
| 109 | title | ||||||||||||
| 110 | titleNoFormatting | ||||||||||||
| 111 | content | ||||||||||||
| 112 | cacheUrl | ||||||||||||
| 113 | ); | ||||||||||||
| 114 | |||||||||||||
| 115 | 2 | __PACKAGE__->mk_ro_accessors( @fields ); | |||||||||||
| 116 | } | ||||||||||||
| 117 | |||||||||||||
| 118 | package # hide from CPAN | ||||||||||||
| 119 | GvideoSearch; | ||||||||||||
| 120 | |||||||||||||
| 121 | 2 | ▶ | use base qw/Class::Accessor/; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 122 | |||||||||||||
| 123 | { | ||||||||||||
| 124 | 2 | my @fields = qw( | |||||||||||
| 125 | title | ||||||||||||
| 126 | titleNoFormatting | ||||||||||||
| 127 | content | ||||||||||||
| 128 | url | ||||||||||||
| 129 | published | ||||||||||||
| 130 | publisher | ||||||||||||
| 131 | duration | ||||||||||||
| 132 | tbWidth | ||||||||||||
| 133 | tbHeight | ||||||||||||
| 134 | tbUrl | ||||||||||||
| 135 | playUrl | ||||||||||||
| 136 | author | ||||||||||||
| 137 | viewCount | ||||||||||||
| 138 | rating | ||||||||||||
| 139 | ); | ||||||||||||
| 140 | |||||||||||||
| 141 | 2 | __PACKAGE__->mk_ro_accessors( @fields ); | |||||||||||
| 142 | } | ||||||||||||
| 143 | |||||||||||||
| 144 | package # hide from CPAN | ||||||||||||
| 145 | GnewsSearch; | ||||||||||||
| 146 | |||||||||||||
| 147 | 2 | ▶ | use base qw/Class::Accessor/; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 148 | |||||||||||||
| 149 | { | ||||||||||||
| 150 | 2 | my @fields = qw( | |||||||||||
| 151 | title | ||||||||||||
| 152 | titleNoFormatting | ||||||||||||
| 153 | unescapedUrl | ||||||||||||
| 154 | url | ||||||||||||
| 155 | clusterUrl | ||||||||||||
| 156 | content | ||||||||||||
| 157 | publisher | ||||||||||||
| 158 | location | ||||||||||||
| 159 | publishedDate | ||||||||||||
| 160 | relatedStories | ||||||||||||
| 161 | image | ||||||||||||
| 162 | language | ||||||||||||
| 163 | ); | ||||||||||||
| 164 | |||||||||||||
| 165 | 2 | __PACKAGE__->mk_ro_accessors( @fields ); | |||||||||||
| 166 | } | ||||||||||||
| 167 | |||||||||||||
| 168 | package # hide from CPAN | ||||||||||||
| 169 | GlocalSearch; | ||||||||||||
| 170 | |||||||||||||
| 171 | 2 | ▶ | use base qw/Class::Accessor/; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 172 | |||||||||||||
| 173 | { | ||||||||||||
| 174 | 2 | my @fields = qw( | |||||||||||
| 175 | title | ||||||||||||
| 176 | titleNoFormatting | ||||||||||||
| 177 | url | ||||||||||||
| 178 | lat | ||||||||||||
| 179 | lng | ||||||||||||
| 180 | streetAddress | ||||||||||||
| 181 | city | ||||||||||||
| 182 | region | ||||||||||||
| 183 | country | ||||||||||||
| 184 | phoneNumbers | ||||||||||||
| 185 | addressLines | ||||||||||||
| 186 | ddUrl | ||||||||||||
| 187 | ddUrlToHere | ||||||||||||
| 188 | ddUrlFromHere | ||||||||||||
| 189 | staticMapUrl | ||||||||||||
| 190 | listingType | ||||||||||||
| 191 | content | ||||||||||||
| 192 | ); | ||||||||||||
| 193 | |||||||||||||
| 194 | 2 | __PACKAGE__->mk_ro_accessors( @fields ); | |||||||||||
| 195 | } | ||||||||||||
| 196 | |||||||||||||
| 197 | package # hide from CPAN | ||||||||||||
| 198 | GimageSearch; | ||||||||||||
| 199 | |||||||||||||
| 200 | 2 | ▶ | use base qw/Class::Accessor/; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 201 | |||||||||||||
| 202 | { | ||||||||||||
| 203 | 2 | my @fields = qw( | |||||||||||
| 204 | title | ||||||||||||
| 205 | titleNoFormatting | ||||||||||||
| 206 | unescapedUrl | ||||||||||||
| 207 | url | ||||||||||||
| 208 | visibleUrl | ||||||||||||
| 209 | originalContextUrl | ||||||||||||
| 210 | width | ||||||||||||
| 211 | height | ||||||||||||
| 212 | tbWidth | ||||||||||||
| 213 | tbHeight | ||||||||||||
| 214 | tbUrl | ||||||||||||
| 215 | content | ||||||||||||
| 216 | contentNoFormatting | ||||||||||||
| 217 | ); | ||||||||||||
| 218 | |||||||||||||
| 219 | 2 | __PACKAGE__->mk_ro_accessors( @fields ); | |||||||||||
| 220 | } | ||||||||||||
| 221 | |||||||||||||
| 222 | package # hide from CPAN | ||||||||||||
| 223 | GbookSearch; | ||||||||||||
| 224 | |||||||||||||
| 225 | 2 | ▶ | use base qw/Class::Accessor/; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 226 | |||||||||||||
| 227 | { | ||||||||||||
| 228 | 2 | my @fields = qw( | |||||||||||
| 229 | title | ||||||||||||
| 230 | titleNoFormatting | ||||||||||||
| 231 | unescapedUrl | ||||||||||||
| 232 | url | ||||||||||||
| 233 | authors | ||||||||||||
| 234 | bookId | ||||||||||||
| 235 | publishedYear | ||||||||||||
| 236 | pageCount | ||||||||||||
| 237 | thumbnailHtml | ||||||||||||
| 238 | ); | ||||||||||||
| 239 | |||||||||||||
| 240 | 2 | __PACKAGE__->mk_ro_accessors( @fields ); | |||||||||||
| 241 | } | ||||||||||||
| 242 | |||||||||||||
| 243 | package # hide from CPAN | ||||||||||||
| 244 | GblogSearch; | ||||||||||||
| 245 | |||||||||||||
| 246 | 2 | ▶ | use base qw/Class::Accessor/; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 247 | |||||||||||||
| 248 | { | ||||||||||||
| 249 | 2 | my @fields = qw( | |||||||||||
| 250 | title | ||||||||||||
| 251 | titleNoFormatting | ||||||||||||
| 252 | postUrl | ||||||||||||
| 253 | content | ||||||||||||
| 254 | author | ||||||||||||
| 255 | blogUrl | ||||||||||||
| 256 | publishedDate | ||||||||||||
| 257 | ); | ||||||||||||
| 258 | |||||||||||||
| 259 | 2 | __PACKAGE__->mk_ro_accessors( @fields ); | |||||||||||
| 260 | } | ||||||||||||
| 261 | |||||||||||||
| 262 | package # hide from CPAN | ||||||||||||
| 263 | GpatentSearch; | ||||||||||||
| 264 | |||||||||||||
| 265 | 2 | ▶ | use base qw/Class::Accessor/; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 266 | |||||||||||||
| 267 | { | ||||||||||||
| 268 | 2 | my @fields = qw( | |||||||||||
| 269 | title | ||||||||||||
| 270 | titleNoFormatting | ||||||||||||
| 271 | content | ||||||||||||
| 272 | unescapedUrl | ||||||||||||
| 273 | url | ||||||||||||
| 274 | applicationDate | ||||||||||||
| 275 | patentNumber | ||||||||||||
| 276 | patentStatus | ||||||||||||
| 277 | assignee | ||||||||||||
| 278 | tbUrl | ||||||||||||
| 279 | ); | ||||||||||||
| 280 | |||||||||||||
| 281 | 2 | __PACKAGE__->mk_ro_accessors( @fields ); | |||||||||||
| 282 | } | ||||||||||||
| 283 | |||||||||||||
| 284 | 2 | 1; | |||||||||||