coveralls_reborn 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +59 -0
- data/.travis.yml +9 -4
- data/Gemfile +17 -16
- data/LICENSE +17 -18
- data/README.md +7 -1
- data/Rakefile +9 -3
- data/bin/coveralls +2 -1
- data/coveralls-ruby.gemspec +15 -13
- data/lib/coveralls/api.rb +72 -68
- data/lib/coveralls/command.rb +28 -24
- data/lib/coveralls/configuration.rb +46 -52
- data/lib/coveralls/output.rb +12 -7
- data/lib/coveralls/rake/task.rb +7 -6
- data/lib/coveralls/simplecov.rb +34 -32
- data/lib/coveralls/version.rb +3 -1
- data/lib/coveralls.rb +43 -41
- data/spec/coveralls/configuration_spec.rb +212 -160
- data/spec/coveralls/coveralls_spec.rb +41 -46
- data/spec/coveralls/fixtures/app/controllers/sample.rb +2 -0
- data/spec/coveralls/fixtures/app/models/airplane.rb +4 -2
- data/spec/coveralls/output_spec.rb +38 -51
- data/spec/coveralls/simple_cov/formatter_spec.rb +82 -0
- data/spec/spec_helper.rb +15 -18
- metadata +21 -16
- data/spec/coveralls/simplecov_spec.rb +0 -82
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4cd807256f3b2424a9ebd737660d179e8bb448f
|
4
|
+
data.tar.gz: 1c83b8e8be4f2d03bf62c26996ff34c52c0f3be2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffd14ccfc5339a43af2951d40be456a27b2d3d805406cd8fe5519a23eea58e6324c5c6ce5b8c5f8ea5ab626d139d3081a6a8efd14b4b62b870299237fad9e13a
|
7
|
+
data.tar.gz: 359db8935442a61cb3d676d73a59ac9be7a5f2647ca238b80daa824d84012485253564274a550d80e7099539538e70f2d43e86bdea61b1458a61aeaa6797f3e0
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require: rubocop-rspec
|
2
|
+
|
3
|
+
AllCops:
|
4
|
+
DisplayCopNames: true
|
5
|
+
TargetRubyVersion: 2.1
|
6
|
+
Exclude:
|
7
|
+
- 'spec/coveralls/fixtures/**/*'
|
8
|
+
- 'vendor/bundle/**/*'
|
9
|
+
|
10
|
+
Lint/HandleExceptions:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
Metrics/AbcSize:
|
14
|
+
Max: 37
|
15
|
+
|
16
|
+
Metrics/CyclomaticComplexity:
|
17
|
+
Max: 18
|
18
|
+
|
19
|
+
Metrics/PerceivedComplexity:
|
20
|
+
Max: 19
|
21
|
+
|
22
|
+
Metrics/BlockLength:
|
23
|
+
Exclude:
|
24
|
+
- 'spec/**/*'
|
25
|
+
|
26
|
+
Metrics/LineLength:
|
27
|
+
Enabled: false
|
28
|
+
|
29
|
+
Metrics/MethodLength:
|
30
|
+
Enabled: false
|
31
|
+
|
32
|
+
Metrics/ModuleLength:
|
33
|
+
Exclude:
|
34
|
+
- 'lib/coveralls/configuration.rb'
|
35
|
+
- 'spec/**/*'
|
36
|
+
|
37
|
+
Naming/AccessorMethodName:
|
38
|
+
Exclude:
|
39
|
+
- 'lib/coveralls/configuration.rb'
|
40
|
+
|
41
|
+
RSpec/ExampleLength:
|
42
|
+
Max: 8
|
43
|
+
|
44
|
+
RSpec/MultipleExpectations:
|
45
|
+
Enabled: false
|
46
|
+
|
47
|
+
RSpec/NamedSubject:
|
48
|
+
Enabled: false
|
49
|
+
|
50
|
+
RSpec/NestedGroups:
|
51
|
+
Max: 4
|
52
|
+
|
53
|
+
Style/Documentation:
|
54
|
+
Enabled: false
|
55
|
+
|
56
|
+
# TODO: Remove when targeting Ruby 2.3 because it is already enabled.
|
57
|
+
Style/FrozenStringLiteralComment:
|
58
|
+
Enabled: true
|
59
|
+
EnforcedStyle: always
|
data/.travis.yml
CHANGED
@@ -7,18 +7,23 @@ sudo: false
|
|
7
7
|
before_install:
|
8
8
|
- gem update bundler
|
9
9
|
|
10
|
+
env:
|
11
|
+
global:
|
12
|
+
# --dev improves JRuby startup time
|
13
|
+
# --debug reports proper coverage to SimpleCov
|
14
|
+
# See https://github.com/jruby/jruby/wiki/Improving-startup-time
|
15
|
+
- JRUBY_OPTS="--dev --debug"
|
16
|
+
|
10
17
|
rvm:
|
11
|
-
- 1.9.3
|
12
|
-
- 2.0.0
|
13
18
|
- 2.1.10
|
14
19
|
- 2.2.8
|
15
20
|
- 2.3.5
|
16
21
|
- 2.4.2
|
17
22
|
- ruby-head
|
18
|
-
- jruby
|
23
|
+
- jruby-9.1.13.0
|
19
24
|
|
20
25
|
matrix:
|
21
26
|
allow_failures:
|
22
27
|
- rvm: ruby-head
|
23
|
-
- rvm: jruby
|
28
|
+
- rvm: jruby-9.1.13.0
|
24
29
|
fast_finish: true
|
data/Gemfile
CHANGED
@@ -1,29 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source 'https://rubygems.org'
|
2
4
|
|
3
5
|
# Specify your gem's dependencies in coveralls-ruby.gemspec
|
4
6
|
gemspec
|
5
7
|
|
6
|
-
|
7
|
-
gem '
|
8
|
-
gem 'simplecov', require: false
|
9
|
-
gem 'truthy', '~> 1.0'
|
10
|
-
gem 'vcr', '~> 3.0'
|
11
|
-
gem 'webmock', Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.0') ? '~> 2.3' : '~> 3.0'
|
12
|
-
|
13
|
-
platforms :ruby_19 do
|
14
|
-
gem 'term-ansicolor', '~> 1.3.0'
|
15
|
-
gem 'tins', '~> 1.6.0'
|
8
|
+
platforms :jruby do
|
9
|
+
gem 'jruby-openssl', '~> 0.9.21'
|
16
10
|
end
|
17
11
|
|
18
|
-
platforms :
|
19
|
-
gem '
|
12
|
+
platforms :rbx do
|
13
|
+
gem 'rubinius-developer_tools', '~> 2.0'
|
14
|
+
gem 'rubysl', '~> 2.2'
|
20
15
|
end
|
21
16
|
|
22
|
-
|
23
|
-
gem '
|
24
|
-
gem '
|
17
|
+
group :development do
|
18
|
+
gem 'rake', '~> 12.2'
|
19
|
+
gem 'rspec', '~> 3.7'
|
20
|
+
gem 'rubocop', '~> 0.51.0'
|
21
|
+
gem 'rubocop-rspec', '~> 1.20'
|
22
|
+
gem 'simplecov', '~> 0.15.1', require: false
|
23
|
+
gem 'truthy', '~> 1.0'
|
24
|
+
gem 'vcr', '~> 3.0'
|
25
|
+
gem 'webmock', '~> 3.1'
|
25
26
|
end
|
26
27
|
|
27
28
|
group :test do
|
28
|
-
gem 'pry'
|
29
|
+
gem 'pry', '~> 0.11.3'
|
29
30
|
end
|
data/LICENSE
CHANGED
@@ -1,22 +1,21 @@
|
|
1
|
-
Copyright (c) 2012 Wil Gieseler
|
2
|
-
|
3
1
|
MIT License
|
4
2
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
the
|
3
|
+
Copyright (c) 2017 Wil Gieseler
|
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:
|
12
11
|
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
15
14
|
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
OF
|
22
|
-
|
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 THE
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
|
-
# [Coveralls Reborn](http://coveralls.io) for Ruby [](https://coveralls.io/r/tagliala/coveralls-ruby-reborn) [](https://travis-ci.org/tagliala/coveralls-ruby-reborn) [ for Ruby [](https://coveralls.io/r/tagliala/coveralls-ruby-reborn) [](https://travis-ci.org/tagliala/coveralls-ruby-reborn) [](http://badge.fury.io/rb/coveralls_reborn) [](https://gemnasium.com/github.com/tagliala/coveralls-ruby-reborn)
|
2
2
|
|
3
3
|
### [Read the docs →](https://coveralls.zendesk.com/hc/en-us/articles/201769485-Ruby-Rails)
|
4
4
|
|
5
5
|
An up-to-date fork of [lemurheavy/coveralls-ruby](https://github.com/lemurheavy/coveralls-ruby)
|
6
|
+
|
7
|
+
Add to your `Gemfile`:
|
8
|
+
|
9
|
+
```rb
|
10
|
+
gem 'coveralls_reborn', '~> 0.10.0', require: false
|
11
|
+
```
|
data/Rakefile
CHANGED
@@ -1,14 +1,20 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
|
-
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/gem_tasks'
|
3
5
|
|
4
6
|
# Travis!
|
5
7
|
require 'rubygems'
|
6
8
|
require 'rake'
|
7
9
|
require 'rspec/core/rake_task'
|
8
10
|
|
9
|
-
|
11
|
+
require 'rubocop/rake_task'
|
12
|
+
|
13
|
+
RuboCop::RakeTask.new
|
14
|
+
|
15
|
+
desc 'Run RSpec'
|
10
16
|
RSpec::Core::RakeTask.new do |t|
|
11
17
|
t.verbose = false
|
12
18
|
end
|
13
19
|
|
14
|
-
task default:
|
20
|
+
task default: %i[rubocop spec]
|
data/bin/coveralls
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
|
4
5
|
$LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
|
@@ -6,4 +7,4 @@ $LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
|
|
6
7
|
require 'coveralls'
|
7
8
|
require 'coveralls/command'
|
8
9
|
|
9
|
-
Coveralls::CommandLine.start
|
10
|
+
Coveralls::CommandLine.start
|
data/coveralls-ruby.gemspec
CHANGED
@@ -1,29 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
lib = File.expand_path('../lib', __FILE__)
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
5
|
require 'coveralls/version'
|
4
6
|
|
5
7
|
Gem::Specification.new do |gem|
|
6
|
-
gem.authors = [
|
7
|
-
gem.email = [
|
8
|
-
gem.description =
|
9
|
-
gem.summary =
|
10
|
-
gem.homepage =
|
11
|
-
gem.license =
|
8
|
+
gem.authors = ['Nick Merwin', 'Wil Gieseler', 'Geremia Taglialatela']
|
9
|
+
gem.email = ['nick@lemurheavy.com', 'supapuerco@gmail.com', 'tagliala.dev@gmail.com']
|
10
|
+
gem.description = 'A Ruby implementation of the Coveralls API.'
|
11
|
+
gem.summary = 'A Ruby implementation of the Coveralls API.'
|
12
|
+
gem.homepage = 'https://coveralls.io'
|
13
|
+
gem.license = 'MIT'
|
12
14
|
|
13
|
-
gem.files = `git ls-files`.split(
|
14
|
-
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
15
|
+
gem.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
15
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
16
|
-
gem.name =
|
17
|
-
gem.require_paths = [
|
18
|
+
gem.name = 'coveralls_reborn'
|
19
|
+
gem.require_paths = ['lib']
|
18
20
|
gem.version = Coveralls::VERSION
|
19
21
|
|
20
|
-
gem.required_ruby_version = '>= 1
|
22
|
+
gem.required_ruby_version = '>= 2.1'
|
21
23
|
|
22
24
|
gem.add_dependency 'json', '~> 2.1'
|
23
25
|
gem.add_dependency 'simplecov', '~> 0.15.1'
|
24
|
-
gem.add_dependency 'tins', '~> 1.6'
|
25
26
|
gem.add_dependency 'term-ansicolor', '~> 1.3'
|
26
27
|
gem.add_dependency 'thor', '~> 0.20.0'
|
28
|
+
gem.add_dependency 'tins', '~> 1.6'
|
27
29
|
|
28
|
-
gem.add_development_dependency 'bundler', '~> 1.
|
30
|
+
gem.add_development_dependency 'bundler', '~> 1.16'
|
29
31
|
end
|
data/lib/coveralls/api.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'json'
|
2
4
|
require 'net/https'
|
3
5
|
require 'tempfile'
|
@@ -8,121 +10,123 @@ module Coveralls
|
|
8
10
|
API_HOST = ENV['COVERALLS_ENDPOINT']
|
9
11
|
API_DOMAIN = ENV['COVERALLS_ENDPOINT']
|
10
12
|
else
|
11
|
-
API_HOST = ENV['COVERALLS_DEVELOPMENT'] ?
|
12
|
-
API_PROTOCOL = ENV['COVERALLS_DEVELOPMENT'] ?
|
13
|
-
API_DOMAIN = "#{API_PROTOCOL}://#{API_HOST}"
|
13
|
+
API_HOST = ENV['COVERALLS_DEVELOPMENT'] ? 'localhost:3000' : 'coveralls.io'
|
14
|
+
API_PROTOCOL = ENV['COVERALLS_DEVELOPMENT'] ? 'http' : 'https'
|
15
|
+
API_DOMAIN = "#{API_PROTOCOL}://#{API_HOST}".freeze
|
14
16
|
end
|
15
17
|
|
16
|
-
API_BASE = "#{API_DOMAIN}/api/v1"
|
18
|
+
API_BASE = "#{API_DOMAIN}/api/v1".freeze
|
17
19
|
|
18
20
|
def self.post_json(endpoint, hash)
|
19
21
|
disable_net_blockers!
|
20
22
|
|
21
23
|
uri = endpoint_to_uri(endpoint)
|
22
24
|
|
23
|
-
Coveralls::Output.puts(
|
24
|
-
Coveralls::Output.puts("[Coveralls] Submitting to #{API_BASE}", color:
|
25
|
+
Coveralls::Output.puts(JSON.pretty_generate(hash).to_s, color: 'green') if ENV['COVERALLS_DEBUG']
|
26
|
+
Coveralls::Output.puts("[Coveralls] Submitting to #{API_BASE}", color: 'cyan')
|
25
27
|
|
26
28
|
client = build_client(uri)
|
27
29
|
request = build_request(uri.path, hash)
|
28
30
|
|
29
31
|
response = client.request(request)
|
30
32
|
|
31
|
-
response_hash = JSON.
|
33
|
+
response_hash = JSON.parse(response.body.to_str)
|
32
34
|
|
33
35
|
if response_hash['message']
|
34
|
-
Coveralls::Output.puts("[Coveralls] #{
|
36
|
+
Coveralls::Output.puts("[Coveralls] #{response_hash['message']}", color: 'cyan')
|
35
37
|
end
|
36
38
|
|
37
39
|
if response_hash['url']
|
38
|
-
Coveralls::Output.puts("[Coveralls] #{
|
40
|
+
Coveralls::Output.puts("[Coveralls] #{Coveralls::Output.format(response_hash['url'], color: 'underline')}", color: 'cyan')
|
39
41
|
end
|
40
42
|
|
41
43
|
case response
|
42
44
|
when Net::HTTPServiceUnavailable
|
43
|
-
Coveralls::Output.puts(
|
45
|
+
Coveralls::Output.puts('[Coveralls] API timeout occured, but data should still be processed', color: 'red')
|
44
46
|
when Net::HTTPInternalServerError
|
45
|
-
Coveralls::Output.puts("[Coveralls] API internal error occured, we're on it!", color:
|
47
|
+
Coveralls::Output.puts("[Coveralls] API internal error occured, we're on it!", color: 'red')
|
46
48
|
end
|
47
49
|
end
|
48
50
|
|
49
|
-
|
51
|
+
class << self
|
52
|
+
private
|
50
53
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
+
def disable_net_blockers!
|
55
|
+
begin
|
56
|
+
require 'webmock'
|
54
57
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
58
|
+
allow = WebMock::Config.instance.allow || []
|
59
|
+
WebMock::Config.instance.allow = [*allow].push API_HOST
|
60
|
+
rescue LoadError
|
61
|
+
end
|
59
62
|
|
60
|
-
|
61
|
-
|
63
|
+
begin
|
64
|
+
require 'vcr'
|
62
65
|
|
63
|
-
|
64
|
-
|
66
|
+
VCR.send(VCR.version.major < 2 ? :config : :configure) do |c|
|
67
|
+
c.ignore_hosts API_HOST
|
68
|
+
end
|
69
|
+
rescue LoadError
|
65
70
|
end
|
66
|
-
rescue LoadError
|
67
71
|
end
|
68
|
-
end
|
69
72
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
+
def endpoint_to_uri(endpoint)
|
74
|
+
URI.parse("#{API_BASE}/#{endpoint}")
|
75
|
+
end
|
73
76
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
77
|
+
def build_client(uri)
|
78
|
+
client = Net::HTTP.new(uri.host, uri.port)
|
79
|
+
client.use_ssl = true if uri.port == 443
|
80
|
+
client.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
78
81
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
+
unless client.respond_to?(:ssl_version=)
|
83
|
+
Net::HTTP.ssl_context_accessor('ssl_version')
|
84
|
+
end
|
82
85
|
|
83
|
-
|
86
|
+
client.ssl_version = 'TLSv1'
|
84
87
|
|
85
|
-
|
86
|
-
|
88
|
+
client
|
89
|
+
end
|
87
90
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
+
def build_request(path, hash)
|
92
|
+
request = Net::HTTP::Post.new(path)
|
93
|
+
boundary = rand(1_000_000).to_s
|
91
94
|
|
92
|
-
|
93
|
-
|
95
|
+
request.body = build_request_body(hash, boundary)
|
96
|
+
request.content_type = "multipart/form-data, boundary=#{boundary}"
|
94
97
|
|
95
|
-
|
96
|
-
|
98
|
+
request
|
99
|
+
end
|
97
100
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
+
def build_request_body(hash, boundary)
|
102
|
+
hash = apified_hash(hash)
|
103
|
+
file = hash_to_file(hash)
|
101
104
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
105
|
+
"--#{boundary}\r\n" \
|
106
|
+
"Content-Disposition: form-data; name=\"json_file\"; filename=\"#{File.basename(file.path)}\"\r\n" \
|
107
|
+
"Content-Type: text/plain\r\n\r\n" +
|
108
|
+
File.read(file.path) +
|
109
|
+
"\r\n--#{boundary}--\r\n"
|
110
|
+
end
|
108
111
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
112
|
+
def hash_to_file(hash)
|
113
|
+
file = nil
|
114
|
+
Tempfile.open(['coveralls-upload', 'json']) do |f|
|
115
|
+
f.write(JSON.dump(hash))
|
116
|
+
file = f
|
117
|
+
end
|
118
|
+
File.new(file.path, 'rb')
|
114
119
|
end
|
115
|
-
File.new(file.path, 'rb')
|
116
|
-
end
|
117
120
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
121
|
+
def apified_hash(hash)
|
122
|
+
config = Coveralls::Configuration.configuration
|
123
|
+
if ENV['COVERALLS_DEBUG'] || Coveralls.testing
|
124
|
+
Coveralls::Output.puts '[Coveralls] Submitting with config:', color: 'yellow'
|
125
|
+
output = JSON.pretty_generate(config).gsub(/"repo_token": ?"(.*?)"/, '"repo_token": "[secure]"')
|
126
|
+
Coveralls::Output.puts output, color: 'yellow'
|
127
|
+
end
|
128
|
+
hash.merge(config)
|
124
129
|
end
|
125
|
-
hash.merge(config)
|
126
130
|
end
|
127
131
|
end
|
128
132
|
end
|
data/lib/coveralls/command.rb
CHANGED
@@ -1,69 +1,73 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'thor'
|
2
4
|
|
3
5
|
module Coveralls
|
4
6
|
class CommandLine < Thor
|
5
|
-
|
6
|
-
desc "push", "Runs your test suite and pushes the coverage results to Coveralls."
|
7
|
+
desc 'push', 'Runs your test suite and pushes the coverage results to Coveralls.'
|
7
8
|
def push
|
8
9
|
return unless ensure_can_run_locally!
|
9
|
-
ENV[
|
10
|
-
cmds = [
|
10
|
+
ENV['COVERALLS_RUN_LOCALLY'] = 'true'
|
11
|
+
cmds = ['bundle exec rake']
|
11
12
|
if File.exist?('.travis.yml')
|
12
|
-
cmds =
|
13
|
+
cmds = begin
|
14
|
+
YAML.load_file('.travis.yml')['script'] || cmds
|
15
|
+
rescue StandardError
|
16
|
+
cmds
|
17
|
+
end
|
13
18
|
end
|
14
19
|
cmds.each { |cmd| system cmd }
|
15
|
-
ENV[
|
20
|
+
ENV['COVERALLS_RUN_LOCALLY'] = nil
|
16
21
|
end
|
17
22
|
|
18
|
-
desc
|
23
|
+
desc 'report', 'Runs your test suite locally and displays coverage statistics.'
|
19
24
|
def report
|
20
|
-
ENV[
|
21
|
-
exec
|
22
|
-
ENV[
|
25
|
+
ENV['COVERALLS_NOISY'] = 'true'
|
26
|
+
exec 'bundle exec rake'
|
27
|
+
ENV['COVERALLS_NOISY'] = nil
|
23
28
|
end
|
24
29
|
|
25
|
-
desc
|
30
|
+
desc 'open', 'View this repository on Coveralls.'
|
26
31
|
def open
|
27
|
-
open_token_based_url
|
32
|
+
open_token_based_url 'https://coveralls.io/repos/%@'
|
28
33
|
end
|
29
34
|
|
30
|
-
desc
|
35
|
+
desc 'service', "View this repository on your CI service's website."
|
31
36
|
def service
|
32
|
-
open_token_based_url
|
37
|
+
open_token_based_url 'https://coveralls.io/repos/%@/service'
|
33
38
|
end
|
34
39
|
|
35
|
-
desc
|
40
|
+
desc 'last', 'View the last build for this repository on Coveralls.'
|
36
41
|
def last
|
37
|
-
open_token_based_url
|
42
|
+
open_token_based_url 'https://coveralls.io/repos/%@/last_build'
|
38
43
|
end
|
39
44
|
|
40
|
-
desc
|
45
|
+
desc 'version', 'See version'
|
41
46
|
def version
|
42
47
|
Coveralls::Output.puts Coveralls::VERSION
|
43
48
|
end
|
44
49
|
|
45
50
|
private
|
46
51
|
|
47
|
-
def open_token_based_url
|
52
|
+
def open_token_based_url(url)
|
48
53
|
config = Coveralls::Configuration.configuration
|
49
54
|
if config[:repo_token]
|
50
|
-
url = url.gsub(
|
55
|
+
url = url.gsub('%@', config[:repo_token])
|
51
56
|
`open #{url}`
|
52
57
|
else
|
53
|
-
Coveralls::Output.puts
|
58
|
+
Coveralls::Output.puts 'No repo_token configured.'
|
54
59
|
end
|
55
60
|
end
|
56
61
|
|
57
62
|
def ensure_can_run_locally!
|
58
63
|
config = Coveralls::Configuration.configuration
|
59
64
|
if config[:repo_token].nil?
|
60
|
-
Coveralls::Output.puts
|
61
|
-
Coveralls::Output.puts
|
65
|
+
Coveralls::Output.puts 'Coveralls cannot run locally because no repo_secret_token is set in .coveralls.yml', color: 'red'
|
66
|
+
Coveralls::Output.puts 'Please try again when you get your act together.', color: 'red'
|
62
67
|
|
63
68
|
return false
|
64
69
|
end
|
65
70
|
true
|
66
71
|
end
|
67
|
-
|
68
72
|
end
|
69
73
|
end
|