Sha256: a326170b838a71adccda826a50a4a44559fbf58827dd01dab0c77d3259a6ab56
Contents?: true
Size: 1019 Bytes
Versions: 1
Compression:
Stored size: 1019 Bytes
Contents
class TrackerFetchedMapper def initialize(renderer) @renderer = renderer end def execute(story_commit) @renderer.render(map(story_commit)) end def map(story_commit) {}.tap do |h| fetch(story_commit.keys).each do |story, state| h[story_commit[story]] = {'story' => story, 'state' => state} end end end def fetch(stories) require 'rubygems' require 'net/http' require 'uri' require 'nokogiri' request = "http://www.pivotaltracker.com/services/v3/projects/#{ENV['TRACKER_PROJECT_ID']}/stories?filter=id:#{stories.join(',')}&includedone:true" resource_uri = URI.parse(request) response = Net::HTTP.start(resource_uri.host, resource_uri.port) do |http| http.get(resource_uri.to_s, {'X-TrackerToken' => ENV['TRACKER_TOKEN']}) end doc = Nokogiri::XML(response.body) {}.tap do |h| doc.xpath('//stories/story').map do |e| h[e.xpath('id').text] = e.xpath('current_state').text.to_sym end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
git_story-0.1.0 | lib/tracker_fetched_mapper.rb |