mirror of
https://github.com/tomgi/git_stats.git
synced 2025-01-03 11:12:11 +01:00
git_command_observer
This commit is contained in:
parent
71c06cd8e3
commit
9f6fab8232
4 changed files with 20 additions and 5 deletions
|
@ -6,7 +6,9 @@ class GitStats::CLI
|
|||
raise "Wrong number of arguments\nUsage: git_stats repo_path output_path" unless args.size == 2
|
||||
|
||||
repo_path, out_path = args
|
||||
GitStats::Generator.new(repo_path, out_path).generate
|
||||
GitStats::Generator.new(repo_path, out_path) { |g|
|
||||
g.git_command_observer { |command| puts command }
|
||||
}.generate
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -2,12 +2,17 @@ module GitStats
|
|||
class Generator
|
||||
def initialize(repo_path, out_path)
|
||||
@repo_path, @out_path = repo_path, out_path
|
||||
yield self if block_given?
|
||||
end
|
||||
|
||||
def git_command_observer(&block)
|
||||
@git_command_observer = block
|
||||
end
|
||||
|
||||
def generate
|
||||
validate_paths
|
||||
|
||||
repo = GitData::Repo.new(@repo_path)
|
||||
repo = GitData::Repo.new(path: @repo_path, git_command_observer: @git_command_observer)
|
||||
view_data = StatsView::ViewData.new(repo)
|
||||
|
||||
view = StatsView::View.new(view_data, @out_path)
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
module GitStats
|
||||
module GitData
|
||||
class Command
|
||||
attr_reader :repo, :command
|
||||
|
||||
def initialize(repo, command)
|
||||
@repo = repo
|
||||
@command = command
|
||||
end
|
||||
|
||||
def run
|
||||
repo.git_command_observer.try(:call, @command)
|
||||
in_repo { %x[#@command] }
|
||||
end
|
||||
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
require 'git_stats/hash_initializable'
|
||||
|
||||
module GitStats
|
||||
module GitData
|
||||
class Repo
|
||||
attr_reader :path
|
||||
include HashInitializable
|
||||
|
||||
def initialize(path)
|
||||
@path = File.expand_path(path)
|
||||
attr_reader :path, :git_command_observer
|
||||
|
||||
def initialize(params)
|
||||
super(params)
|
||||
@path = File.expand_path(@path)
|
||||
end
|
||||
|
||||
def authors
|
||||
|
|
Loading…
Reference in a new issue