Open
Description
It would be nice if I could fetch the total number of contributors in a time window.
Currently, I'm parsing using Nokogiri, but I guess that's fine.
Sample code fwiw:
class Contributors
attr_accessor :body, :start_date, :end_date, :total
def initialize(start_date, end_date)
@start_date = start_date.strftime("%Y%m%d")
@end_date = end_date.strftime("%Y%m%d")
@body = fetch
@total = extract_total
end
def url
"https://contributors.rubyonrails.org/contributors/in-time-window/#{@start_date}-#{@end_date}"
end
def fetch
uri = URI.parse(url)
body = uri.open.read
return Nokogiri::HTML(body)
end
def extract_total
xpath = "//span[@class=\"listing-total\"][1]"
text = @body.xpath(xpath.to_s).first.content
return text.match(/\d+/)
end
end
Metadata
Metadata
Assignees
Labels
No labels