quality_report 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f18d81f9fa7d9dca4e114657e18e06fed11bed99df6746c0438bf2bf9b625441
4
- data.tar.gz: 19578513e16b8457a2e388e326834f31f1dd17876c822cf6f509349a2ae261e3
3
+ metadata.gz: c36b81a22b99492d9995e4446769315fe3a01df58e39ed71a3a1050bc05f1791
4
+ data.tar.gz: ebc3e1150b528d795fd72e926a462a93aca6311f4a232a3d94c04416bc0a7a7e
5
5
  SHA512:
6
- metadata.gz: '03793a5b452e7f3ecc1b3c805eb273ff60f5619dceb902d0f19fc7c1272da7b60751ee737602671b364c00f2a2894568b8cf9c09b6e707feed5029b195c00952'
7
- data.tar.gz: 0da7cd9be8337214421ee9ed709dc5a6119fdc48611c4648c70b211e8df0aee85b39c65d24c30dc77be690237f205c34c788176d22e49db38467368c6a9fe9f5
6
+ metadata.gz: 1e9379b163149edcab1180868a320b7b5529f6c73b5a8c90cc2ffe3292fa818ccc1a48a1cfef9fb6a319fd9dbdf348fc9e6f66749d9b82e4886f2f4a42a50d4d
7
+ data.tar.gz: f9911d996413da6cf9264b34749e318d01a1c64e85925c76dae7da609966495341e7fc9d5956866b32c477cc7adbf9f0fbbe50bd0422773242b69e16a122003f
@@ -2,6 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'tty-table'
5
+ require 'pastel'
5
6
 
6
7
  #
7
8
  # ruby-quality-report
@@ -10,6 +11,9 @@ require 'tty-table'
10
11
  # of lines of code written by each author that have been flagged as
11
12
  # having too high of a complexity.
12
13
  #
14
+ #
15
+
16
+ SIXTY_DAYS_IN_SECONDS = 60 * 24 * 60 * 60
13
17
 
14
18
  def create_combined_stats(part_stats, whole_stats)
15
19
  part_data = make_data_set(part_stats)
@@ -40,15 +44,42 @@ def generate_csv(combined_stats)
40
44
  end
41
45
 
42
46
  def generate_table(combined_stats)
43
- table = TTY::Table.new(header: ['Author', 'Percent Flagged', 'Flagged Lines', 'All Lines'])
47
+ table = TTY::Table.new(header: %W[Author Percent\nFlagged Flagged\nLines All\nLines])
48
+ table_data = generate_data(combined_stats).reject { should_skip?(_1) }
49
+
50
+ table_data.each do |stats|
51
+ table << [
52
+ { value: stats[:label], alignment: :left },
53
+ { value: "#{stats[:percent]}%", alignment: :right },
54
+ { value: stats[:part_count], alignment: :right },
55
+ { value: stats[:whole_count], alignment: :right }
56
+ ]
57
+ end
44
58
 
45
- generate_data(combined_stats).each do |stats|
46
- next if should_skip?(stats)
59
+ render_table(table, table_data)
60
+ end
47
61
 
48
- table << [stats[:label], "#{stats[:percent]}%", stats[:part_count], stats[:whole_count]]
62
+ def render_table(table, table_data)
63
+ pastel = Pastel.new
64
+
65
+ table.render(:unicode, alignment: :center, padding: [0, 1], multiline: true) do |renderer|
66
+ renderer.border.style = :dim
67
+ renderer.filter = lambda { |val, row_index, _col_index|
68
+ if row_index <= 0
69
+ # Header row
70
+ val
71
+ else
72
+ case table_data[row_index - 1][:percent]
73
+ when 0...40
74
+ val
75
+ when 40...50
76
+ pastel.bold.yellow(val)
77
+ else
78
+ pastel.bold.red(val)
79
+ end
80
+ end
81
+ }
49
82
  end
50
-
51
- table.render(:unicode, alignments: %i[left right right right])
52
83
  end
53
84
 
54
85
  def generate_data(combined_stats)
@@ -73,7 +104,7 @@ def no_commits_in_last_60_days?(stats)
73
104
 
74
105
  # Convert Unix timestamp to Time object
75
106
  last_commit_time = Time.at(last_commit.to_i)
76
- sixty_days_ago = Time.now - (60 * 24 * 60 * 60) # 60 days in seconds
107
+ sixty_days_ago = Time.now - SIXTY_DAYS_IN_SECONDS
77
108
 
78
109
  last_commit_time < sixty_days_ago
79
110
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module QualityReport
4
- VERSION = '1.3.0'
4
+ VERSION = '1.4.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quality_report
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robb Shecter
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-11-08 00:00:00.000000000 Z
11
+ date: 2024-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop