class GitReporting::Reporter
Attributes
source[R]
Public Class Methods
new(source_options)
click to toggle source
# File lib/git_reporting.rb, line 32 def initialize(source_options) @source = case source_options when Source then source_options when Array then Source::Array.new(source_options) when Hash then Source.from_options(source_options) else raise ArgumentError, "You should initialize GitReporting::Reporter with array, hash of source options or GitReporting::Source instance." end end
Public Instance Methods
build_report(options = {})
click to toggle source
# File lib/git_reporting.rb, line 42 def build_report(options = {}) type = options[:type] || :simple group = options[:group] || :none from_time = options[:from].present? ? parse_time(options[:from]) : Time.at(0) to_time = options[:to].present? ? parse_time(options[:to]) : Time.current commits = source.fetch(from_time..to_time) root = Report.new("Report") root << Report::Group.const_get(group.to_s.capitalize).build(commits) do |group_commits| Report::Type.const_get(type.to_s.capitalize).build(group_commits) end end
Private Instance Methods
parse_time(time)
click to toggle source
# File lib/git_reporting.rb, line 58 def parse_time(time) DateTime.parse(time.to_s) rescue ArgumentError raise ArgumentError, "#{time} is not a valid date" end