Last active
December 23, 2015 14:49
-
-
Save rubys/6651139 to your computer and use it in GitHub Desktop.
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/ruby | |
require 'wunderbar/opal-jquery' | |
require 'nokogumbo' | |
_html do | |
_head do | |
_title 'Various stats' | |
end | |
_body do | |
_table do | |
_tr do | |
_td 'Opal gem version' | |
_td.opal | |
end | |
_tr do | |
_td 'Gumbo-parser last update' | |
_td.gumbo | |
end | |
_tr do | |
_td 'Nokogumbo downloads' | |
_td.nokogumbo | |
end | |
end | |
end | |
_script do | |
%w(opal gumbo nokogumbo).each do |field| | |
HTTP.post(ENV['REQUEST_URI'], payload: "field=#{field}") do |response| | |
response.json.each do |name, value| | |
$document.find('.' + name).text = value | |
end | |
end | |
end | |
end | |
end | |
_json do | |
if @field == 'opal' | |
_opal Nokogiri::HTML5.get('http://rubygems.org/gems/opal'). | |
at('.title h3').text | |
elsif @field == 'gumbo' | |
_gumbo Nokogiri::HTML5. | |
get('https://github.com/google/gumbo-parser/commits/master'). | |
at('.authorship time')['datetime'] | |
elsif @field == 'nokogumbo' | |
_nokogumbo Nokogiri::HTML5.get('http://rubygems.org/gems/nokogumbo'). | |
search('.downloads strong').last.text | |
else | |
_no 'data' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment