class PivotalIntegration::Util::Label
Utilities for dealing with the shell
Public Class Methods
Add labels to story if they are not already appended to story.
@param [PivotalTracker::Story, String] labels as Strings, one label per parameter. @return [boolean] Boolean defining whether story was updated or not.
# File lib/pivotal-integration/util/label.rb, line 25 def self.add(story, *labels) current_labels = story.labels.split(',') rescue [] new_labels = current_labels | labels if story.update(:labels => new_labels) puts "Updated labels on #{story.name}:" puts "#{current_labels} => #{new_labels}" else abort("Failed to update labels on Pivotal Tracker") end end
Print labels from story.
@param [PivotalTracker::Story, String] labels as Strings, one label per parameter. @return [boolean] Boolean defining whether story was updated or not.
# File lib/pivotal-integration/util/label.rb, line 68 def self.list(story) puts "Story labels:" puts story.labels.split(',') rescue [] end
Add labels from story and remove those labels from every other story in a project.
@param [PivotalTracker::Story, String] labels as Strings, one label per parameter. @return [boolean] Boolean defining whether story was updated or not.
# File lib/pivotal-integration/util/label.rb, line 40 def self.once(story, *labels) PivotalTracker::Project.find(story.project_id).stories.all.each do |other_story| self.remove(other_story, *labels) if story.name != other_story.name and other_story.labels and (other_story.labels.split(',') & labels).any? end self.add(story, *labels) end
Remove labels from story.
@param [PivotalTracker::Story, String] labels as Strings, one label per parameter. @return [boolean] Boolean defining whether story was updated or not.
# File lib/pivotal-integration/util/label.rb, line 53 def self.remove(story, *labels) current_labels = story.labels.split(',') rescue [] new_labels = current_labels - labels if story.update(:labels => new_labels) puts "Updated labels on #{story.name}:" puts "#{current_labels} => #{new_labels}" else abort("Failed to update labels on Pivotal Tracker") end end