Class: Tracker::Deliverer

Inherits:
Object
  • Object
show all
Defined in:
lib/pivotal-git-tracker/deliverer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project, git) ⇒ Deliverer

Returns a new instance of Deliverer.



4
5
6
7
# File 'lib/pivotal-git-tracker/deliverer.rb', line 4

def initialize(project, git)
  @project = project
  @git = git
end

Instance Attribute Details

#gitObject (readonly)

Returns the value of attribute git.



3
4
5
# File 'lib/pivotal-git-tracker/deliverer.rb', line 3

def git
  @git
end

#projectObject (readonly)

Returns the value of attribute project.



3
4
5
# File 'lib/pivotal-git-tracker/deliverer.rb', line 3

def project
  @project
end

Instance Method Details

#find_and_comment(branch = nil, server_name = nil, version = nil) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/pivotal-git-tracker/deliverer.rb', line 25

def find_and_comment(branch = nil, server_name = nil, version = nil)
  options = {}
  options[:branch] = branch if branch

  for story_id in git.latest_log(options)
    story = project.find(story_id)
    if story
      puts "Found story with id #{story_id} on server #{server_name}"
      project.comment(story, server_name)
      project.add_label(story, version) if version
    end
  end
end

#mark_as_delivered(branch = nil, server_name = nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/pivotal-git-tracker/deliverer.rb', line 9

def mark_as_delivered(branch = nil, server_name = nil)
  options = {}
  options[:branch] = branch if branch

  collection = project.finished

  collection.each do |story|
    puts "Found finished story in Pivotal with id #{story.id}"
    if git.contains?(story.id, options)
      puts "Delivering story with id #{story.id} on server #{server_name}"
      project.deliver(story)
      project.comment(story, server_name) if server_name
    end
  end
end