Class: HOC::Base
- Inherits:
-
Object
- Object
- HOC::Base
- Defined in:
- lib/hoc.rb
Overview
Code base abstraction
Instance Method Summary collapse
-
#initialize(dir, format) ⇒ Base
constructor
Ctor.
-
#report ⇒ Object
Generate report.
Constructor Details
#initialize(dir, format) ⇒ Base
Ctor.
dir-
Directory to read from
format-
Format (xml, json, text)
37 38 39 40 41 |
# File 'lib/hoc.rb', line 37 def initialize(dir, format) @dir = dir @format = format fail "only int format is supported (#{@format})" unless @format == 'int' end |
Instance Method Details
#report ⇒ Object
Generate report.
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/hoc.rb', line 44 def report repo = nil if File.exist?(File.join(@dir, '.git')) repo = Git.new(@dir) elsif File.exist?(File.join(@dir, '.svn')) repo = Svn.new(@dir) else fail 'only Git repositories supported now' end repo.hits.map { |h| h.total }.inject(:+) end |