class Octaccord::Formatter::Base
Public Class Methods
new()
click to toggle source
# File lib/octaccord/formatter.rb, line 31 def initialize @issues = [] end
Public Instance Methods
<<(issue)
click to toggle source
# File lib/octaccord/formatter.rb, line 35 def <<(issue) @issues << Issue.new(issue) end
order(numbers)
click to toggle source
# File lib/octaccord/formatter.rb, line 51 def order(numbers) numbers = scan_issue_numbers_from_string(numbers) if numbers.is_a?(String) ordered = numbers.map do |n| @issues.find{|issue| issue.number.to_i == n} end.compact @issues = ordered + (@issues - ordered) end
to_s()
click to toggle source
# File lib/octaccord/formatter.rb, line 61 def to_s format_frame_header + format_header + format_body + format_footer + format_frame_footer end
tsort()
click to toggle source
# File lib/octaccord/formatter.rb, line 39 def tsort graph = {} @issues.each do |issue| graph[issue.number.to_i] ||= [] issue.references.each do |parent| graph[parent] ||= [] graph[parent] << issue.number.to_i end end graph.tsort end
Private Instance Methods
format_body()
click to toggle source
# File lib/octaccord/formatter.rb, line 76 def format_body @issues.map{|issue| format_item(issue)}.compact.join("\n") + "\n" end
format_frame_header()
click to toggle source
# File lib/octaccord/formatter.rb, line 80 def format_frame_header "" end
format_header()
click to toggle source
# File lib/octaccord/formatter.rb, line 88 def format_header ;""; end
scan_issue_numbers_from_string(string, one_for_each_line = true)
click to toggle source
# File lib/octaccord/formatter.rb, line 71 def scan_issue_numbers_from_string(string, one_for_each_line = true) regexp = one_for_each_line ? /#(\d+).*\n?/ : /#(\d+)/ string.scan(regexp).map{|i| i.first.to_i} end