simplecov_badger 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.travis.yml +6 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +52 -0
- data/LICENSE.txt +21 -0
- data/README.md +67 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/simplecov_badger.rb +17 -0
- data/lib/simplecov_badger/configuration.rb +26 -0
- data/lib/simplecov_badger/formatter.rb +19 -0
- data/lib/simplecov_badger/version.rb +3 -0
- data/simplecov_badger.gemspec +33 -0
- metadata +115 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f4d774d270c5c09b19d0b976afa8891689ac77680a92212167dae59cf15d21da
|
4
|
+
data.tar.gz: 4b4e434b9b1cb2e831bafa3ff7d4368473472f22328eb508b7637569f203d3d3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4209b850927d96d06f904c85da2ef3e5c50af3f65fd21332304853f4c76c07018719ec96b25012f660bd7bf264ae417315618bbfdc46320e291e88519b0b9196
|
7
|
+
data.tar.gz: eb998aa4886e38ed871f9f2e4ff513c6741e33ba21fd2804760df250b5af0336389890f9aa2b7480ba979453b2cbdb1ed2762b6ab8f734a241af44b13caa81f5
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
simplecov_badger (0.0.1)
|
5
|
+
rest-client (~> 2.1.0)
|
6
|
+
simplecov (~> 0.18.5)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
docile (1.3.2)
|
12
|
+
domain_name (0.5.20190701)
|
13
|
+
unf (>= 0.0.5, < 1.0.0)
|
14
|
+
http-accept (1.7.0)
|
15
|
+
http-cookie (1.0.3)
|
16
|
+
domain_name (~> 0.5)
|
17
|
+
m (1.5.1)
|
18
|
+
method_source (>= 0.6.7)
|
19
|
+
rake (>= 0.9.2.2)
|
20
|
+
method_source (1.0.0)
|
21
|
+
mime-types (3.3.1)
|
22
|
+
mime-types-data (~> 3.2015)
|
23
|
+
mime-types-data (3.2019.1009)
|
24
|
+
minitest (5.14.0)
|
25
|
+
mocha (1.11.2)
|
26
|
+
netrc (0.11.0)
|
27
|
+
rake (12.3.3)
|
28
|
+
rest-client (2.1.0)
|
29
|
+
http-accept (>= 1.7.0, < 2.0)
|
30
|
+
http-cookie (>= 1.0.2, < 2.0)
|
31
|
+
mime-types (>= 1.16, < 4.0)
|
32
|
+
netrc (~> 0.8)
|
33
|
+
simplecov (0.18.5)
|
34
|
+
docile (~> 1.1)
|
35
|
+
simplecov-html (~> 0.11)
|
36
|
+
simplecov-html (0.12.2)
|
37
|
+
unf (0.1.4)
|
38
|
+
unf_ext
|
39
|
+
unf_ext (0.0.7.7)
|
40
|
+
|
41
|
+
PLATFORMS
|
42
|
+
ruby
|
43
|
+
|
44
|
+
DEPENDENCIES
|
45
|
+
m (~> 1.5.1)
|
46
|
+
minitest (~> 5.0)
|
47
|
+
mocha (~> 1.11.2)
|
48
|
+
rake (~> 12.0)
|
49
|
+
simplecov_badger!
|
50
|
+
|
51
|
+
BUNDLED WITH
|
52
|
+
2.1.4
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Nicolai Bach Woller
|
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,67 @@
|
|
1
|
+
# SimplecovBadger
|
2
|
+
This gem is a formatter for SimpleCov. It sends the total test coverage from SimpleCov to a url via a post request.
|
3
|
+
It is heavily inspired by the formatter in MarcGrimme's simplecov-small-badge: https://github.com/MarcGrimme/simplecov-small-badge
|
4
|
+
The gem is connected with our simplecov badge service for rendering badge .svgs. See more at: https://coverage.traels.it
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'simplecov_badger'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle install
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install simplecov_badger
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
There are very few things to do, before you can use the gem. The only necessary setup is to add the `SimplecovBadger::Formatter` to `SimpleCov`'s formatters in the same place you start `SimpleCov`:
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
SimpleCov.start do
|
28
|
+
SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new(
|
29
|
+
[
|
30
|
+
SimpleCov::Formatter::HTMLFormatter,
|
31
|
+
SimplecovBadger::Formatter # <-- this one
|
32
|
+
]
|
33
|
+
)
|
34
|
+
end
|
35
|
+
```
|
36
|
+
|
37
|
+
After running your test suite on your master branch, you can find a badge on the url https://coverage.traels.it/badges/[Base64.urlsafe_encode64(your_repo_url)]
|
38
|
+
Subsequent runs will update the badge on the same url.
|
39
|
+
|
40
|
+
The gem comes with a standard configuration. If you want to override any of these (three) settings, it can be done like this:
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
# this is the standard configuration
|
44
|
+
SimplecovBadger.configure do |config|
|
45
|
+
config.post_url = "coverage.traels.it/badges",
|
46
|
+
config.repo_url = `git remote -v`.split(" ")[1],
|
47
|
+
config.run_when = -> { `git rev-parse --abbrev-ref HEAD` == "master\n" }
|
48
|
+
end
|
49
|
+
```
|
50
|
+
Changing the `post_url` changes where the gem posts the coverage to and as a result you will have to make a service for drawing badges yourself.
|
51
|
+
The `repo_url` defaults to the git remote of the project you work on.
|
52
|
+
The `run_when` defaults to a lambda, that returns true if your current branch is master. This means the badge is only updated, when the test suite is run on the master branch. If replaced, it should be with another lambda that returns true whenever you want the badge updated.
|
53
|
+
|
54
|
+
## Development
|
55
|
+
|
56
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
57
|
+
|
58
|
+
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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
59
|
+
|
60
|
+
## Contributing
|
61
|
+
|
62
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/traels-it/simplecov_badger
|
63
|
+
|
64
|
+
|
65
|
+
## License
|
66
|
+
|
67
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "simplecov/post/formatter"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require "simplecov_badger/version"
|
2
|
+
require "simplecov_badger/formatter"
|
3
|
+
require "simplecov_badger/configuration"
|
4
|
+
require "base64"
|
5
|
+
require "rest-client"
|
6
|
+
|
7
|
+
module SimplecovBadger
|
8
|
+
class Error < StandardError; end
|
9
|
+
|
10
|
+
def self.configure
|
11
|
+
yield configuration
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.configuration
|
15
|
+
@configuration ||= Configuration.new
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module SimplecovBadger
|
2
|
+
class Configuration
|
3
|
+
def self.options
|
4
|
+
{
|
5
|
+
post_url: "coverage.traels.it/badges",
|
6
|
+
repo_url: `git remote -v`.split(" ")[1],
|
7
|
+
run_when: -> { `git rev-parse --abbrev-ref HEAD` == "master\n" }
|
8
|
+
}
|
9
|
+
end
|
10
|
+
|
11
|
+
options.keys.each do |opt|
|
12
|
+
define_method(opt) { instance_variable_get "@#{opt}" }
|
13
|
+
define_method("#{opt}=") { |val| instance_variable_set("@#{opt}", val) }
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize(**opts)
|
17
|
+
SimplecovBadger::Configuration.options.merge(opts).each { |opt, v| send(:"#{opt}=", v) }
|
18
|
+
end
|
19
|
+
|
20
|
+
def encoded_repo_url
|
21
|
+
raise SimplecovBadger::Error, "repo_url is nil" if repo_url.nil?
|
22
|
+
|
23
|
+
Base64.urlsafe_encode64(repo_url)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module SimplecovBadger
|
2
|
+
class Formatter
|
3
|
+
attr_reader :config
|
4
|
+
|
5
|
+
def initialize(output = nil)
|
6
|
+
@output = output || STDOUT
|
7
|
+
@config = SimplecovBadger.configuration
|
8
|
+
end
|
9
|
+
|
10
|
+
def format(result)
|
11
|
+
if config.run_when.call
|
12
|
+
RestClient.post(
|
13
|
+
config.post_url,
|
14
|
+
{ percentage: result.source_files.covered_percent.round(2), repo_url: config.encoded_repo_url }
|
15
|
+
)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require_relative 'lib/simplecov_badger/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "simplecov_badger"
|
5
|
+
spec.version = SimplecovBadger::VERSION
|
6
|
+
spec.authors = ["Nicolai Bach Woller"]
|
7
|
+
spec.email = ["woller@traels.it"]
|
8
|
+
|
9
|
+
spec.summary = %q{A small gem that posts simplecovs test coverage to a web service.}
|
10
|
+
spec.description = %q{A small gem that posts simplecovs test coverage to a web service.}
|
11
|
+
spec.homepage = "https://github.com/traels-it/simplecov_badger"
|
12
|
+
spec.license = "MIT"
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
14
|
+
|
15
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
16
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
17
|
+
|
18
|
+
# Specify which files should be added to the gem when it is released.
|
19
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
20
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
21
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
|
+
end
|
23
|
+
spec.bindir = "exe"
|
24
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
|
+
spec.require_paths = ["lib"]
|
26
|
+
|
27
|
+
# dependencies
|
28
|
+
spec.add_dependency "simplecov", "~> 0.18.5"
|
29
|
+
spec.add_dependency "rest-client", "~> 2.1.0"
|
30
|
+
|
31
|
+
spec.add_development_dependency "m", "~> 1.5.1"
|
32
|
+
spec.add_development_dependency "mocha", "~> 1.11.2"
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: simplecov_badger
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nicolai Bach Woller
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-04-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: simplecov
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.18.5
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.18.5
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rest-client
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.1.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.1.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: m
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.5.1
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.5.1
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: mocha
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.11.2
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.11.2
|
69
|
+
description: A small gem that posts simplecovs test coverage to a web service.
|
70
|
+
email:
|
71
|
+
- woller@traels.it
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".travis.yml"
|
78
|
+
- Gemfile
|
79
|
+
- Gemfile.lock
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/console
|
84
|
+
- bin/setup
|
85
|
+
- lib/simplecov_badger.rb
|
86
|
+
- lib/simplecov_badger/configuration.rb
|
87
|
+
- lib/simplecov_badger/formatter.rb
|
88
|
+
- lib/simplecov_badger/version.rb
|
89
|
+
- simplecov_badger.gemspec
|
90
|
+
homepage: https://github.com/traels-it/simplecov_badger
|
91
|
+
licenses:
|
92
|
+
- MIT
|
93
|
+
metadata:
|
94
|
+
homepage_uri: https://github.com/traels-it/simplecov_badger
|
95
|
+
source_code_uri: https://github.com/traels-it/simplecov_badger
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options: []
|
98
|
+
require_paths:
|
99
|
+
- lib
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: 2.3.0
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
requirements: []
|
111
|
+
rubygems_version: 3.1.2
|
112
|
+
signing_key:
|
113
|
+
specification_version: 4
|
114
|
+
summary: A small gem that posts simplecovs test coverage to a web service.
|
115
|
+
test_files: []
|