Class: Stagehand::Auditor::ChecklistVisualizer
- Inherits:
-
Object
- Object
- Stagehand::Auditor::ChecklistVisualizer
- Defined in:
- lib/stagehand/auditor/checklist_visualizer.rb
Instance Method Summary collapse
-
#initialize(checklist, show_all_commits: false) ⇒ ChecklistVisualizer
constructor
A new instance of ChecklistVisualizer.
- #output(file_name, format: ) ⇒ Object
Constructor Details
#initialize(checklist, show_all_commits: false) ⇒ ChecklistVisualizer
Returns a new instance of ChecklistVisualizer.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/stagehand/auditor/checklist_visualizer.rb', line 6 def initialize(checklist, show_all_commits: false) entries = checklist.affected_entries.select(&:commit_id) @graph = GraphViz.new( :G, :type => :graph ); @commits = Hash.new {|hash, commit_id| hash[commit_id] = Stagehand::Staging::CommitEntry.find(commit_id) } nodes = Hash.new edges = [] # Detect edges entries.group_by(&:key).each_value do |entries| entries.combination(2).each do |entry_a, entry_b| current_edge = [entry_a, entry_b] next if edges.detect {|edge| edge.sort == current_edge.sort } next if same_node?(entry_a, entry_b) next if same_subject?(entry_a, entry_b) edges << current_edge end end # Create Subgraph nodes for commits with connections to other subjects entries = edges.flatten.uniq unless show_all_commits entries.group_by {|entry| commit_subject(entry) }.each do |subject, entries| subgraph = create_subgraph(subject, @graph) entries.each do |entry| nodes[entry] = create_node(entry, subgraph) end end # Create edges edges.each do |entry_a, entry_b| create_edge(nodes[entry_a], nodes[entry_b], :label => edge_label(entry_a, entry_b)) end end |
Instance Method Details
#output(file_name, format: ) ⇒ Object
40 41 42 43 |
# File 'lib/stagehand/auditor/checklist_visualizer.rb', line 40 def output(file_name, format: File.extname(file_name)[1..-1]) @graph.output(format => file_name) File.open(file_name) end |