couve 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9951b504fe35d8e491741d5b10967bac1044406fb3296ab60608956fb722b72d
4
+ data.tar.gz: aa58ce0e6fcf1fa4f30b53b811013d4829303b64fc1ddde5194ef367bc2e812a
5
+ SHA512:
6
+ metadata.gz: 98aba7ff061457837b09b5a606d6bb5077c7b6f6f76c7565d6001a62d2bd09d20072650e79d9a4d71cc3c908f49d08f8b2683be80cff10222c144170da7736d0
7
+ data.tar.gz: 8c87e661c97979580788a9d6e0b0fa59154814cf72d730dc0f71cba8c6f78f2474b200323454fdafdba903ee816127c0dd313de46c5929bef3ff7676ed44fabd
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,20 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
14
+
15
+ Style/Documentation:
16
+ Enabled: false
17
+
18
+ Metrics/BlockLength:
19
+ Exclude:
20
+ - 'spec/**/*.rb'
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2023-07-19
4
+
5
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in couve.gemspec
6
+ gemspec
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"
data/Gemfile.lock ADDED
@@ -0,0 +1,97 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ couve (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.2)
10
+ coderay (1.1.3)
11
+ diff-lcs (1.5.0)
12
+ ffi (1.15.5)
13
+ formatador (1.1.0)
14
+ guard (2.18.0)
15
+ formatador (>= 0.2.4)
16
+ listen (>= 2.7, < 4.0)
17
+ lumberjack (>= 1.0.12, < 2.0)
18
+ nenv (~> 0.1)
19
+ notiffany (~> 0.0)
20
+ pry (>= 0.13.0)
21
+ shellany (~> 0.0)
22
+ thor (>= 0.18.1)
23
+ guard-compat (1.2.1)
24
+ guard-rspec (4.7.3)
25
+ guard (~> 2.1)
26
+ guard-compat (~> 1.1)
27
+ rspec (>= 2.99.0, < 4.0)
28
+ json (2.6.3)
29
+ language_server-protocol (3.17.0.3)
30
+ listen (3.8.0)
31
+ rb-fsevent (~> 0.10, >= 0.10.3)
32
+ rb-inotify (~> 0.9, >= 0.9.10)
33
+ lumberjack (1.2.9)
34
+ method_source (1.0.0)
35
+ nenv (0.3.0)
36
+ notiffany (0.1.3)
37
+ nenv (~> 0.1)
38
+ shellany (~> 0.0)
39
+ parallel (1.23.0)
40
+ parser (3.2.2.3)
41
+ ast (~> 2.4.1)
42
+ racc
43
+ pry (0.14.2)
44
+ coderay (~> 1.1)
45
+ method_source (~> 1.0)
46
+ racc (1.7.1)
47
+ rainbow (3.1.1)
48
+ rake (13.0.6)
49
+ rb-fsevent (0.11.2)
50
+ rb-inotify (0.10.1)
51
+ ffi (~> 1.0)
52
+ regexp_parser (2.8.1)
53
+ rexml (3.2.5)
54
+ rspec (3.12.0)
55
+ rspec-core (~> 3.12.0)
56
+ rspec-expectations (~> 3.12.0)
57
+ rspec-mocks (~> 3.12.0)
58
+ rspec-core (3.12.2)
59
+ rspec-support (~> 3.12.0)
60
+ rspec-expectations (3.12.3)
61
+ diff-lcs (>= 1.2.0, < 2.0)
62
+ rspec-support (~> 3.12.0)
63
+ rspec-mocks (3.12.6)
64
+ diff-lcs (>= 1.2.0, < 2.0)
65
+ rspec-support (~> 3.12.0)
66
+ rspec-support (3.12.1)
67
+ rubocop (1.54.2)
68
+ json (~> 2.3)
69
+ language_server-protocol (>= 3.17.0)
70
+ parallel (~> 1.10)
71
+ parser (>= 3.2.2.3)
72
+ rainbow (>= 2.2.2, < 4.0)
73
+ regexp_parser (>= 1.8, < 3.0)
74
+ rexml (>= 3.2.5, < 4.0)
75
+ rubocop-ast (>= 1.28.0, < 2.0)
76
+ ruby-progressbar (~> 1.7)
77
+ unicode-display_width (>= 2.4.0, < 3.0)
78
+ rubocop-ast (1.29.0)
79
+ parser (>= 3.2.1.0)
80
+ ruby-progressbar (1.13.0)
81
+ shellany (0.0.1)
82
+ thor (1.2.2)
83
+ unicode-display_width (2.4.2)
84
+
85
+ PLATFORMS
86
+ x86_64-darwin-21
87
+
88
+ DEPENDENCIES
89
+ couve!
90
+ guard (~> 2.18)
91
+ guard-rspec (~> 4.7)
92
+ rake (~> 13.0)
93
+ rspec (~> 3.0)
94
+ rubocop (~> 1.21)
95
+
96
+ BUNDLED WITH
97
+ 2.2.32
data/Guardfile ADDED
@@ -0,0 +1,22 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec features) \
6
+ # .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
+
8
+ ## Note: if you are using the `directories` clause above and you are not
9
+ ## watching the project directory ('.'), then you will want to move
10
+ ## the Guardfile to a watched dir and symlink it back, e.g.
11
+ #
12
+ # $ mkdir config
13
+ # $ mv Guardfile config/
14
+ # $ ln -s config/Guardfile .
15
+ #
16
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17
+
18
+ guard :rspec, cmd: "rspec" do
19
+ watch(%r{^spec/.+_spec\.rb$})
20
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
21
+ watch('spec/spec_helper.rb') { "spec" }
22
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 Cezinha
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # Couve
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/couve`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'couve'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install couve
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/couve.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/bin/_guard-core 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 '_guard-core' 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("guard", "_guard-core")
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "couve"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/guard 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 'guard' 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("guard", "guard")
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/couve.gemspec ADDED
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/couve/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "couve"
7
+ spec.version = Couve::VERSION
8
+ spec.authors = ["Cezinha"]
9
+ spec.email = ["cesar@asseinfo.com.br"]
10
+
11
+ spec.summary = "Generate a human readable report for CodeClimate test-reporter gem."
12
+
13
+ # Specify which files should be added to the gem when it is released.
14
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
15
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
16
+ `git ls-files -z`.split("\x0").reject do |f|
17
+ (f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
18
+ end
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ # Uncomment to register a new dependency of your gem
25
+ # spec.add_dependency "example-gem", "~> 1.0"
26
+
27
+ # For more information and examples about making a new gem, checkout our
28
+ # guide at: https://bundler.io/guides/creating_gem.html
29
+ end
data/exe/couve ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "./lib/couve"
5
+
6
+ Couve.start
@@ -0,0 +1,67 @@
1
+ require "json"
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
9
+
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
37
+
38
+ private
39
+
40
+ def body
41
+ html = ["<tbody>"]
42
+
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>"
49
+ end
50
+
51
+ html << "</tbody>"
52
+
53
+ html.join("\n ")
54
+ end
55
+
56
+ def not_covered_lines(source_file)
57
+ total_lines = JSON.parse(source_file[:coverage])
58
+
59
+ not_covered = total_lines.each_with_index.map do |line, index|
60
+ next if line != 0
61
+
62
+ index + 1
63
+ end
64
+
65
+ not_covered.compact.join(", ")
66
+ end
67
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Couve
4
+ VERSION = "0.1.0"
5
+ end
data/lib/couve.rb ADDED
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "couve/version"
4
+ require_relative "couve/parser"
5
+
6
+ module Couve
7
+ def self.start
8
+ coverage_file = ARGV[0]
9
+ output_file = ARGV[1]
10
+
11
+ coverage = File.read(coverage_file)
12
+ parser = Couve::Parser.new(coverage)
13
+
14
+ File.open(output_file, "w") do |f|
15
+ f.puts parser.to_html
16
+ end
17
+ end
18
+ end
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: couve
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Cezinha
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-07-19 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - cesar@asseinfo.com.br
16
+ executables:
17
+ - couve
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - ".rspec"
22
+ - ".rubocop.yml"
23
+ - CHANGELOG.md
24
+ - Gemfile
25
+ - Gemfile.lock
26
+ - Guardfile
27
+ - LICENSE.txt
28
+ - README.md
29
+ - Rakefile
30
+ - bin/_guard-core
31
+ - bin/console
32
+ - bin/guard
33
+ - bin/setup
34
+ - couve.gemspec
35
+ - exe/couve
36
+ - lib/couve.rb
37
+ - lib/couve/parser.rb
38
+ - lib/couve/version.rb
39
+ homepage:
40
+ licenses: []
41
+ metadata: {}
42
+ post_install_message:
43
+ rdoc_options: []
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ requirements: []
57
+ rubygems_version: 3.2.32
58
+ signing_key:
59
+ specification_version: 4
60
+ summary: Generate a human readable report for CodeClimate test-reporter gem.
61
+ test_files: []