Class: FlashFlow::Merge::ReleaseGraph
- Inherits:
-
Object
- Object
- FlashFlow::Merge::ReleaseGraph
- Defined in:
- lib/flash_flow/merge/release_graph.rb
Instance Attribute Summary collapse
-
#branches ⇒ Object
Returns the value of attribute branches.
-
#issue_tracker ⇒ Object
Returns the value of attribute issue_tracker.
Class Method Summary collapse
Instance Method Summary collapse
- #build ⇒ Object
- #connected_branches(node_id) ⇒ Object
- #connected_releases(node_id) ⇒ Object
- #connected_stories(node_id) ⇒ Object
-
#initialize(branches, issue_tracker) ⇒ ReleaseGraph
constructor
A new instance of ReleaseGraph.
- #output(png_file) ⇒ Object
Constructor Details
#initialize(branches, issue_tracker) ⇒ ReleaseGraph
Returns a new instance of ReleaseGraph.
14 15 16 17 |
# File 'lib/flash_flow/merge/release_graph.rb', line 14 def initialize(branches, issue_tracker) @issue_tracker = issue_tracker @branches = branches end |
Instance Attribute Details
#branches ⇒ Object
Returns the value of attribute branches.
6 7 8 |
# File 'lib/flash_flow/merge/release_graph.rb', line 6 def branches @branches end |
#issue_tracker ⇒ Object
Returns the value of attribute issue_tracker.
6 7 8 |
# File 'lib/flash_flow/merge/release_graph.rb', line 6 def issue_tracker @issue_tracker end |
Class Method Details
.build(branches, issue_tracker) ⇒ Object
8 9 10 11 12 |
# File 'lib/flash_flow/merge/release_graph.rb', line 8 def self.build(branches, issue_tracker) instance = new(branches, issue_tracker) instance.build instance end |
Instance Method Details
#build ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/flash_flow/merge/release_graph.rb', line 30 def build queue = [] branches.each do |branch| seen_branches[branch] = true queue.unshift([branch, graph.add_node(branch.ref)]) #, color: branch[:shippable?] ? 'green' : 'red', shape: 'record', label: "<f0>#{branch[:name]}") end while !queue.empty? element, node = queue.pop case when seen_branches.has_key?(element) element.stories.to_a.map(&:to_s).each do |story_id| story_id = story_id.to_s seen_stories[story_id] = true find_or_add_node(node, queue, story_id) end when seen_stories.has_key?(element) issue_tracker.release_keys(element).each do |release_key| seen_releases[release_key] = true find_or_add_node(node, queue, release_key) end when seen_releases.has_key?(element) issue_tracker.stories_for_release(element).map(&:to_s).each do |story_id| story_id = story_id.to_s seen_stories[story_id] = true find_or_add_node(node, queue, story_id) end end end end |
#connected_branches(node_id) ⇒ Object
65 66 67 68 69 |
# File 'lib/flash_flow/merge/release_graph.rb', line 65 def connected_branches(node_id) visited = connected(node_id) seen_branches.keys.select { |k| visited[k.ref] } end |
#connected_releases(node_id) ⇒ Object
77 78 79 80 81 |
# File 'lib/flash_flow/merge/release_graph.rb', line 77 def connected_releases(node_id) visited = connected(node_id) seen_releases.keys.select { |k| visited[k] } end |
#connected_stories(node_id) ⇒ Object
71 72 73 74 75 |
# File 'lib/flash_flow/merge/release_graph.rb', line 71 def connected_stories(node_id) visited = connected(node_id) seen_stories.keys.select { |k| visited[k] } end |
#output(png_file) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/flash_flow/merge/release_graph.rb', line 19 def output(png_file) graph.output(png: png_file) png_file rescue StandardError => e if e. =~ /GraphViz/i nil else raise e end end |