Class: PivotalTracker
Instance Attribute Summary
Attributes inherited from Tracker
Instance Method Summary collapse
- #extract_story_ids(commits_list) ⇒ Object
- #fetch_story_data(obj_path, token) ⇒ Object
-
#initialize(tracker_ids = PIVOTAL_TRACKER_PROJECT_IDS, api_key = PIVOTAL_TRACKER_TOKEN) ⇒ PivotalTracker
constructor
A new instance of PivotalTracker.
- #load_stories(story_id_list = nil, show_progress = false) ⇒ Object
- #story_obj(story_id, progress_bar = nil) ⇒ Object
Constructor Details
#initialize(tracker_ids = PIVOTAL_TRACKER_PROJECT_IDS, api_key = PIVOTAL_TRACKER_TOKEN) ⇒ PivotalTracker
Returns a new instance of PivotalTracker.
24 25 26 27 28 |
# File 'lib/tracker.rb', line 24 def initialize(tracker_ids = PIVOTAL_TRACKER_PROJECT_IDS,api_key = PIVOTAL_TRACKER_TOKEN) @tracker_ids = tracker_ids @api_key = api_key super(@tracker_ids,@api_key) end |
Instance Method Details
#extract_story_ids(commits_list) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/tracker.rb', line 30 def extract_story_ids(commits_list) stories = {} untagged_commits = [] commits_list.each { |c| = c..scan(@tag_pattern) if .empty? untagged_commits << c else .flatten.each {|s| @story_ids << s stories[s] ||= [] stories[s] << c.oid.to_s } end } return stories,untagged_commits end |
#fetch_story_data(obj_path, token) ⇒ Object
90 91 92 93 94 95 96 97 98 99 |
# File 'lib/tracker.rb', line 90 def fetch_story_data(obj_path,token) url = "http://www.pivotaltracker.com/services/v3/#{obj_path}" resource_uri = URI.parse(url) response = Net::HTTP.start(resource_uri.host, resource_uri.port) do |http| http.get(resource_uri.path, {'X-TrackerToken' => "#{token}"}) end doc = Hpricot(response.body) rescue doc = Hpricot("<xml></xml>") end |
#load_stories(story_id_list = nil, show_progress = false) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/tracker.rb', line 49 def load_stories(story_id_list = nil,show_progress = false) unless story_id_list.nil? @story_ids = story_id_list end @stories = [] if show_progress = ProgressBar.new("Fetching...", @story_ids.length * @tracker_ids.length) . = '=' end @story_ids.each do |story_id| story = story_obj(story_id,) if story @stories << story else puts "WARNING: Story(#{story_id}) not found in any tracker(#{@tracker_ids.inspect})" end end .finish if show_progress @stories end |
#story_obj(story_id, progress_bar = nil) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/tracker.rb', line 70 def story_obj(story_id, = nil) @tracker_ids.each { |tracker_id| obj = fetch_story_data("/projects/#{tracker_id}/stories/#{story_id}",@api_key) story_obj = obj.at('story') unless story_obj.nil? story = { :id => story_id, :name => story_obj.at('name').innerHTML, :type => story_obj.at('story_type').innerHTML, :requested_by => story_obj.at('requested_by').innerHTML, :url => story_obj.at('url').innerHTML, :status => story_obj.at('current_state').innerHTML } return story end .inc if } return nil end |