Created
April 18, 2013 13:12
-
-
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.
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 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