Class: PivotalAngel::Label

Inherits:
Object
  • Object
show all
Defined in:
lib/pivotal_angel/label.rb

Class Method Summary collapse

Class Method Details

.apply_to(stories, label) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/pivotal_angel/label.rb', line 7

def apply_to(stories, label)
  stories.each do |s|
    story = get_story(s)
    labels = story.labels.split(',')
    labels << label unless labels.include?(label)
    story.update(:labels => labels.join(','))
  end
end

.remove_from(stories, label) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/pivotal_angel/label.rb', line 16

def remove_from(stories, label)
  stories.each do |s|
    story = get_story(s)
    labels = story.labels.split(',')
    labels.delete label
    story.update(:labels => labels.join(','))
  end
end

.rename(project, old_label, new_label) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/pivotal_angel/label.rb', line 25

def rename(project, old_label, new_label)
  stories = project.stories.all(:label => old_label)
  stories.each do |story|
    labels = story.labels.split(',')
    labels.delete(old_label)
    labels << new_label
    story.update(:labels => labels.join(','))
  end
end