Skip to content

Instantly share code, notes, and snippets.

@rubys
Created September 22, 2013 13:54
Show Gist options
  • Save rubys/6660094 to your computer and use it in GitHub Desktop.
Save rubys/6660094 to your computer and use it in GitHub Desktop.
#!/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(nil, payload: {field: field}) do |response|
$document.find('.' + field).text = response.json
end
end
end
end
_json do
if @field == 'opal'
_ Nokogiri::HTML5.get('http://rubygems.org/gems/opal').
at('.title h3').text
elsif @field == 'gumbo'
_ Nokogiri::HTML5.
get('https://github.com/google/gumbo-parser/commits/master').
at('.authorship time')['datetime']
elsif @field == 'nokogumbo'
_ Nokogiri::HTML5.get('http://rubygems.org/gems/nokogumbo').
search('.downloads strong').last.text
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment