couve 0.4.0 → 0.5.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: d2d77a7f4ff4d71e6a6b44dbbce503b7e24db2781949c690fe0dbea9abc1e925
4
- data.tar.gz: 6907bd5e49f9018a56fe693b53f31d320691fc2237d04b68a8d9e29c007295b1
3
+ metadata.gz: b00642800c7fb55e834a786a5243dafe3ff38ae2dc1e638b0c041f4686bc3c28
4
+ data.tar.gz: 9d5bf8a939b2c46e528ec47add60d325fdd4105232127f06ffdbe0690840475f
5
5
  SHA512:
6
- metadata.gz: 2cf6728d574b655ef2a6e4632a2d103cccb2eeaba0ad1d620bc3d92db5f0a2b98b5480f4e7137b7099aba3cd4ca0b16247b003a7e84cba47a340c3785d200992
7
- data.tar.gz: 2d2c6c9e145e31e61b47c4fb1cf4350f4974a8d4ac34e448588925b5805ac0a57bfb59145f59298987749c512135a6456a699293cc57da079e034c9ef79217d4
6
+ metadata.gz: 85783f6edf42296754670765ea005c6a63ae4a40aaa26de8ca56ec0861d63155ec30e7e8ab376a09bb9bd0ea76c7d4037520a71a00ad472d496bdb86234c1e65
7
+ data.tar.gz: 9f1cc2e8da3106fcdcd0b64450d0d16f28b530c2f33c126df69871cc0387408788f4f4b09c7908b2be99056d9a144df1654d9d2b219745a60848916b56cfa93f
data/.rubocop.yml CHANGED
@@ -1,5 +1,30 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.6
2
+ TargetRubyVersion: 3.0.3
3
+ NewCops: enable
4
+ SuggestExtensions: false
5
+ Exclude:
6
+ - 'bin/**/*'
7
+ - 'config/**/*'
8
+ - 'log/**/*'
9
+ - 'tmp/**/*'
10
+ - 'public/**/*'
11
+ - 'vendor/**/*'
12
+ - 'db/**/*'
13
+ - 'spec/spec_helper.rb'
14
+ - 'spec/rails_helper.rb'
15
+
16
+ Bundler/OrderedGems:
17
+ Enabled: false
18
+
19
+ Gemspec/RequiredRubyVersion:
20
+ Enabled: false
21
+
22
+ Layout/LineLength:
23
+ Max: 120
24
+
25
+ Metrics/BlockLength:
26
+ Exclude:
27
+ - 'spec/**/*.rb'
3
28
 
4
29
  Style/StringLiterals:
5
30
  Enabled: true
@@ -9,12 +34,8 @@ Style/StringLiteralsInInterpolation:
9
34
  Enabled: true
10
35
  EnforcedStyle: double_quotes
11
36
 
12
- Layout/LineLength:
13
- Max: 120
37
+ Style/SymbolArray:
38
+ EnforcedStyle: brackets
14
39
 
15
40
  Style/Documentation:
16
41
  Enabled: false
17
-
18
- Metrics/BlockLength:
19
- Exclude:
20
- - 'spec/**/*.rb'
data/Gemfile CHANGED
@@ -5,8 +5,10 @@ source "https://rubygems.org"
5
5
  # Specify your gem's dependencies in couve.gemspec
6
6
  gemspec
7
7
 
