Class: FlashFlow::IssueTracker::Pivotal

Inherits:
Object
  • Object
show all
Includes:
TimeHelper
Defined in:
lib/flash_flow/issue_tracker/pivotal.rb

Instance Method Summary collapse

Methods included from TimeHelper

#with_time_zone

Constructor Details

#initialize(branches, git, opts = {}) ⇒ Pivotal

Returns a new instance of Pivotal.



10
11
12
13
14
15
16
17
18
19
# File 'lib/flash_flow/issue_tracker/pivotal.rb', line 10

def initialize(branches, git, opts={})
  @branches = branches
  @git = git
  @timezone = opts['timezone'] || "UTC"
  @project_id = opts['project_id']

  PivotalTracker::Client.token = opts['token']
  PivotalTracker::Client.use_ssl = true
  @release_label_prefix = Regexp.new("^#{opts['release_label_prefix'] || 'release'}", Regexp::IGNORECASE)
end

Instance Method Details

#production_deployObject



43
44
45
46
47
48
49
# File 'lib/flash_flow/issue_tracker/pivotal.rb', line 43

def production_deploy
  shipped_branches.each do |branch|
    branch.stories.to_a.each do |story_id|
      comment(story_id)
    end
  end
end

#release_keys(story_id) ⇒ Object



79
80
81
82
83
84
85
# File 'lib/flash_flow/issue_tracker/pivotal.rb', line 79

def release_keys(story_id)
  story = get_story(story_id)

  return [] unless story && story.labels

  story.labels.split(",").map(&:strip).select { |label| label =~ @release_label_prefix }.map(&:strip)
end

#release_notes(hours, file = STDOUT) ⇒ Object



51
52
53
54
55
56
57
58
59
# File 'lib/flash_flow/issue_tracker/pivotal.rb', line 51

def release_notes(hours, file=STDOUT)
  release_stories = done_and_current_stories.map do |story|
    shipped_text = has_shipped_text?(story)
    format_release_data(story.id, story.name, shipped_text) if shipped_text
  end.compact

  release_notes = release_by(release_stories, hours)
  print_release_notes(release_notes, file)
end

#stories_deliveredObject



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/flash_flow/issue_tracker/pivotal.rb', line 29

def stories_delivered
  merged_branches.each do |branch|
    branch.stories.to_a.each do |story_id|
      deliver(story_id)
    end
  end

  removed_and_failed_branches.each do |branch|
    branch.stories.to_a.each do |story_id|
      undeliver(story_id)
    end
  end
end

#stories_for_release(release_key) ⇒ Object



87
88
89
# File 'lib/flash_flow/issue_tracker/pivotal.rb', line 87

def stories_for_release(release_key)
  stories_for_label(release_key)
end

#stories_pushedObject



21
22
23
24
25
26
27
# File 'lib/flash_flow/issue_tracker/pivotal.rb', line 21

def stories_pushed
  if merged_working_branch
    merged_working_branch.stories.to_a.each do |story_id|
      finish(story_id)
    end
  end
end

#story_deployable?(story_id) ⇒ Boolean

Returns:

  • (Boolean)


61
62
63
64
65
# File 'lib/flash_flow/issue_tracker/pivotal.rb', line 61

def story_deployable?(story_id)
  story = get_story(story_id)

  story && story.current_state == 'accepted'
end

#story_link(story_id) ⇒ Object



67
68
69
70
71
# File 'lib/flash_flow/issue_tracker/pivotal.rb', line 67

def story_link(story_id)
  story = get_story(story_id)

  story.url if story
end

#story_title(story_id) ⇒ Object



73
74
75
76
77
# File 'lib/flash_flow/issue_tracker/pivotal.rb', line 73

def story_title(story_id)
  story = get_story(story_id)

  story.name if story
end