Sha256: ccd442cc220822fd3a98bfc6adb3b210a7135b1d874c26632f4f7cb7d333f808

Contents?: true

Size: 857 Bytes

Versions: 3

Compression:

Stored size: 857 Bytes

Contents

# -*- encoding : utf-8 -*-
module GitStats
  class Generator
    delegate :add_command_observer, to: :@repo
    delegate :render_all, to: :@view

    def initialize(repo_path, out_path)
      validate_paths(repo_path, out_path)

      @repo = GitData::Repo.new(path: repo_path)
      view_data = StatsView::ViewData.new(@repo)
      @view = StatsView::View.new(view_data, out_path)

      yield self if block_given?
    end

    private
    def validate_paths(repo_path, out_path)
      validate_repo_path(repo_path)
      validate_out_path(out_path)
    end

    def validate_repo_path(repo_path)
      raise ArgumentError, "#{repo_path} is not a git repository" unless Dir.exists?("#{repo_path}/.git")
    end

    def validate_out_path(out_path)
      raise ArgumentError, "#{out_path} is not a directory" unless Dir.exists?(out_path)
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
git_stats-1.0.2 lib/git_stats/generator.rb
git_stats-1.0.1 lib/git_stats/generator.rb
git_stats-1.0.0 lib/git_stats/generator.rb