8
- gem "rake", "~> 13.0"
9
- gem "rspec", "~> 3.0"
10
- gem "rubocop", "~> 1.21"
11
- gem "guard", "~> 2.18"
12
- gem "guard-rspec", "~> 4.7"
8
+ gem "rake", "~> 13.0", group: [:test, :development]
9
+ gem "rspec", "~> 3.0", group: [:test, :development]
10
+ gem "rubocop", "~> 1.21", group: [:test, :development]
11
+ gem "guard", "~> 2.18", group: :development
12
+ gem "guard-rspec", "~> 4.7", group: :development, require: false
13
+ gem "nokogiri", "~> 1.15", group: [:test, :development]
14
+ gem "byebug", group: :development
data/Gemfile.lock CHANGED
@@ -1,12 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- couve (0.1.0)
4
+ couve (0.4.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
9
  ast (2.4.2)
10
+ byebug (11.1.3)
10
11
  coderay (1.1.3)
11
12
  diff-lcs (1.5.0)
12
13
  ffi (1.15.5)
@@ -33,6 +34,10 @@ GEM
33
34
  lumberjack (1.2.9)
34
35
  method_source (1.0.0)
35
36
  nenv (0.3.0)
37
+ nokogiri (1.15.3-x86_64-darwin)
38
+ racc (~> 1.4)
39
+ nokogiri (1.15.3-x86_64-linux)
40
+ racc (~> 1.4)
36
41
  notiffany (0.1.3)
37
42
  nenv (~> 0.1)
38
43
  shellany (~> 0.0)
@@ -84,11 +89,14 @@ GEM
84
89
 
85
90
  PLATFORMS
86
91
  x86_64-darwin-21
92
+ x86_64-linux
87
93
 
88
94
  DEPENDENCIES
95
+ byebug
89
96
  couve!
90
97
  guard (~> 2.18)
91
98
  guard-rspec (~> 4.7)
99
+ nokogiri (~> 1.15)
92
100
  rake (~> 13.0)
93
101
  rspec (~> 3.0)
94
102
  rubocop (~> 1.21)
data/Guardfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # A sample Guardfile
2
4
  # More info at https://github.com/guard/guard#readme
3
5
 
@@ -18,5 +20,5 @@
18
20
  guard :rspec, cmd: "rspec" do
19
21
  watch(%r{^spec/.+_spec\.rb$})
20
22
  watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
21
- watch('spec/spec_helper.rb') { "spec" }
23
+ watch("spec/spec_helper.rb") { "spec" }
22
24
  end
data/Rakefile CHANGED
@@ -9,4 +9,4 @@ require "rubocop/rake_task"
9
9
 
10
10
  RuboCop::RakeTask.new
11
11
 
12
- task default: %i[spec rubocop]
12
+ task default: [:spec, :rubocop]
data/bin/rubocop ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rubocop' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rubocop", "rubocop")
data/couve.gemspec CHANGED
@@ -7,6 +7,7 @@ Gem::Specification.new do |spec|
7
7
  spec.version = Couve::VERSION
8
8
  spec.authors = ["Cezinha"]
9
9
  spec.email = ["cesar@asseinfo.com.br"]
10
+ spec.metadata = { "rubygems_mfa_required" => "true" }
10
11
 
11
12
  spec.summary = "Generate a human readable report for CodeClimate test-reporter gem."
12
13
 
@@ -20,6 +21,7 @@ Gem::Specification.new do |spec|
20
21
  spec.bindir = "exe"
21
22
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
22
23
  spec.require_paths = ["lib", "lib/couve"]
24
+ spec.required_ruby_version = ">= 3"
23
25
 
24
26
  # Uncomment to register a new dependency of your gem
25
27
  # spec.add_dependency "example-gem", "~> 1.0"
data/lib/couve/parser.rb CHANGED
@@ -1,67 +1,99 @@
1
- require "json"
1
+ # frozen_string_literal: true
2
2
 
3
- class Couve::Parser
4
- def initialize(coverage)
5
- @coverage = JSON.parse(coverage, symbolize_names: true)
6
- @coverage[:source_files].reject! { |file| file[:covered_percent] == 100 }
7
- @coverage[:source_files].sort_by! { |file| file[:covered_percent] }
8
- end
3
+ require "json"
9
4
 
10
- def to_html
11
- <<~HTML
12
- <html>
13
- <body>
14
- <div class="container mt-5">
15
- <h1 class="display-5">
16
- Coverage problems
17
- </h1>
18
-
19
- <table class="table table-hover mt-5">
20
- <thead>
21
- <tr>
22
- <th class="col-1 text-end">Coverage</th>
23
- <th class="col-8">File</th>
24
- <th class="col-3">Not covered lines</th>
25
- </tr>
26
- </thead>
27
- #{body}
28
- </table>
29
- </div>
30
-
31
- <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
32
- <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
33
- </body>
34
- </html>
35
- HTML
36
- end
5
+ module Couve
6
+ class Parser
7
+ def initialize(coverage)
8
+ @coverage = JSON.parse(coverage, symbolize_names: true)
9
+ @coverage[:source_files].reject! { |file| file[:covered_percent] == 100 }
10
+ @coverage[:source_files].sort_by! { |file| file[:covered_percent] }
11
+ end
37
12
 
38
- private
13
+ def to_html
14
+ <<~HTML
15
+ <html>
16
+ <body>
17
+ <div class="container mt-5">
18
+ <h1 class="display-5">
19
+ Coverage problems
20
+ </h1>
39
21
 
40
- def body
41
- html = ["<tbody>"]
22
+ <table class="table table-hover mt-5">
23
+ <thead>
24
+ <tr>
25
+ <th class="col-1" colspan="2">Coverage</th>
26
+ <th class="col-7">File</th>
27
+ <th class="col-3">Not covered lines</th>
28
+ </tr>
29
+ </thead>
30
+ #{body}
31
+ </table>
32
+ </div>
42
33
 
43
- @coverage[:source_files].each do |source_file|
44
- html << " <tr>"
45
- html << " <td class=\"col-1 text-end\">#{source_file[:covered_percent].round(2)}%</td>"
46
- html << " <td class=\"col-8 text-break\">#{source_file[:name]}</td>"
47
- html << " <td class=\"col-3 text-break\">#{not_covered_lines(source_file)}</td>"
48
- html << " </tr>"
34
+ <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
35
+ <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
36
+ </body>
37
+ </html>
38
+ HTML
49
39
  end
50
40
 
51
- html << "</tbody>"
41
+ private
52
42
 
53
- html.join("\n ")
54
- end
43
+ # rubocop:disable Metrics/MethodLength
44
+ # rubocop:disable Metrics/AbcSize
45
+ def body
46
+ html = ["<tbody>"]
47
+
48
+ @coverage[:source_files].each do |source_file|
49
+ percentage = source_file[:covered_percent].round(2)
50
+ bg_color = percentage_bar_color(percentage)
55
51
 
56
- def not_covered_lines(source_file)
57
- total_lines = JSON.parse(source_file[:coverage])
52
+ html << " <tr>"
53
+ html << " <td class=\"col-1\">"
54
+ html << " <div class=\"progress\">"
55
+ html << " <div"
56
+ html << " class=\"progress-bar #{bg_color}\""
57
+ html << " role=\"progressbar\""
58
+ html << " style=\"width: #{percentage}%;\""
59
+ html << " aria-valuenow=\"#{percentage}\""
60
+ html << " aria-valuemin=\"0\" aria-valuemax=\"100\">"
61
+ html << " </div>"
62
+ html << " </div>"
63
+ html << " </td>"
64
+ html << " <td class=\"col-1\">#{percentage}%</td>"
65
+ html << " <td class=\"col-8 text-break\">#{source_file[:name]}</td>"
66
+ html << " <td class=\"col-3 text-break\">#{not_covered_lines(source_file)}</td>"
67
+ html << " </tr>"
68
+ end
58
69
 
59
- not_covered = total_lines.each_with_index.map do |line, index|
60
- next if line != 0
70
+ html << "</tbody>"
61
71
 
62
- index + 1
72
+ html.join("\n ")
63
73
  end
74
+ # rubocop:enable Metrics/AbcSize
75
+ # rubocop:enable Metrics/MethodLength
64
76
 
65
- not_covered.compact.join(", ")
77
+ def percentage_bar_color(percentage)
78
+ if percentage < 33.33
79
+ "bg-danger"
80
+ elsif percentage < 66.66
81
+ "bg-warning"
82
+ else
83
+ "bg-success"
84
+ end
85
+ end
86
+
87
+ def not_covered_lines(source_file)
88
+ total_lines = JSON.parse(source_file[:coverage])
89
+
90
+ not_covered = total_lines.each_with_index.map do |line, index|
91
+ next if line != 0
92
+
93
+ index + 1
94
+ end
95
+
96
+ not_covered.compact.join(", ")
97
+ end
66
98
  end
67
99
  end
data/lib/couve/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Couve
4
- VERSION = "0.4.0"
4
+ VERSION = "0.5.0"
5
5
  end
data/tmp/.keep ADDED
File without changes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: couve
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cezinha
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-19 00:00:00.000000000 Z
11
+ date: 2023-07-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -30,15 +30,18 @@ files:
30
30
  - bin/_guard-core
31
31
  - bin/console
32
32
  - bin/guard
33
+ - bin/rubocop
33
34
  - bin/setup
34
35
  - couve.gemspec
35
36
  - exe/couve
36
37
  - lib/couve.rb
37
38
  - lib/couve/parser.rb
38
39
  - lib/couve/version.rb
40
+ - tmp/.keep
39
41
  homepage:
40
42
  licenses: []
41
- metadata: {}
43
+ metadata:
44
+ rubygems_mfa_required: 'true'
42
45
  post_install_message:
43
46
  rdoc_options: []
44
47
  require_paths:
@@ -48,7 +51,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
48
51
  requirements:
49
52
  - - ">="
50
53
  - !ruby/object:Gem::Version
51
- version: '0'
54
+ version: '3'
52
55
  required_rubygems_version: !ruby/object:Gem::Requirement
53
56
  requirements:
54
57
  - - ">="