Last active
August 29, 2015 14:00
-
-
Save jacaetevha/11042884 to your computer and use it in GitHub Desktop.
Pivotal Tracker Story Textalizer
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/env ruby | |
require 'open-uri' | |
require "rexml/document" | |
TOKEN = ENV['TOKEN'] || '****' | |
PROJECT = ENV['PROJECT'] || '****' | |
STORY = ENV['STORY'] || ARGV[0] | |
# ripped from Rails | |
def word_wrap(text, line_width=40) | |
text.split("\n").collect! do |line| | |
line.length > line_width ? line.gsub(/(.{1,#{line_width}})(\s+|$)/, "\\1\n").strip : line | |
end * "\n" | |
end | |
xml = open("http://www.pivotaltracker.com/services/v3/projects/#{PROJECT}/stories/#{STORY}", "X-TrackerToken" => TOKEN) | |
doc = REXML::Document.new(xml).root | |
puts %q{***************************************** | |
***************************************** | |
} | |
puts word_wrap("#{STORY}: #{doc.elements.to_a('//story/name').first.text}") | |
puts | |
puts word_wrap(doc.elements.to_a("//story/description").first.text) | |
puts | |
count = 0 | |
doc.elements.to_a('//story/tasks/task/description').each.with_index do |el, index| | |
text = el.text | |
if text =~ /DC\s*\d+\s*\[/ | |
puts word_wrap(text) | |
else | |
puts word_wrap("DC#{index + 1} [ ] - #{text}") | |
end | |
end | |
puts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment