pretty-git 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,31 +4,50 @@ module PrettyGit
4
4
  module Render
5
5
  # Renders Markdown tables and sections per specs/output_formats.md
6
6
  class MarkdownRenderer
7
+ TITLES = {
8
+ 'activity' => 'Activity',
9
+ 'authors' => 'Authors',
10
+ 'files' => 'Top Files',
11
+ 'heatmap' => 'Heatmap',
12
+ 'languages' => 'Languages',
13
+ 'hotspots' => 'Hotspots',
14
+ 'churn' => 'Churn',
15
+ 'ownership' => 'Ownership'
16
+ }.freeze
17
+
18
+ HEADERS = {
19
+ 'activity' => %w[bucket timestamp commits additions deletions],
20
+ 'authors' => %w[author author_email commits additions deletions avg_commit_size],
21
+ 'files' => %w[path commits additions deletions changes],
22
+ 'heatmap' => %w[dow hour commits],
23
+ 'hotspots' => %w[path score commits additions deletions changes],
24
+ 'churn' => %w[path churn commits additions deletions],
25
+ 'ownership' => %w[path owner owner_share authors]
26
+ }.freeze
7
27
  def initialize(io: $stdout)
8
28
  @io = io
9
29
  end
10
30
 
11
31
  def call(report, result, _filters)
12
- case report
13
- when 'summary'
14
- render_summary(result)
15
- when 'activity'
16
- render_table('Activity', %w[bucket timestamp commits additions deletions], result[:items])
17
- when 'authors'
18
- render_table('Authors', %w[author author_email commits additions deletions avg_commit_size], result[:items])
19
- when 'files'
20
- render_table('Top Files', %w[path commits additions deletions changes], result[:items])
21
- when 'heatmap'
22
- render_table('Heatmap', %w[dow hour commits], result[:items])
23
- when 'languages'
24
- render_table('Languages', %w[language bytes percent], result[:items])
25
- else
26
- @io.puts result.inspect
27
- end
32
+ return render_summary(result) if report == 'summary'
33
+
34
+ headers = headers_for(report, result)
35
+ title = title_for(report)
36
+ render_table(title, headers, result[:items])
28
37
  end
29
38
 
30
39
  private
31
40
 
41
+ def headers_for(report, result)
42
+ return ['language', (result[:metric] || 'bytes').to_s, 'percent', 'color'] if report == 'languages'
43
+
44
+ HEADERS.fetch(report, [])
45
+ end
46
+
47
+ def title_for(report)
48
+ TITLES.fetch(report, report.to_s.capitalize)
49
+ end
50
+
32
51
  def render_summary(data)
33
52
  header_summary(data)
34
53
  print_totals(data[:totals])
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PrettyGit
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.3'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pretty-git
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pretty Git Authors
@@ -58,15 +58,20 @@ executables:
58
58
  extensions: []
59
59
  extra_rdoc_files: []
60
60
  files:
61
+ - CHANGELOG.md
61
62
  - LICENSE
62
63
  - README.md
64
+ - README.ru.md
63
65
  - bin/pretty-git
64
66
  - lib/pretty_git.rb
65
67
  - lib/pretty_git/analytics/activity.rb
66
68
  - lib/pretty_git/analytics/authors.rb
69
+ - lib/pretty_git/analytics/churn.rb
67
70
  - lib/pretty_git/analytics/files.rb
68
71
  - lib/pretty_git/analytics/heatmap.rb
72
+ - lib/pretty_git/analytics/hotspots.rb
69
73
  - lib/pretty_git/analytics/languages.rb
74
+ - lib/pretty_git/analytics/ownership.rb
70
75
  - lib/pretty_git/analytics/summary.rb
71
76
  - lib/pretty_git/app.rb
72
77
  - lib/pretty_git/cli.rb