Sha256: c31a5f25d7c6e5dafaf66747a35db8706a21bc7e99b348f2421e03ac5ac631ad

Contents?: true

Size: 746 Bytes

Versions: 4

Compression:

Stored size: 746 Bytes

Contents

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

    def initialize(options)
      validate_repo_path(options[:path])

      @repo = GitData::Repo.new(options)
      view_data = StatsView::ViewData.new(@repo)
      @view = StatsView::View.new(view_data, options[:out_path])

      yield self if block_given?
    end

    private


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


    def valid_repo_path?(repo_path)
      Dir.exists?("#{repo_path}/.git") || File.exists?("#{repo_path}/.git") || File.exists?("#{repo_path}/HEAD")
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
git_stats-1.0.17 lib/git_stats/generator.rb
git_stats-1.0.16 lib/git_stats/generator.rb
git_stats-1.0.15 lib/git_stats/generator.rb
git_stats-1.0.14 lib/git_stats/generator.rb