Created
April 23, 2011 01:17
-
-
Save atoulme/938094 to your computer and use it in GitHub Desktop.
Extract Greenhopper graph from Jira using Ruby
This file contains hidden or 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
require 'rubygems' | |
require 'net/http' | |
require 'hpricot' | |
SERVER = "jira.example.com" | |
GRAPH_URL = "/secure/ChartBoard.jspa?type=CCB&selectedProjectId=xxxxx&selectedBoardId=xxxxxx&colPage=1" | |
Net::HTTP.start(SERVER) {|http| | |
req = Net::HTTP::Get.new(GRAPH_URL) | |
resp = http.request(req) | |
html = Hpricot(resp.body) | |
graph = html.search("img").select {|src| src.to_s.match /\/charts/}[0].attributes["src"] | |
req2 = Net::HTTP::Get.new(graph) | |
File.open("file.png", "w+") { |f| | |
f.write http.request(req2).body | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment