Created
September 2, 2012 14:04
-
-
Save moznion/3599242 to your computer and use it in GitHub Desktop.
gitPullSuspender_proto
This file contains hidden or 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/perl | |
use strict; | |
use warnings; | |
use 5.012; | |
use WebService::Simple; | |
my $target_username = "plack"; # <= It's test var! Hehe. FIXME | |
my $target_reponame = "Plack"; # <= It's test var! Hehe. FIXME | |
my $query = "pulls"; | |
my $polling_interval = 6000; | |
my $github = WebService::Simple->new( | |
base_url => 'https://api.github.com/', | |
response_parser => 'JSON' | |
); | |
while (1) { | |
my $number_of_pull_requests = 0; | |
my $pull_requests = $github->get( "repos/$target_username/$target_reponame/$query" ); | |
my $parsed_pull_requests = $pull_requests->parse_response; | |
foreach my $list (@{ $parsed_pull_requests }) { | |
foreach my $key (keys %{ $list }) { | |
if ($key ~~ /number/) { | |
$number_of_pull_requests++; | |
} | |
} | |
} | |
# Following statements will replace from outputting message to outputting images. | |
given ($number_of_pull_requests) { | |
when (0) { say "I'm Okay." }; | |
when (0 < $_ && $_ <= 10) { say "Oops..." }; | |
when (10 < $_ && $_ <= 30) { say "Ugggg...."}; | |
when ($_ > 30) { say "HELP!" }; | |
} | |
sleep($polling_interval); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment