Skip to content

Instantly share code, notes, and snippets.

@mlbright
Created April 18, 2013 13:12
Show Gist options
  • Save mlbright/5412571 to your computer and use it in GitHub Desktop.
Save mlbright/5412571 to your computer and use it in GitHub Desktop.
Should you upgrade Jenkins to the latest version? Here's the ratio of sunny ratings to the number of cloudy and stormy ratings.
#!/usr/bin/env perl
use 5.010;
use strict;
use warnings;
use HTTP::Tiny;
my $ratings = 'http://jenkins-ci.org/rate/result.php';
my $response = HTTP::Tiny->new->get($ratings);
die "Failed!\n" unless $response->{success};
die "no results ... \n" unless ( length $response->{content} );
my %releases;
for ( split /\n/, $response->{content} ) {
next unless ( $_ =~ /^'.+'/ );
my ( $version, $values ) = $_ =~ m/^'(.+)':\s+\[(.+)\]/;
my ( $sunny, $cloudy, $stormy ) = split /,/, $values;
$releases{$version} = [ $sunny, $cloudy, $stormy ];
}
my @keys = sort keys %releases;
my $latest = pop @keys;
my ( $sunny, $cloudy, $stormy ) = @{ $releases{$latest} };
say sprintf "Yes, with %.2f%% confidence", $sunny / ( $sunny + $cloudy + $stormy ) * 100;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment