Created
September 5, 2013 03:11
-
-
Save sharl/6445616 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use Net::GrowthForecast; | |
{ | |
package Net::GrowthForecast; | |
sub create_complex { | |
my ($self, $service_name, $section_name, $graph_name, $description, $sumup, $sort, @graph_params) = @_; | |
# | |
# parameter checks ... | |
# | |
my $spec = +{ | |
service_name => $service_name, | |
section_name => $section_name, | |
graph_name => $graph_name, | |
description => $description || '', | |
sumup => $sumup ? JSON::XS::true : JSON::XS::false, | |
sort => int($sort), | |
data => [ | |
map { | |
croak 'graph_id is not defined' unless defined $_->{graph_id}; | |
+{ | |
graph_id => $_->{graph_id}, | |
stack => $_->{stack} ? JSON::XS::true : JSON::XS::false, | |
type => defined $_->{type} ? $_->{type} : $self->graph($_->{graph_id})->{type}, | |
gmode => defined $_->{gmode} ? $_->{gmode} : $self->graph($_->{graph_id})->{gmode}, | |
} | |
} @graph_params | |
], | |
}; | |
$self->_add_complex($spec); | |
} | |
} | |
my $gf = Net::GrowthForecast->new; | |
$gf->create_complex( | |
qw(weather sapporo complex), | |
'test desc', | |
0, # sumup | |
19, # sort order | |
{ | |
graph_id => $gf->by_name(qw(weather sapporo temp))->{id}, | |
gmode => 'gauge', | |
stack => 0, | |
}, | |
{ | |
graph_id => $gf->by_name(qw(weather sapporo rain))->{id}, | |
gmode => 'gauge', | |
stack => 0, | |
}, | |
{ | |
graph_id => $gf->by_name(qw(weather sapporo snow))->{id}, | |
gmode => 'gauge', | |
stack => 0, | |
}, | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment