t qw[ WWW::EchoNest::CatalogProxy Exporter ];
use 5.010;
use strict;
use warnings;
use Carp;
use JSON;
use WWW::EchoNest::Logger qw( get_logger );
use WWW::EchoNest::Result::List;
use WWW::EchoNest:
$_[0]->get_name . q['>];
}
sub _types { WWW::EchoNest::CatalogProxy::_types }
sub _pretty_json { to_json( $_[0], { utf8 => 1, pretty => 1 } ) }
my @acceptable_actions = qw( delete update play skip
em_id"
if $item_id !~ /[[:alpha:][:digit:][:punct:]]+/;
}
my $data = _pretty_json( $items_aref );
$logger->debug('items: ' . $data);
my $result = $self->post_attribu
et_catalog',
'get_playlist',
'get_song',
'get_track',
'pretty_json',
'set_log_level',
'set_codegen_path',
'set_api_key',
);
o
$_[0] );
}
sub set_api_key {
WWW::EchoNest::Config::set_api_key( $_[0] );
}
use JSON;
sub pretty_json { to_json( $_[0], { utf8 => 1, pretty => 1 } ) }
use WWW::EchoNest::Logger;
sub set_log_leve
# Imports:
# - get_artist
# - get_catalog
# - get_playlist
# - get_song
# - get_track
# - pretty_json
# - set_log_level
# - set_codegen_path
# - set_api_key
# Each of which can also be imported indiv
= qw( profile search_song identify );
}
use parent qw( WWW::EchoNest::SongProxy Exporter );
use JSON;
use WWW::EchoNest::Functional qw(
any
se->{songs};
return if ! $songs_ref;
# $logger->debug('$songs_ref : ', $json->encode($songs_ref));
$self->{tracks} = [] if ! @cached_tracks;
# Build the ar
1;
eval {
$data = { query => encode_json($query_obj_ref) };
};
croak "Could not encode json string: $@" if $@;
}
if ($has_data) {
my $req
make_stupid_accessor
);
# Required CPAN modules
eval {
use JSON;
};
croak "$@" if $@;
use overload
'""' => '_stringify',
;
# FUNCTIONS #############
my $json_url = $audio_summary->{analysis_url};
my $json_response = user_agent()->get($json_url);
my $json_string;
if ( $json_response->is_success() ) {
$json_str
ing = $json_response->decoded_content()
} else {
croak "Could not get $json_url: $json_response->status_line()";
}
my $analysis = decode_json( $json_string );
my $nes
s;
use JSON qw( from_json );
sub palette {
my ( $self, $palette ) = @_;
my $response =
$self->{'ua'}
->post("http://www.colourlovers.com/api/palette/$palette?format=json");
return ( from_json $response->content )->[0];
}
sub palettes {
my ( $self, $args, $url ) = @_;
$args = Net::COLOURlovers::_build_parametres(
$args,
[
qw(
{'ua'}
->post( $url || 'http://www.colourlovers.com/api/palettes?format=json',
$args );
return from_json $response->content;
}
sub palettes_new {
my ( $self, $args ) = @_;
s;
use JSON qw( from_json );
sub pattern {
my ( $self, $pattern ) = @_;
my $response =
$self->{'ua'}
->post("http://www.colourlovers.com/api/pattern/$pattern?format=json");
return ( from_json $response->content )->[0];
}
sub patterns {
my ( $self, $args, $url ) = @_;
$args = Net::COLOURlovers::_build_parametres(
$args,
[
qw(
{'ua'}
->post( $url || 'http://www.colourlovers.com/api/patterns?format=json',
$args );
return from_json $response->content;
}
sub patterns_new {
my ( $self, $args ) = @_;
nings;
use JSON qw( from_json );
sub lover {
my ( $self, $lover ) = @_;
my $response =
$self->{'ua'}
->post("http://www.colourlovers.com/api/lover/$lover?format=json");
retu
->{'ua'}
->post( $url || 'http://www.colourlovers.com/api/lovers?format=json',
$args );
return from_json $response->content;
}
sub lovers_new {
my ( $self, $args ) = @_;
re
/api/lovers/new?format=json' );
}
sub lovers_top {
my ( $self, $args ) = @_;
return $self->lovers( $args,
'http://www.colourlovers.com/api/lovers/top?format=json' );
}
1;
__END__
=p
nings;
use JSON qw( from_json );
sub color {
my ( $self, $color ) = @_;
my $response =
$self->{'ua'}
->post("http://www.colourlovers.com/api/color/$color?format=json");
retu
->{'ua'}
->post( $url || 'http://www.colourlovers.com/api/colors?format=json',
$args );
return from_json $response->content;
}
sub colors_new {
my ( $self, $args ) = @_;
re
/api/colors/new?format=json' );
}
sub colors_top {
my ( $self, $args ) = @_;
return $self->colors( $args,
'http://www.colourlovers.com/api/colors/top?format=json' );
}
sub color_rand
rnings;
use JSON qw( from_json );
sub stats_colors {
my $self = shift;
my $response =
$self->{'ua'}
->post("http://www.colourlovers.com/api/stats/colors?format=json");
retu
$self->{'ua'}
->post("http://www.colourlovers.com/api/stats/lovers?format=json");
return ( from_json $response->content )->{'total'};
}
sub stats_palettes {
my $self = shift;
$self->{'ua'}
->post("http://www.colourlovers.com/api/stats/palettes?format=json");
return ( from_json $response->content )->{'total'};
}
sub stats_patterns {
my $self = shift;
= JSON::XS
module = YAML::XS
=head1 DESCRIPTION
Use this plugin instead of the regular C<ModuleBuild> plugin when you are
relying on XS modules that have a pure Perl fallback, eg L<JSON>, L<JSON:
:XS>
and L<JSON::PP>.
It generates a F<Build.PL> which will promote XS modules
from C<recommends> to C<requires> if there is a working C compiler.
This behaviour can be disabled by passing a C<--pp>
onfig
Template
Try::Tiny
Storable
Test::Exception
Carp::Clan
Bit::Vector
Date::Calc
common::sense
JSON::XS
URI
URI::Escape
Encode::DoubleEncodedUTF8
PadWalker
Devel::Caller
callee
String::Random
YAML:
ite
Crypt::RC4
IO::Stringy
OLE::Storage_Lite
Digest::Perl::MD5
Spreadsheet::ParseExcel
File::Type
JSON
Roman
HTML::HTMLDoc
LWP::MediaTypes
Encode::Local###Encode::LOcale
HTTP::Date
HTML::Tagset
HTML::
tab
YAML
DBD::Pg
Net::Google::DataAPI
GD::SecurityImage
version
Module::Metadata
CPAN::Meta::YAML
JSON::PP
Parse::CPAN::Meta
Version::Requirements
CPAN::Meta
Perl::OSType
ExtUtils::CBuilder
List::More
t/|
Makefile\.PL$|
README$|
MANIFEST$|
Changes$|
META\.json$|
META\.yml$|
[^\/]+\.xs$
)}x }
}
sub prune_files {
my $self = shift;
akefile\.PL$|
README$|
MANIFEST$|
Changes$|
META\.json$|
META\.yml$|
\.xs$
)}x
=head1 AUTHOR
Robert Krimen <robertkrim
package WWW::LongURL;
use JSON::Any;
use LWP::UserAgent;
use URI::Escape;
use strict;
use warnings;
use base qw(Class::Accessor::Fast);
__PACKAGE__->mk_accessors(qw(apibase useragent format error));
{};
bless $self, $class;
$self->apibase('http://api.longurl.org/v2/');
$self->format('json');
$self->useragent('WWW-LongURL/0.05');
return $self;
}
sub expand {
my ($self, $ur
t());
my $response = $ua->get($what);
if ($response->is_success()) {
return JSON::Any->jsonToObj($response->decoded_content());
} else {
$self->error($response->status_lin
in and/or token' );
return;
}
}
my $uri = "https://github.com/api/v2/json/repos/show/$login/$repository";
my $response = $agent->post( $uri,
[ login => $login,
d1 LICENSE
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=head1 Thanks
Thanks do Tatsuhiko Miyagawa for Catalyst::View::JSON :)
=cut
);
use Garivini::DB;
use Garivini::Client;
use Gearman::Client;
use Gearman::Worker;
use JSON;
use constant DEBUG => 0;
sub new {
my Garivini::Controller $self = shift;
$self = fiel
$sm_client = $self->{sm_client};
my $gm_client = $self->{gm_client};
my $sm_job = decode_json(${$gm_job->argref});
DEBUG && warn "Got a job $sm_job->{funcname}\n";
# NOTE: This passe
',
);
use Carp qw/croak/;
use Garivini::DB;
use Gearman::Client;
use IO::Socket;
use JSON;
use Data::Dumper qw/Dumper/;
# TODO: Make the "job" table name configurable:
# one dbid creates
iq} = $job->{uniqkey} if $job->{uniqkey};
$client->dispatch_background($funcname, \encode_json($job), \%opts);
}
}
# This isn't your typical worker, as in it doesn't register as a gearman
warnings;
use Garivini::DB;
use Garivini::Client;
use Gearman::Worker;
use Gearman::Client;
use JSON;
use Data::Dumper qw/Dumper/;
use fields (
'job_servers',
'sm_client',
my $self = shift;
my $job = shift;
my $queues = $self->{queues};
my $args = decode_json(${$job->argref});
my $run_job = 1;
if ($queues->{$args->{funcname}} && $queues->{$args->{
eue_watermark_depth}) {
$run_job = 0;
}
# TODO: Uhh if $job->{arg} was a cuddled JSON blob, did this just decode
# that? Easy enough to test and fix, but I'm tired :P
$args->{
->insert_job(funcname => 'hello', arg => 'world');
# Worker
use Gearman::Worker;
use JSON;
my $cli = Garivini::Client->new(dbs => {
1 => { id => 1, dsn => 'DBI:mysql:job:host
gister_function('hello' => \&hello);
$worker->work;
sub hello {
my $job = decode_json(${$_[0]->argref});
print "Hello ", $job->{arg}, "\n";
$cli->complete_job($job);
world');
# Meanwhile, in a worker
use Gearman::Worker;
use Garivini::Client;
use JSON;
my $cli = Garivini::Client->new(dbs => {
1 => { id => 1, dsn => 'DBI:mysql:job:host
gister_function('hello' => \&hello);
$worker->work;
sub hello {
my $job = decode_json(${$_[0]->argref});
print "Hello ", $job->{arg}, "\n";
$cli->complete_job($job);
ient
use Gearman::Client;
use JSON;
my $cli = Gearman::Client->new;
$cli->job_servers('127.0.0.1');
$cli->do_task('inject_jobs', \encode_json({ funcname => 'hello',
arg =>