Class: Git::Heatmap::Command::Generate

Inherits:
Samovar::Command
  • Object
show all
Defined in:
lib/git/heatmap/command/generate.rb

Constant Summary collapse

PERIODS =
{
	"hourly" => Hourly,
	"daily" => Daily,
	"weekly" => Weekly,
	"monthly" => Monthly,
	"quarterly" => Quarterly,
	"yearly" => Yearly
}

Instance Method Summary collapse

Instance Method Details

#callObject



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/git/heatmap/command/generate.rb', line 74

def call
	commits = Commits.new(filter: self.period, depth: @options[:depth])
	
	@paths.each do |path|
		Console.logger.info "Loading commits from #{path}..."
		
		begin
			repository = Rugged::Repository.discover(path)
		
			commits.add(repository)
		rescue
			Console.logger.error($!)
		end
	end
	
	File.write(output_path, template(commits).call)
end

#output_pathObject



64
65
66
67
68
# File 'lib/git/heatmap/command/generate.rb', line 64

def output_path
	@options.fetch(:output) do
		"#{title} #{@options[:period]}.html"
	end
end

#periodObject



54
55
56
# File 'lib/git/heatmap/command/generate.rb', line 54

def period
	PERIODS[@options[:period]].new
end

#template(commits) ⇒ Object



70
71
72
# File 'lib/git/heatmap/command/generate.rb', line 70

def template(commits)
	Templates::Series.new(commits, title: self.title)
end

#titleObject



58
59
60
61
62
# File 'lib/git/heatmap/command/generate.rb', line 58

def title
	@paths.map do |path|
		File.basename(File.expand_path(path))
	end.join(', ')
end