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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f4d774d270c5c09b19d0b976afa8891689ac77680a92212167dae59cf15d21da
4
- data.tar.gz: 4b4e434b9b1cb2e831bafa3ff7d4368473472f22328eb508b7637569f203d3d3
3
+ metadata.gz: 9991e96e26dfbc1c6d14ff8de33827fbf1d7f883d07cdfce17f9b20fae6f0f60
4
+ data.tar.gz: a65339cc048c2d18b2c8c6242744fa34d359cbf9e6c8b27d3fd3a6b794653020
5
5
  SHA512:
6
- metadata.gz: 4209b850927d96d06f904c85da2ef3e5c50af3f65fd21332304853f4c76c07018719ec96b25012f660bd7bf264ae417315618bbfdc46320e291e88519b0b9196
7
- data.tar.gz: eb998aa4886e38ed871f9f2e4ff513c6741e33ba21fd2804760df250b5af0336389890f9aa2b7480ba979453b2cbdb1ed2762b6ab8f734a241af44b13caa81f5
6
+ metadata.gz: 873826e79fc30581b8dc9ab531a9776176ab7bd47f02c6c9a0da776f7c92e8620e2f094b27a5c1bfc96aaab6f4718ac29a5990d479838fd3ab531cd5d55ebe9d
7
+ data.tar.gz: 44bff7625e2704e2e4ef3981bc379a0467bef03c95332e45c89e386dd56cff21bc5c76bae7d87bd1fb4dced8efb12ca252282fec55eaffc1c07ded4368e67d96
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # SimplecovBadger
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 `SimplecovBadger::Formatter` to `SimpleCov`'s formatters in the same place you start `SimpleCov`:
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
- SimplecovBadger::Formatter # <-- this one
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
- SimplecovBadger.configure do |config|
44
+ SimpleCov::Badger.configure do |config|
45
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" }
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 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.
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
 
@@ -4,14 +4,16 @@ require "simplecov_badger/configuration"
4
4
  require "base64"
5
5
  require "rest-client"
6
6
 
7
- module SimplecovBadger
8
- class Error < StandardError; end
7
+ module SimpleCov
8
+ module Badger
9
+ class Error < StandardError; end
9
10
 
10
- def self.configure
11
- yield configuration
12
- end
11
+ def self.configure
12
+ yield configuration
13
+ end
13
14
 
14
- def self.configuration
15
- @configuration ||= Configuration.new
15
+ def self.configuration
16
+ @configuration ||= Configuration.new
17
+ end
16
18
  end
17
19
  end
@@ -1,24 +1,19 @@
1
- module SimplecovBadger
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 remote -v`.split(" ")[1],
7
- run_when: -> { `git rev-parse --abbrev-ref HEAD` == "master\n" }
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
- 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) }
11
+ def initialize
12
+ super(self.class.options)
18
13
  end
19
14
 
20
15
  def encoded_repo_url
21
- raise SimplecovBadger::Error, "repo_url is nil" if repo_url.nil?
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 SimplecovBadger
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 = SimplecovBadger.configuration
7
+ @config = SimpleCov::Badger.configuration
8
8
  end
9
9
 
10
10
  def format(result)
11
- if config.run_when.call
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 }
@@ -1,3 +1,5 @@
1
- module SimplecovBadger
2
- VERSION = "0.0.1"
1
+ module SimpleCov
2
+ module Badger
3
+ VERSION = "0.0.2"
4
+ end
3
5
  end
@@ -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 = SimplecovBadger::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.1
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-17 00:00:00.000000000 Z
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: []