simplecov_badger 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -8
- data/lib/simplecov_badger.rb +9 -7
- data/lib/simplecov_badger/configuration.rb +7 -12
- data/lib/simplecov_badger/formatter.rb +3 -3
- data/lib/simplecov_badger/version.rb +4 -2
- data/simplecov_badger.gemspec +2 -2
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9991e96e26dfbc1c6d14ff8de33827fbf1d7f883d07cdfce17f9b20fae6f0f60
|
4
|
+
data.tar.gz: a65339cc048c2d18b2c8c6242744fa34d359cbf9e6c8b27d3fd3a6b794653020
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 873826e79fc30581b8dc9ab531a9776176ab7bd47f02c6c9a0da776f7c92e8620e2f094b27a5c1bfc96aaab6f4718ac29a5990d479838fd3ab531cd5d55ebe9d
|
7
|
+
data.tar.gz: 44bff7625e2704e2e4ef3981bc379a0467bef03c95332e45c89e386dd56cff21bc5c76bae7d87bd1fb4dced8efb12ca252282fec55eaffc1c07ded4368e67d96
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# SimpleCov::Badger
|
2
2
|
This gem is a formatter for SimpleCov. It sends the total test coverage from SimpleCov to a url via a post request.
|
3
3
|
It is heavily inspired by the formatter in MarcGrimme's simplecov-small-badge: https://github.com/MarcGrimme/simplecov-small-badge
|
4
4
|
The gem is connected with our simplecov badge service for rendering badge .svgs. See more at: https://coverage.traels.it
|
@@ -21,14 +21,14 @@ Or install it yourself as:
|
|
21
21
|
|
22
22
|
## Usage
|
23
23
|
|
24
|
-
There are very few things to do, before you can use the gem. The only necessary setup is to add the `
|
24
|
+
There are very few things to do, before you can use the gem. The only necessary setup is to add the `SimpleCov::Badger::Formatter` to `SimpleCov`'s formatters in the same place you start `SimpleCov`:
|
25
25
|
|
26
26
|
```ruby
|
27
27
|
SimpleCov.start do
|
28
28
|
SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new(
|
29
29
|
[
|
30
30
|
SimpleCov::Formatter::HTMLFormatter,
|
31
|
-
|
31
|
+
SimpleCov::Badger::Formatter # <-- this one
|
32
32
|
]
|
33
33
|
)
|
34
34
|
end
|
@@ -41,15 +41,15 @@ The gem comes with a standard configuration. If you want to override any of thes
|
|
41
41
|
|
42
42
|
```ruby
|
43
43
|
# this is the standard configuration
|
44
|
-
|
44
|
+
SimpleCov::Badger.configure do |config|
|
45
45
|
config.post_url = "coverage.traels.it/badges",
|
46
|
-
config.repo_url = `git
|
47
|
-
config.
|
46
|
+
config.repo_url = `git config --get remote.origin.url`,
|
47
|
+
config.run_if = -> { `git rev-parse --abbrev-ref HEAD` == "master\n" }
|
48
48
|
end
|
49
49
|
```
|
50
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
|
52
|
-
The `
|
51
|
+
The `repo_url` defaults to the git repo's origin url.
|
52
|
+
The `run_if` 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
53
|
|
54
54
|
## Development
|
55
55
|
|
data/lib/simplecov_badger.rb
CHANGED
@@ -4,14 +4,16 @@ require "simplecov_badger/configuration"
|
|
4
4
|
require "base64"
|
5
5
|
require "rest-client"
|
6
6
|
|
7
|
-
module
|
8
|
-
|
7
|
+
module SimpleCov
|
8
|
+
module Badger
|
9
|
+
class Error < StandardError; end
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
def self.configure
|
12
|
+
yield configuration
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
|
15
|
+
def self.configuration
|
16
|
+
@configuration ||= Configuration.new
|
17
|
+
end
|
16
18
|
end
|
17
19
|
end
|
@@ -1,24 +1,19 @@
|
|
1
|
-
module
|
2
|
-
class Configuration
|
1
|
+
module SimpleCov::Badger
|
2
|
+
class Configuration < OpenStruct
|
3
3
|
def self.options
|
4
4
|
{
|
5
5
|
post_url: "coverage.traels.it/badges",
|
6
|
-
repo_url: `git
|
7
|
-
|
6
|
+
repo_url: `git config --get remote.origin.url`,
|
7
|
+
run_if: -> { `git rev-parse --abbrev-ref HEAD` == "master\n" }
|
8
8
|
}
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
|
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) }
|
11
|
+
def initialize
|
12
|
+
super(self.class.options)
|
18
13
|
end
|
19
14
|
|
20
15
|
def encoded_repo_url
|
21
|
-
raise
|
16
|
+
raise SimpleCov::Badger::Error, "repo_url is nil" if repo_url.nil?
|
22
17
|
|
23
18
|
Base64.urlsafe_encode64(repo_url)
|
24
19
|
end
|
@@ -1,14 +1,14 @@
|
|
1
|
-
module
|
1
|
+
module SimpleCov::Badger
|
2
2
|
class Formatter
|
3
3
|
attr_reader :config
|
4
4
|
|
5
5
|
def initialize(output = nil)
|
6
6
|
@output = output || STDOUT
|
7
|
-
@config =
|
7
|
+
@config = SimpleCov::Badger.configuration
|
8
8
|
end
|
9
9
|
|
10
10
|
def format(result)
|
11
|
-
if config.
|
11
|
+
if config.run_if.call
|
12
12
|
RestClient.post(
|
13
13
|
config.post_url,
|
14
14
|
{ percentage: result.source_files.covered_percent.round(2), repo_url: config.encoded_repo_url }
|
data/simplecov_badger.gemspec
CHANGED
@@ -2,12 +2,12 @@ require_relative 'lib/simplecov_badger/version'
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "simplecov_badger"
|
5
|
-
spec.version =
|
5
|
+
spec.version = SimpleCov::Badger::VERSION
|
6
6
|
spec.authors = ["Nicolai Bach Woller"]
|
7
7
|
spec.email = ["woller@traels.it"]
|
8
8
|
|
9
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.}
|
10
|
+
spec.description = %q{A small gem that posts simplecovs test coverage to a web service. We've built a web service for rendering coverage badge svgs too. You can find it at coverage.traels.it}
|
11
11
|
spec.homepage = "https://github.com/traels-it/simplecov_badger"
|
12
12
|
spec.license = "MIT"
|
13
13
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simplecov_badger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicolai Bach Woller
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-04-
|
11
|
+
date: 2020-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simplecov
|
@@ -66,7 +66,8 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 1.11.2
|
69
|
-
description: A small gem that posts simplecovs test coverage to a web service.
|
69
|
+
description: A small gem that posts simplecovs test coverage to a web service. We've
|
70
|
+
built a web service for rendering coverage badge svgs too. You can find it at coverage.traels.it
|
70
71
|
email:
|
71
72
|
- woller@traels.it
|
72
73
|
executables: []
|