quality_report 1.0.0 → 1.1.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 864f3f5fa2d1b9a35478532a96341ef0b23df5911aa8eb8ac0293beb7e42397a
4
- data.tar.gz: 926133e5ba6df85661a397f10e6c035e987b0d3a68920595633a8d3b6d4d9330
3
+ metadata.gz: a14f06872f83645bba1702173f3f9ee1942c54ae51ca3031db00158c63b51217
4
+ data.tar.gz: 614f5743e39d968b4a431206f5f886a40a258a849e2a89543687ce00b2a8015f
5
5
  SHA512:
6
- metadata.gz: 047430fe2e35df46138827d368f7eae6dc24881a41f952e128f59fae156fe0338bfff5a721d148372983513f7d8f45bc71ecc6bd77377918bb8e8d5c755f0e4f
7
- data.tar.gz: 154ffb7d0e21db6d0ac67b20a5d73247980ae074bf21323369a4ed2d9add28e4e7af101f11e90d8319240ce5a804715202fea345a2d8fd47d618683863f545c3
6
+ metadata.gz: 5af1a4cfcef6c1831c40a5a6a111d684091ad282109015a9438ec9ab692349a7284b73a9e0b06d3ce51c29536f6167e4b3429386841a2fe622f9846ddd99c5a3
7
+ data.tar.gz: a059cce459f23251d0d7c72cd0b29d4f3f3824fb2bf65a8e2d9fb0af78299a4dec89af4986071534ce690e0e7838aa00289c0171db94da8beddfbc1830197bbe
data/README.md CHANGED
@@ -6,6 +6,8 @@
6
6
  ruby-quality-report
7
7
  ```
8
8
 
9
+ This outputs a CSV report to stdout.
10
+
9
11
  ## Contributing
10
12
 
11
13
  Bug reports and pull requests are welcome on GitHub at https://github.com/dogweather/ruby-quality-report.
@@ -1,4 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'tty-table'
2
5
 
3
6
  #
4
7
  # ruby-quality-report
@@ -14,11 +17,12 @@ def create_combined_stats(part_stats, whole_stats)
14
17
 
15
18
  whole_data.map do |label, whole_count|
16
19
  part_count = part_data[label] || 0
20
+
17
21
  {
18
22
  label:,
19
23
  part_count:,
20
24
  whole_count:,
21
- percent: part_count.to_f / whole_count.to_f
25
+ percent: float_to_percent(part_count.to_f / whole_count)
22
26
  }
23
27
  end
24
28
  end
@@ -33,21 +37,43 @@ def make_data_set(two_column_data)
33
37
  end
34
38
 
35
39
  def generate_csv(combined_stats)
40
+ generate_data(combined_stats)
41
+ .map { |stats| [stats[:label], stats[:percent], stats[:part_count], stats[:whole_count]].join(',') }
42
+ .tap { |x| x.prepend(['Author,Percent Flagged,Flagged Lines,All Lines']) }
43
+ .join("\n")
44
+ end
45
+
46
+ def generate_table(combined_stats)
47
+ table = TTY::Table.new(header: ['Author', 'Percent Flagged', 'Flagged Lines', 'All Lines'])
48
+
49
+ generate_data(combined_stats).each do |stats|
50
+ next if should_skip?(stats)
51
+
52
+ table << [stats[:label], "#{stats[:percent]}%", stats[:part_count], stats[:whole_count]]
53
+ end
54
+
55
+ table.render(:unicode)
56
+ end
57
+
58
+ def generate_data(combined_stats)
36
59
  combined_stats
37
- .sort_by{|s| s[:percent]}
60
+ .sort_by { |s| s[:percent] }
38
61
  .reverse
39
- .map{ |stats| [stats[:label], stats[:percent], stats[:part_count], stats[:whole_count]].join(',') }
40
- .tap{|x| x.prepend(["Author,Percent Flagged,Flagged Lines,All Lines"])}
41
- .join("\n")
42
62
  end
43
63
 
64
+ def should_skip?(stats)
65
+ stats[:whole_count] < 200
66
+ end
67
+
68
+ def float_to_percent(a_float)
69
+ (Float(a_float) * 100).round(1)
70
+ end
44
71
 
45
72
  #
46
73
  # Execution begins here
47
74
  #
48
- PART_STATS = `ruby-author-warnings | frequency-list`
49
- WHOLE_STATS = `ruby-line-authors | frequency-list`
50
-
75
+ PART_STATS = `ruby-author-warnings | frequency-list`
76
+ WHOLE_STATS = `ruby-line-authors | frequency-list`
51
77
  COMBINED_STATS = create_combined_stats(PART_STATS, WHOLE_STATS)
52
78
 
53
- puts generate_csv(COMBINED_STATS)
79
+ puts generate_table(COMBINED_STATS)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module QualityReport
4
- VERSION = '1.0.0'
4
+ VERSION = '1.1.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quality_report
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robb Shecter
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.68'
27
+ - !ruby/object:Gem::Dependency
28
+ name: tty-table
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.12.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.12.0
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rspec
29
43
  requirement: !ruby/object:Gem::Requirement