Skip to content

Instantly share code, notes, and snippets.

@moznion
Created September 2, 2012 14:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moznion/3599242 to your computer and use it in GitHub Desktop.
Save moznion/3599242 to your computer and use it in GitHub Desktop.
gitPullSuspender_proto
#!/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