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
|
raise "Wrong number of arguments\nUsage: git_stats repo_path output_path" unless args.size == 2
|
||||||
|
|
||||||
repo_path, out_path = args
|
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,12 +2,17 @@ module GitStats
|
||||||
class Generator
|
class Generator
|
||||||
def initialize(repo_path, out_path)
|
def initialize(repo_path, out_path)
|
||||||
@repo_path, @out_path = 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
|
end
|
||||||
|
|
||||||
def generate
|
def generate
|
||||||
validate_paths
|
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_data = StatsView::ViewData.new(repo)
|
||||||
|
|
||||||
view = StatsView::View.new(view_data, @out_path)
|
view = StatsView::View.new(view_data, @out_path)
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
module GitStats
|
module GitStats
|
||||||
module GitData
|
module GitData
|
||||||
class Command
|
class Command
|
||||||
|
attr_reader :repo, :command
|
||||||
|
|
||||||
def initialize(repo, command)
|
def initialize(repo, command)
|
||||||
@repo = repo
|
@repo = repo
|
||||||
@command = command
|
@command = command
|
||||||
end
|
end
|
||||||
|
|
||||||
def run
|
def run
|
||||||
|
repo.git_command_observer.try(:call, @command)
|
||||||
in_repo { %x[#@command] }
|
in_repo { %x[#@command] }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
|
require 'git_stats/hash_initializable'
|
||||||
|
|
||||||
module GitStats
|
module GitStats
|
||||||
module GitData
|
module GitData
|
||||||
class Repo
|
class Repo
|
||||||
attr_reader :path
|
include HashInitializable
|
||||||
|
|
||||||
def initialize(path)
|
attr_reader :path, :git_command_observer
|
||||||
@path = File.expand_path(path)
|
|
||||||
|
def initialize(params)
|
||||||
|
super(params)
|
||||||
|
@path = File.expand_path(@path)
|
||||||
end
|
end
|
||||||
|
|
||||||
def authors
|
def authors
|
||||||
|
|
Loading…
Reference in a new issue