Class: FlashFlow::MergeMaster::Status

Inherits:
Object
  • Object
show all
Defined in:
lib/flash_flow/merge_master/status.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(issue_tracker_config, branches_config, branch_info_file, git_config, opts = {}) ⇒ Status

Returns a new instance of Status.



8
9
10
11
# File 'lib/flash_flow/merge_master/status.rb', line 8

def initialize(issue_tracker_config, branches_config, branch_info_file, git_config, opts={})
  @issue_tracker = IssueTracker::Base.new(issue_tracker_config)
  @collection = Data::Base.new(branches_config, branch_info_file, ShadowGit.new(git_config)).merged_branches
end

Instance Attribute Details

#collectionObject (readonly)

Returns the value of attribute collection.



6
7
8
# File 'lib/flash_flow/merge_master/status.rb', line 6

def collection
  @collection
end

#issue_trackerObject (readonly)

Returns the value of attribute issue_tracker.



6
7
8
# File 'lib/flash_flow/merge_master/status.rb', line 6

def issue_tracker
  @issue_tracker
end

#releasesObject (readonly)

Returns the value of attribute releases.



6
7
8
# File 'lib/flash_flow/merge_master/status.rb', line 6

def releases
  @releases
end

#storiesObject (readonly)

Returns the value of attribute stories.



6
7
8
# File 'lib/flash_flow/merge_master/status.rb', line 6

def stories
  @stories
end

Instance Method Details

#branchesObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/flash_flow/merge_master/status.rb', line 25

def branches
  g = ReleaseGraph.build(collection.current_branches, issue_tracker)

  branch_hash = {}
  collection.current_branches.each_with_index do |branch, i|
    connected_branches = g.connected_branches(branch.ref)
    connected_stories = g.connected_stories(branch.ref)
    connected_releases = g.connected_releases(branch.ref)
    add_stories(connected_stories)
    add_releases(connected_releases)
    sub_g = ReleaseGraph.build(connected_branches, issue_tracker)
    graph_file = sub_g.output("/tmp/graph-#{i}.png")

    branch_hash[branch] =
        Hash.new.tap do |hash|
          hash[:name] = branch.ref
          hash[:branch_url] = collection.branch_link(branch)
          hash[:branch_can_ship?] = collection.can_ship?(branch)
          hash[:connected_branches] = connected_branches
          hash[:image] = graph_file
          hash[:my_stories] = branch.stories.to_a
          hash[:stories] = connected_stories
          hash[:releases] = connected_releases
        end
  end

  mark_as_shippable(branch_hash)
  branch_hash
end

#status(filename = nil) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/flash_flow/merge_master/status.rb', line 13

def status(filename=nil)
  filename = File.dirname(__FILE__) + '/merge_status.html'
  @branches = branches

  template = ERB.new File.read(File.dirname(__FILE__) + '/merge_status.html.erb')
  html = template.result(binding)
  File.open(filename, 'w') do |f|
    f.puts html
  end
  `open #{filename}`
end