Class: GitReporting::Reporter
- Inherits:
-
Object
- Object
- GitReporting::Reporter
- Defined in:
- lib/git_reporting.rb
Instance Attribute Summary collapse
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #build_report(options = {}) ⇒ Object
-
#initialize(source_options) ⇒ Reporter
constructor
A new instance of Reporter.
Constructor Details
#initialize(source_options) ⇒ Reporter
Returns a new instance of Reporter.
32 33 34 35 36 37 38 39 40 |
# File 'lib/git_reporting.rb', line 32 def initialize() @source = case when Source then when Array then Source::Array.new() when Hash then Source.() else raise ArgumentError, "You should initialize GitReporting::Reporter with array, hash of source options or GitReporting::Source instance." end end |
Instance Attribute Details
#source ⇒ Object (readonly)
Returns the value of attribute source.
30 31 32 |
# File 'lib/git_reporting.rb', line 30 def source @source end |
Instance Method Details
#build_report(options = {}) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/git_reporting.rb', line 42 def build_report( = {}) type = [:type] || :simple group = [:group] || :none from_time = [:from].present? ? parse_time([:from]) : Time.at(0) to_time = [:to].present? ? parse_time([: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 |