lib/hoc.rb in hoc-0.2 vs lib/hoc.rb in hoc-0.3

- old
+ new

@@ -20,10 +20,11 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. require 'hoc/git' +require 'hoc/svn' # HOC main module. # Author:: Yegor Bugayenko (yegor@teamed.io) # Copyright:: Copyright (c) 2014 Yegor Bugayenko # License:: MIT @@ -34,17 +35,22 @@ # +dir+:: Directory to read from # +format+:: Format (xml, json, text) def initialize(dir, format) @dir = dir @format = format + fail "only int format is supported (#{@format})" unless @format == 'int' end # Generate report. def report + repo = nil if File.exist?(File.join(@dir, '.git')) - Git.new(@dir).hits.map { |h| h.total }.inject(:+) + 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 end end