| 1 | # ABSTRACT: Interface to COLOURlovers.com's API | ||||||||||
| 2 | |||||||||||
| 3 | package Net::COLOURlovers; | ||||||||||
| 4 | { | ||||||||||
| 5 | 1 | $Net::COLOURlovers::VERSION = '0.01'; | |||||||||
| 6 | } | ||||||||||
| 7 | |||||||||||
| 8 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 1 | ▶ | use List::Util qw( first ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 1 | ▶ | use LWP::UserAgent; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 1 | ▶ | use base qw( | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | Net::COLOURlovers::Color | ||||||||||
| 16 | Net::COLOURlovers::Lover | ||||||||||
| 17 | Net::COLOURlovers::Palette | ||||||||||
| 18 | Net::COLOURlovers::Pattern | ||||||||||
| 19 | Net::COLOURlovers::Stat | ||||||||||
| 20 | 1 | ); | |||||||||
| 21 | |||||||||||
| 22 | 1 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 23 | 1 | my $ua = LWP::UserAgent->new( | |||||||||
| 24 | 'agent' => "Net::COLOURlovers/$Net::COLOURlovers::VERSION" ); | ||||||||||
| 25 | 1 | my $args = { 'ua' => $ua }; | |||||||||
| 26 | |||||||||||
| 27 | 1 | return bless $args, __PACKAGE__; | |||||||||
| 28 | } | ||||||||||
| 29 | |||||||||||
| 30 | 0 | ▶ | sub _build_parametres { | ||||||||
|
Subroutine
_build_parametres: not called CC=3 SCAR=24.8
| |||||||||||
| 31 | 0 | my ( $args, $parametres_ref ) = @_; | |||||||||
| 32 | |||||||||||
| 33 | 0 | my %parametre; | |||||||||
| 34 | 0 | for my $parametre (@$parametres_ref) { | |||||||||
| 35 | 0 | ▶ | if ( first { $_ eq $parametre } keys %$args ) { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
| |||||||||||
| 36 | 0 | $parametre{$parametre} = $args->{$parametre}; | |||||||||
| 37 | } | ||||||||||
| 38 | } | ||||||||||
| 39 | |||||||||||
| 40 | 0 | return \%parametre; | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | 1 | 1; | |||||||||
| 44 | |||||||||||
| 45 | |||||||||||
| 46 | |||||||||||
| 47 | =pod | ||||||||||
| 48 | |||||||||||
| 49 | =head1 NAME | ||||||||||
| 50 | |||||||||||
| 51 | Net::COLOURlovers - Interface to COLOURlovers.com's API | ||||||||||
| 52 | |||||||||||
| 53 | =head1 VERSION | ||||||||||
| 54 | |||||||||||
| 55 | version 0.01 | ||||||||||
| 56 | |||||||||||
| 57 | =head1 SYNOPSIS | ||||||||||
| 58 | |||||||||||
| 59 | use Net::COLOURlovers; | ||||||||||
| 60 | |||||||||||
| 61 | my $cl = Net::COLOURlovers->new; | ||||||||||
| 62 | |||||||||||
| 63 | my $pattern = $cl->pattern_random; | ||||||||||
| 64 | my @colors = $cl->colors_top( { 'numResults' => 5 } ); | ||||||||||
| 65 | |||||||||||
| 66 | A sample page built using this API can be found at: L<http://bit.ly/qtIepU>. | ||||||||||
| 67 | |||||||||||
| 68 | =head3 METHOD FORMAT | ||||||||||
| 69 | |||||||||||
| 70 | Each method listed below has its input and output parametres specified in | ||||||||||
| 71 | sections titled I<Input> and I<Output>. These sections are followed by the | ||||||||||
| 72 | parametre type: | ||||||||||
| 73 | |||||||||||
| 74 | =over 4 | ||||||||||
| 75 | |||||||||||
| 76 | =item * B<C<UNDEF>> - accepts no parametre | ||||||||||
| 77 | |||||||||||
| 78 | =item * B<C<SCALAR>> - accepts/returns a B<C<SCALAR>> | ||||||||||
| 79 | |||||||||||
| 80 | =item * B<C<HASHREF>> - accepts/returns a B<C<HASH>> | ||||||||||
| 81 | |||||||||||
| 82 | =item * B<C<ARRAYREF> of C<HASHREF>s> - accepts/returns an B<C<ARRAY>> reference | ||||||||||
| 83 | which has B<C<HASH>> references as its elements | ||||||||||
| 84 | |||||||||||
| 85 | =back | ||||||||||
| 86 | |||||||||||
| 87 | =head1 ATTRIBUTES | ||||||||||
| 88 | |||||||||||
| 89 | =head2 C<new> | ||||||||||
| 90 | |||||||||||
| 91 | Constructs and returns a L<Net::COLOURlovers> object. | ||||||||||
| 92 | |||||||||||
| 93 | =head1 METHODS | ||||||||||
| 94 | |||||||||||
| 95 | =head2 C<color> | ||||||||||
| 96 | |||||||||||
| 97 | I<Input>: B<C<SCALAR>> | ||||||||||
| 98 | |||||||||||
| 99 | =over 4 | ||||||||||
| 100 | |||||||||||
| 101 | =item * C<'color_name'> | ||||||||||
| 102 | |||||||||||
| 103 | A 6-character hexadecimal value like C<6B4106>. | ||||||||||
| 104 | |||||||||||
| 105 | =back | ||||||||||
| 106 | |||||||||||
| 107 | I<Output>: B<C<HASHREF>> | ||||||||||
| 108 | |||||||||||
| 109 | =over 4 | ||||||||||
| 110 | |||||||||||
| 111 | =item * C<id> | ||||||||||
| 112 | |||||||||||
| 113 | =item * C<title> | ||||||||||
| 114 | |||||||||||
| 115 | =item * C<userName> | ||||||||||
| 116 | |||||||||||
| 117 | =item * C<numViews> | ||||||||||
| 118 | |||||||||||
| 119 | =item * C<numVotes> | ||||||||||
| 120 | |||||||||||
| 121 | =item * C<numComments> | ||||||||||
| 122 | |||||||||||
| 123 | =item * C<numHearts> | ||||||||||
| 124 | |||||||||||
| 125 | =item * C<rank> | ||||||||||
| 126 | |||||||||||
| 127 | =item * C<dateCreated> | ||||||||||
| 128 | |||||||||||
| 129 | =item * C<hex> | ||||||||||
| 130 | |||||||||||
| 131 | =item * C<rgb> | ||||||||||
| 132 | |||||||||||
| 133 | =over 4 | ||||||||||
| 134 | |||||||||||
| 135 | =item * C<red> | ||||||||||
| 136 | |||||||||||
| 137 | =item * C<green> | ||||||||||
| 138 | |||||||||||
| 139 | =item * C<blue> | ||||||||||
| 140 | |||||||||||
| 141 | =back | ||||||||||
| 142 | |||||||||||
| 143 | =item * C<hsv> | ||||||||||
| 144 | |||||||||||
| 145 | =over 4 | ||||||||||
| 146 | |||||||||||
| 147 | =item * C<hue> | ||||||||||
| 148 | |||||||||||
| 149 | =item * C<saturation> | ||||||||||
| 150 | |||||||||||
| 151 | =item * C<value> | ||||||||||
| 152 | |||||||||||
| 153 | =back | ||||||||||
| 154 | |||||||||||
| 155 | =item * C<description> | ||||||||||
| 156 | |||||||||||
| 157 | =item * C<url> | ||||||||||
| 158 | |||||||||||
| 159 | =item * C<imageUrl> | ||||||||||
| 160 | |||||||||||
| 161 | =item * C<badgeUrl> | ||||||||||
| 162 | |||||||||||
| 163 | =item * C<apiUrl> | ||||||||||
| 164 | |||||||||||
| 165 | =back | ||||||||||
| 166 | |||||||||||
| 167 | =head2 C<colors>, C<colors_new> and C<colors_top> | ||||||||||
| 168 | |||||||||||
| 169 | I<Input>: B<C<HASHREF>> (optional) | ||||||||||
| 170 | |||||||||||
| 171 | =over 4 | ||||||||||
| 172 | |||||||||||
| 173 | =item * C<lover> | ||||||||||
| 174 | |||||||||||
| 175 | =item * C<hueRange> | ||||||||||
| 176 | |||||||||||
| 177 | =item * C<briRange> | ||||||||||
| 178 | |||||||||||
| 179 | =item * C<keywords> | ||||||||||
| 180 | |||||||||||
| 181 | =item * C<keywordExact> | ||||||||||
| 182 | |||||||||||
| 183 | =item * C<orderCol> | ||||||||||
| 184 | |||||||||||
| 185 | =item * C<sortBy> | ||||||||||
| 186 | |||||||||||
| 187 | =item * C<numResults> | ||||||||||
| 188 | |||||||||||
| 189 | =item * C<resultOffset> | ||||||||||
| 190 | |||||||||||
| 191 | =back | ||||||||||
| 192 | |||||||||||
| 193 | I<Output>: B<C<ARRAYREF> of C<HASHREF>s> | ||||||||||
| 194 | |||||||||||
| 195 | Format same as that for L</color>. | ||||||||||
| 196 | |||||||||||
| 197 | =head2 C<color_random> | ||||||||||
| 198 | |||||||||||
| 199 | I<Input>: B<C<UNDEF>> | ||||||||||
| 200 | |||||||||||
| 201 | I<Output>: B<C<HASHREF>> | ||||||||||
| 202 | |||||||||||
| 203 | Format same as that for L</color>. | ||||||||||
| 204 | |||||||||||
| 205 | =head2 C<lover> | ||||||||||
| 206 | |||||||||||
| 207 | I<Input>: B<C<SCALAR>> | ||||||||||
| 208 | |||||||||||
| 209 | =over 4 | ||||||||||
| 210 | |||||||||||
| 211 | =item * C<'lover_name'> | ||||||||||
| 212 | |||||||||||
| 213 | A valid COLOURlovers.com username. | ||||||||||
| 214 | |||||||||||
| 215 | =back | ||||||||||
| 216 | |||||||||||
| 217 | I<Output>: B<C<HASHREF>> | ||||||||||
| 218 | |||||||||||
| 219 | =over 4 | ||||||||||
| 220 | |||||||||||
| 221 | =item * C<userName> | ||||||||||
| 222 | |||||||||||
| 223 | =item * C<dateRegistered> | ||||||||||
| 224 | |||||||||||
| 225 | =item * C<dateLastActive> | ||||||||||
| 226 | |||||||||||
| 227 | =item * C<rating> | ||||||||||
| 228 | |||||||||||
| 229 | =item * C<location> | ||||||||||
| 230 | |||||||||||
| 231 | =item * C<numColors> | ||||||||||
| 232 | |||||||||||
| 233 | =item * C<numPalettes> | ||||||||||
| 234 | |||||||||||
| 235 | =item * C<numCommentsMade> | ||||||||||
| 236 | |||||||||||
| 237 | =item * C<numCommentsOnProfile> | ||||||||||
| 238 | |||||||||||
| 239 | =item * C<comments> | ||||||||||
| 240 | |||||||||||
| 241 | =item * C<url> | ||||||||||
| 242 | |||||||||||
| 243 | =item * C<apiUrl> | ||||||||||
| 244 | |||||||||||
| 245 | =back | ||||||||||
| 246 | |||||||||||
| 247 | =head2 C<lovers>, C<lovers_new> and C<lovers_top> | ||||||||||
| 248 | |||||||||||
| 249 | I<Input>: B<C<HASHREF>> (optional) | ||||||||||
| 250 | |||||||||||
| 251 | =over 4 | ||||||||||
| 252 | |||||||||||
| 253 | =item * C<orderCol> | ||||||||||
| 254 | |||||||||||
| 255 | =item * C<sortBy> | ||||||||||
| 256 | |||||||||||
| 257 | =item * C<numResults> | ||||||||||
| 258 | |||||||||||
| 259 | =item * C<resultOffset> | ||||||||||
| 260 | |||||||||||
| 261 | =back | ||||||||||
| 262 | |||||||||||
| 263 | I<Output>: B<C<ARRAYREF> of C<HASHREF>s> | ||||||||||
| 264 | |||||||||||
| 265 | Format same as that for L</lover>. | ||||||||||
| 266 | |||||||||||
| 267 | =head2 C<palette> | ||||||||||
| 268 | |||||||||||
| 269 | I<Input>: B<C<SCALAR>> | ||||||||||
| 270 | |||||||||||
| 271 | =over 4 | ||||||||||
| 272 | |||||||||||
| 273 | =item * C<'palette_id'> | ||||||||||
| 274 | |||||||||||
| 275 | A valid palette ID like C<113451>. | ||||||||||
| 276 | |||||||||||
| 277 | =back | ||||||||||
| 278 | |||||||||||
| 279 | I<Output>: B<C<HASHREF>> | ||||||||||
| 280 | |||||||||||
| 281 | =over 4 | ||||||||||
| 282 | |||||||||||
| 283 | =item * C<id> | ||||||||||
| 284 | |||||||||||
| 285 | =item * C<title> | ||||||||||
| 286 | |||||||||||
| 287 | =item * C<userName> | ||||||||||
| 288 | |||||||||||
| 289 | =item * C<numViews> | ||||||||||
| 290 | |||||||||||
| 291 | =item * C<numVotes> | ||||||||||
| 292 | |||||||||||
| 293 | =item * C<numComments> | ||||||||||
| 294 | |||||||||||
| 295 | =item * C<numHearts> | ||||||||||
| 296 | |||||||||||
| 297 | =item * C<rank> | ||||||||||
| 298 | |||||||||||
| 299 | =item * C<dateCreated> | ||||||||||
| 300 | |||||||||||
| 301 | =item * C<colors> | ||||||||||
| 302 | |||||||||||
| 303 | =item * C<description> | ||||||||||
| 304 | |||||||||||
| 305 | =item * C<url> | ||||||||||
| 306 | |||||||||||
| 307 | =item * C<imageUrl> | ||||||||||
| 308 | |||||||||||
| 309 | =item * C<badgeUrl> | ||||||||||
| 310 | |||||||||||
| 311 | =item * C<apiUrl> | ||||||||||
| 312 | |||||||||||
| 313 | =back | ||||||||||
| 314 | |||||||||||
| 315 | =head2 C<palettes>, C<palettes_new> and C<palettes_top> | ||||||||||
| 316 | |||||||||||
| 317 | I<Input>: B<C<HASHREF>> (optional) | ||||||||||
| 318 | |||||||||||
| 319 | =over 4 | ||||||||||
| 320 | |||||||||||
| 321 | =item * C<lover> | ||||||||||
| 322 | |||||||||||
| 323 | =item * C<hueOption> | ||||||||||
| 324 | |||||||||||
| 325 | =item * C<hex> | ||||||||||
| 326 | |||||||||||
| 327 | =item * C<keywords> | ||||||||||
| 328 | |||||||||||
| 329 | =item * C<keywordExact> | ||||||||||
| 330 | |||||||||||
| 331 | =item * C<orderCol> | ||||||||||
| 332 | |||||||||||
| 333 | =item * C<sortBy> | ||||||||||
| 334 | |||||||||||
| 335 | =item * C<numResults> | ||||||||||
| 336 | |||||||||||
| 337 | =item * C<resultOffset> | ||||||||||
| 338 | |||||||||||
| 339 | =item * C<showPaletteWidths> | ||||||||||
| 340 | |||||||||||
| 341 | =back | ||||||||||
| 342 | |||||||||||
| 343 | I<Output>: B<C<ARRAYREF> of C<HASHREF>s> | ||||||||||
| 344 | |||||||||||
| 345 | Format same as that for L</palette>. | ||||||||||
| 346 | |||||||||||
| 347 | =head2 C<palette_random> | ||||||||||
| 348 | |||||||||||
| 349 | I<Input>: B<C<UNDEF>> | ||||||||||
| 350 | |||||||||||
| 351 | I<Output>: B<C<HASHREF>> | ||||||||||
| 352 | |||||||||||
| 353 | Format same as that for L</palette>. | ||||||||||
| 354 | |||||||||||
| 355 | =head2 C<pattern> | ||||||||||
| 356 | |||||||||||
| 357 | I<Input>: B<C<SCALAR>> | ||||||||||
| 358 | |||||||||||
| 359 | =over 4 | ||||||||||
| 360 | |||||||||||
| 361 | =item * C<'pattern_id'> | ||||||||||
| 362 | |||||||||||
| 363 | A valid pattern ID like C<1451>. | ||||||||||
| 364 | |||||||||||
| 365 | =back | ||||||||||
| 366 | |||||||||||
| 367 | I<Output>: B<C<ARRAYREF> of C<HASHREF>s> | ||||||||||
| 368 | |||||||||||
| 369 | =over 4 | ||||||||||
| 370 | |||||||||||
| 371 | =item * C<id> | ||||||||||
| 372 | |||||||||||
| 373 | =item * C<title> | ||||||||||
| 374 | |||||||||||
| 375 | =item * C<userName> | ||||||||||
| 376 | |||||||||||
| 377 | =item * C<numViews> | ||||||||||
| 378 | |||||||||||
| 379 | =item * C<numVotes> | ||||||||||
| 380 | |||||||||||
| 381 | =item * C<numComments> | ||||||||||
| 382 | |||||||||||
| 383 | =item * C<numHearts> | ||||||||||
| 384 | |||||||||||
| 385 | =item * C<rank> | ||||||||||
| 386 | |||||||||||
| 387 | =item * C<dateCreated> | ||||||||||
| 388 | |||||||||||
| 389 | =item * C<colors> | ||||||||||
| 390 | |||||||||||
| 391 | =item * C<description> | ||||||||||
| 392 | |||||||||||
| 393 | =item * C<url> | ||||||||||
| 394 | |||||||||||
| 395 | =item * C<imageUrl> | ||||||||||
| 396 | |||||||||||
| 397 | =item * C<badgeUrl> | ||||||||||
| 398 | |||||||||||
| 399 | =item * C<apiUrl> | ||||||||||
| 400 | |||||||||||
| 401 | =back | ||||||||||
| 402 | |||||||||||
| 403 | =head2 C<patterns>, C<patterns_new> and C<patterns_top> | ||||||||||
| 404 | |||||||||||
| 405 | I<Input>: B<C<HASHREF>> (optional) | ||||||||||
| 406 | |||||||||||
| 407 | =over 4 | ||||||||||
| 408 | |||||||||||
| 409 | =item * C<lover> | ||||||||||
| 410 | |||||||||||
| 411 | =item * C<hueOption> | ||||||||||
| 412 | |||||||||||
| 413 | =item * C<hex> | ||||||||||
| 414 | |||||||||||
| 415 | =item * C<keywords> | ||||||||||
| 416 | |||||||||||
| 417 | =item * C<keywordExact> | ||||||||||
| 418 | |||||||||||
| 419 | =item * C<orderCol> | ||||||||||
| 420 | |||||||||||
| 421 | =item * C<sortBy> | ||||||||||
| 422 | |||||||||||
| 423 | =item * C<numResults> | ||||||||||
| 424 | |||||||||||
| 425 | =item * C<resultOffset> | ||||||||||
| 426 | |||||||||||
| 427 | =back | ||||||||||
| 428 | |||||||||||
| 429 | I<Output>: B<C<ARRAYREF> of C<HASHREF>s> | ||||||||||
| 430 | |||||||||||
| 431 | Format same as that for L</pattern>. | ||||||||||
| 432 | |||||||||||
| 433 | =head2 C<pattern_random> | ||||||||||
| 434 | |||||||||||
| 435 | I<Input>: B<C<UNDEF>> | ||||||||||
| 436 | |||||||||||
| 437 | I<Output>: B<C<HASHREF>> | ||||||||||
| 438 | |||||||||||
| 439 | Format same as that for L</pattern>. | ||||||||||
| 440 | |||||||||||
| 441 | =head2 C<stats_colors> | ||||||||||
| 442 | |||||||||||
| 443 | Returns total number of colors. | ||||||||||
| 444 | |||||||||||
| 445 | =head2 C<stats_lovers> | ||||||||||
| 446 | |||||||||||
| 447 | Returns total number of lovers. | ||||||||||
| 448 | |||||||||||
| 449 | =head2 C<stats_palettes> | ||||||||||
| 450 | |||||||||||
| 451 | Returns total number of palettes. | ||||||||||
| 452 | |||||||||||
| 453 | =head2 C<stats_patterns> | ||||||||||
| 454 | |||||||||||
| 455 | Returns total number of patterns. | ||||||||||
| 456 | |||||||||||
| 457 | =encoding utf8 | ||||||||||
| 458 | |||||||||||
| 459 | =head1 SEE ALSO | ||||||||||
| 460 | |||||||||||
| 461 | L<COLOURLovers API Documentation|http://www.colourlovers.com/api> | ||||||||||
| 462 | |||||||||||
| 463 | =head1 ATTRIBUTION CREDIT | ||||||||||
| 464 | |||||||||||
| 465 | L<COLOURlovers.com|http://www.colourlovers.com/> | ||||||||||
| 466 | |||||||||||
| 467 | =head1 AUTHOR | ||||||||||
| 468 | |||||||||||
| 469 | Alan Haggai Alavi <alanhaggai@alanhaggai.org> | ||||||||||
| 470 | |||||||||||
| 471 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 472 | |||||||||||
| 473 | This software is copyright (c) 2011 by Alan Haggai Alavi. | ||||||||||
| 474 | |||||||||||
| 475 | This is free software; you can redistribute it and/or modify it under | ||||||||||
| 476 | the same terms as the Perl 5 programming language system itself. | ||||||||||
| 477 | |||||||||||
| 478 | =cut | ||||||||||
| 479 | |||||||||||
| 480 | |||||||||||
| 481 | __END__ | ||||||||||