Class: Git::Heatmap::Command::Generate
- Inherits:
-
Samovar::Command
- Object
- Samovar::Command
- Git::Heatmap::Command::Generate
- 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
#call ⇒ Object
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: [: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_path ⇒ Object
64 65 66 67 68 |
# File 'lib/git/heatmap/command/generate.rb', line 64 def output_path .fetch(:output) do "#{title} #{@options[:period]}.html" end end |
#period ⇒ Object
54 55 56 |
# File 'lib/git/heatmap/command/generate.rb', line 54 def period PERIODS[[: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 |
#title ⇒ Object
58 59 60 61 62 |
# File 'lib/git/heatmap/command/generate.rb', line 58 def title @paths.map do |path| File.basename(File.(path)) end.join(', ') end |