Skip to content

Instantly share code, notes, and snippets.

@pj4533
Created May 9, 2018 12:49
Show Gist options
  • Save pj4533/927abe2c288f0cd692e1a83684b65a90 to your computer and use it in GitHub Desktop.
Save pj4533/927abe2c288f0cd692e1a83684b65a90 to your computer and use it in GitHub Desktop.
Quick script to get status of a travis repo from the SVG link on the command line
#!/usr/bin/env ruby
require 'nokogiri'
require 'open-uri'
html_data = open(ARGV[0]).read
@test = Nokogiri::HTML(html_data)
status_string = @test.xpath('//text').map.each.each { |i| i.inner_text }.last
color_code = 31 # red
if status_string == "passing"
color_code = 32 # green
end
puts "\e[#{color_code}m#{status_string}\e[0m"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment