coveralls 0.6.9 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +8 -0
- data/lib/coveralls.rb +10 -6
- data/lib/coveralls/api.rb +5 -5
- data/lib/coveralls/command.rb +2 -2
- data/lib/coveralls/output.rb +30 -6
- data/lib/coveralls/rake/task.rb +1 -2
- data/lib/coveralls/simplecov.rb +4 -4
- data/lib/coveralls/version.rb +1 -1
- data/spec/coveralls/coveralls_spec.rb +26 -0
- data/spec/coveralls/output_spec.rb +54 -2
- data/spec/coveralls/simplecov_spec.rb +4 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37fb125236b8084bb66698ff83b734e7c50019c7
|
4
|
+
data.tar.gz: 5c14c65f7b7a093ab62b7b3219c8a18d9102b84a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1e17590b229ed02769fc5004ad45ad2469f647913af1259049b7ff59c9f2d6130b450a28472e707306fb143171a7c6f007e047584fcc48cd52a1103325cc755
|
7
|
+
data.tar.gz: 9e3f728924b192cddbb5b608f7f5f596a250a716f27c1acf39fc8b227b7ac4c7164062caf11435271afe6114138167b402fbe0df90f9c5f25bfcb95400eb7091
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## 0.7.0 (September 18, 2013)
|
2
|
+
|
3
|
+
[Full Changelog](https://github.com/lemurheavy/coveralls-ruby/compare/v0.6.4...v0.7.0)
|
4
|
+
|
5
|
+
Added:
|
6
|
+
* output silencing (Thanks @elizabrock)
|
7
|
+
* ruby warning fixes (Thanks @steveklabnik and @Nucc)
|
8
|
+
|
1
9
|
## 0.6.4 (April 2, 2013)
|
2
10
|
|
3
11
|
[Full Changelog](https://github.com/lemurheavy/coveralls-ruby/compare/v0.6.3...v0.6.4)
|
data/lib/coveralls.rb
CHANGED
@@ -66,9 +66,9 @@ module Coveralls
|
|
66
66
|
else
|
67
67
|
::SimpleCov.start(simplecov_setting)
|
68
68
|
end
|
69
|
-
elsif
|
69
|
+
elsif block
|
70
70
|
Coveralls::Output.puts("[Coveralls] Using SimpleCov settings defined in block.", :color => "green")
|
71
|
-
::SimpleCov.start { instance_eval(&block)}
|
71
|
+
::SimpleCov.start { instance_eval(&block) }
|
72
72
|
else
|
73
73
|
Coveralls::Output.puts("[Coveralls] Using SimpleCov's default settings.", :color => "green")
|
74
74
|
::SimpleCov.start
|
@@ -78,20 +78,24 @@ module Coveralls
|
|
78
78
|
|
79
79
|
def should_run?
|
80
80
|
# Fail early if we're not on a CI
|
81
|
-
unless
|
82
|
-
ENV["COVERALLS_RUN_LOCALLY"] || testing
|
81
|
+
unless will_run?
|
83
82
|
Coveralls::Output.puts("[Coveralls] Outside the Travis environment, not sending data.", :color => "yellow")
|
84
83
|
return false
|
85
84
|
end
|
86
85
|
|
87
|
-
if ENV["COVERALLS_RUN_LOCALLY"] || run_locally
|
86
|
+
if ENV["COVERALLS_RUN_LOCALLY"] || (defined?(@run_locally) && @run_locally)
|
88
87
|
Coveralls::Output.puts("[Coveralls] Creating a new job on Coveralls from local coverage results.", :color => "cyan")
|
89
88
|
end
|
90
89
|
|
91
90
|
true
|
92
91
|
end
|
93
92
|
|
93
|
+
def will_run?
|
94
|
+
ENV["CI"] || ENV["JENKINS_URL"] || ENV["COVERALLS_RUN_LOCALLY"] ||
|
95
|
+
(defined?(@testing) && @testing)
|
96
|
+
end
|
97
|
+
|
94
98
|
def noisy?
|
95
|
-
ENV["COVERALLS_NOISY"] || noisy
|
99
|
+
ENV["COVERALLS_NOISY"] || (defined?(@noisy) && @noisy)
|
96
100
|
end
|
97
101
|
end
|
data/lib/coveralls/api.rb
CHANGED
@@ -14,17 +14,17 @@ module Coveralls
|
|
14
14
|
url = endpoint_to_url(endpoint)
|
15
15
|
Coveralls::Output.puts("#{ MultiJson.dump(hash, :pretty => true) }", :color => "green") if ENV['COVERALLS_DEBUG']
|
16
16
|
hash = apified_hash hash
|
17
|
-
Coveralls::Output.puts
|
17
|
+
Coveralls::Output.puts("[Coveralls] Submitting to #{API_BASE}", :color => "cyan")
|
18
18
|
response = RestClient.post(url, :json_file => hash_to_file(hash))
|
19
19
|
response_hash = MultiJson.load(response.to_str)
|
20
|
-
Coveralls::Output.puts
|
20
|
+
Coveralls::Output.puts("[Coveralls] #{ response_hash['message'] }", :color => "cyan")
|
21
21
|
if response_hash['message']
|
22
22
|
Coveralls::Output.puts("[Coveralls] #{ Coveralls::Output.format(response_hash['url'], :color => "underline") }", :color => "cyan")
|
23
23
|
end
|
24
24
|
rescue RestClient::ServiceUnavailable
|
25
|
-
Coveralls::Output.puts
|
25
|
+
Coveralls::Output.puts("[Coveralls] API timeout occured, but data should still be processed", :color => "red")
|
26
26
|
rescue RestClient::InternalServerError
|
27
|
-
Coveralls::Output.puts
|
27
|
+
Coveralls::Output.puts("[Coveralls] API internal error occured, we're on it!", :color => "red")
|
28
28
|
end
|
29
29
|
|
30
30
|
private
|
@@ -58,7 +58,7 @@ module Coveralls
|
|
58
58
|
def self.apified_hash hash
|
59
59
|
config = Coveralls::Configuration.configuration
|
60
60
|
if ENV['CI'] || ENV['COVERALLS_DEBUG'] || Coveralls.testing
|
61
|
-
Coveralls::Output.puts "[Coveralls]
|
61
|
+
Coveralls::Output.puts "[Coveralls] Submitting with config:", :color => "yellow"
|
62
62
|
output = MultiJson.dump(config, :pretty => true).gsub(/"repo_token": "(.*?)"/,'"repo_token": "[secure]"')
|
63
63
|
Coveralls::Output.puts output, :color => "yellow"
|
64
64
|
end
|
data/lib/coveralls/command.rb
CHANGED
@@ -39,7 +39,7 @@ module Coveralls
|
|
39
39
|
|
40
40
|
desc "version", "See version"
|
41
41
|
def version
|
42
|
-
puts Coveralls::VERSION
|
42
|
+
Coveralls::Output.puts Coveralls::VERSION
|
43
43
|
end
|
44
44
|
|
45
45
|
private
|
@@ -50,7 +50,7 @@ module Coveralls
|
|
50
50
|
url = url.gsub("%@", config[:repo_token])
|
51
51
|
`open #{url}`
|
52
52
|
else
|
53
|
-
puts "No repo_token configured."
|
53
|
+
Coveralls::Output.puts "No repo_token configured."
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
data/lib/coveralls/output.rb
CHANGED
@@ -18,10 +18,25 @@ module Coveralls
|
|
18
18
|
# Coveralls::Output.puts("Hello World", :color => "underline")
|
19
19
|
# # Hello World
|
20
20
|
# # => nil
|
21
|
+
#
|
22
|
+
# To silence output completely:
|
23
|
+
#
|
24
|
+
# Coveralls::Output.silent = true
|
25
|
+
#
|
26
|
+
# or set this environment variable:
|
27
|
+
#
|
28
|
+
# COVERALLS_SILENT
|
29
|
+
|
21
30
|
module Output
|
22
31
|
require 'term/ansicolor'
|
32
|
+
attr_accessor :silent
|
33
|
+
attr_writer :output
|
23
34
|
extend self
|
24
35
|
|
36
|
+
def output
|
37
|
+
(defined?(@output) && @output) || $stdout
|
38
|
+
end
|
39
|
+
|
25
40
|
# Public: Formats the given string with the specified color
|
26
41
|
# through Term::ANSIColor
|
27
42
|
#
|
@@ -37,11 +52,14 @@ module Coveralls
|
|
37
52
|
#
|
38
53
|
# Returns the formatted string.
|
39
54
|
def format(string, options = {})
|
40
|
-
if options[:color]
|
41
|
-
|
42
|
-
|
43
|
-
|
55
|
+
if options[:color]
|
56
|
+
options[:color].split(/\s/).reverse_each do |color|
|
57
|
+
if Term::ANSIColor.respond_to?(color.to_sym)
|
58
|
+
string = Term::ANSIColor.send(color.to_sym, string)
|
59
|
+
end
|
60
|
+
end
|
44
61
|
end
|
62
|
+
string
|
45
63
|
end
|
46
64
|
|
47
65
|
# Public: Passes .format to Kernel#puts
|
@@ -58,7 +76,8 @@ module Coveralls
|
|
58
76
|
#
|
59
77
|
# Returns nil.
|
60
78
|
def puts(string, options = {})
|
61
|
-
|
79
|
+
return if silent?
|
80
|
+
(options[:output] || output).puts self.format(string, options)
|
62
81
|
end
|
63
82
|
|
64
83
|
# Public: Passes .format to Kernel#print
|
@@ -74,7 +93,12 @@ module Coveralls
|
|
74
93
|
#
|
75
94
|
# Returns nil.
|
76
95
|
def print(string, options = {})
|
77
|
-
|
96
|
+
return if silent?
|
97
|
+
(options[:output] || output).print self.format(string, options)
|
98
|
+
end
|
99
|
+
|
100
|
+
def silent?
|
101
|
+
ENV["COVERALLS_SILENT"] || (defined?(@silent) && @silent)
|
78
102
|
end
|
79
103
|
end
|
80
104
|
end
|
data/lib/coveralls/rake/task.rb
CHANGED
data/lib/coveralls/simplecov.rb
CHANGED
@@ -5,12 +5,12 @@ module Coveralls
|
|
5
5
|
def display_result(result)
|
6
6
|
# Log which files would be submitted.
|
7
7
|
if result.files.length > 0
|
8
|
-
puts "[Coveralls] Some handy coverage stats:"
|
8
|
+
Coveralls::Output.puts "[Coveralls] Some handy coverage stats:"
|
9
9
|
else
|
10
10
|
Coveralls::Output.puts "[Coveralls] There are no covered files.", :color => "yellow"
|
11
11
|
end
|
12
12
|
result.files.each do |f|
|
13
|
-
print " * "
|
13
|
+
Coveralls::Output.print " * "
|
14
14
|
Coveralls::Output.print short_filename(f.filename).to_s, :color => "cyan"
|
15
15
|
Coveralls::Output.print " => ", :color => "white"
|
16
16
|
cov = "#{f.covered_percent.round}%"
|
@@ -21,7 +21,7 @@ module Coveralls
|
|
21
21
|
else
|
22
22
|
Coveralls::Output.print cov, :color => "red"
|
23
23
|
end
|
24
|
-
puts ""
|
24
|
+
Coveralls::Output.puts ""
|
25
25
|
end
|
26
26
|
true
|
27
27
|
end
|
@@ -70,7 +70,7 @@ module Coveralls
|
|
70
70
|
|
71
71
|
# Post to Coveralls.
|
72
72
|
API.post_json "jobs", {:source_files => source_files, :test_framework => result.command_name.downcase, :run_at => result.created_at}
|
73
|
-
puts output_message result
|
73
|
+
Coveralls::Output.puts output_message result
|
74
74
|
|
75
75
|
true
|
76
76
|
|
data/lib/coveralls/version.rb
CHANGED
@@ -7,6 +7,32 @@ describe Coveralls do
|
|
7
7
|
Coveralls.testing = true
|
8
8
|
end
|
9
9
|
|
10
|
+
describe "#will_run?" do
|
11
|
+
it "checks CI environemnt variables" do
|
12
|
+
Coveralls.will_run?.should be_true
|
13
|
+
end
|
14
|
+
|
15
|
+
context "with CI disabled" do
|
16
|
+
before do
|
17
|
+
@ci = ENV['CI']
|
18
|
+
ENV['CI'] = nil
|
19
|
+
@coveralls_run_locally = ENV['COVERALLS_RUN_LOCALLY']
|
20
|
+
ENV['COVERALLS_RUN_LOCALLY'] = nil
|
21
|
+
|
22
|
+
Coveralls.testing = false
|
23
|
+
end
|
24
|
+
|
25
|
+
after do
|
26
|
+
ENV['CI'] = @ci
|
27
|
+
ENV['COVERALLS_RUN_LOCALLY'] = @coveralls_run_locally
|
28
|
+
end
|
29
|
+
|
30
|
+
it "indicates no run" do
|
31
|
+
Coveralls.will_run?.should be_false
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
10
36
|
describe "#should_run?" do
|
11
37
|
it "outputs to stdout when running locally" do
|
12
38
|
Coveralls.testing = false
|
@@ -1,6 +1,60 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Coveralls::Output do
|
4
|
+
it "defaults the IO to $stdout" do
|
5
|
+
old_stdout = $stdout
|
6
|
+
out = StringIO.new
|
7
|
+
$stdout = out
|
8
|
+
Coveralls::Output.puts "this is a test"
|
9
|
+
expect(out.string).to eq "this is a test\n"
|
10
|
+
$stdout = old_stdout
|
11
|
+
end
|
12
|
+
|
13
|
+
it "accepts an IO injection" do
|
14
|
+
out = StringIO.new
|
15
|
+
Coveralls::Output.output = out
|
16
|
+
Coveralls::Output.puts "this is a test"
|
17
|
+
expect(out.string).to eq "this is a test\n"
|
18
|
+
end
|
19
|
+
|
20
|
+
describe ".puts" do
|
21
|
+
it "accepts an IO injection" do
|
22
|
+
out = StringIO.new
|
23
|
+
Coveralls::Output.puts "this is a test", :output => out
|
24
|
+
expect(out.string).to eq "this is a test\n"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe ".print" do
|
29
|
+
it "accepts an IO injection" do
|
30
|
+
out = StringIO.new
|
31
|
+
Coveralls::Output.print "this is a test", :output => out
|
32
|
+
expect(out.string).to eq "this is a test"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe 'when silenced' do
|
37
|
+
before do
|
38
|
+
@original_stdout = $stdout
|
39
|
+
@output = StringIO.new
|
40
|
+
Coveralls::Output.silent = true
|
41
|
+
$stdout = @output
|
42
|
+
end
|
43
|
+
it "should not puts" do
|
44
|
+
Coveralls::Output.puts "foo"
|
45
|
+
@output.rewind
|
46
|
+
@output.read.should == ""
|
47
|
+
end
|
48
|
+
it "should not print" do
|
49
|
+
Coveralls::Output.print "foo"
|
50
|
+
@output.rewind
|
51
|
+
@output.read.should == ""
|
52
|
+
end
|
53
|
+
after do
|
54
|
+
$stdout = @original_stdout
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
4
58
|
describe '.format' do
|
5
59
|
it "accepts a color argument" do
|
6
60
|
string = 'Hello'
|
@@ -19,8 +73,6 @@ describe Coveralls::Output do
|
|
19
73
|
end
|
20
74
|
|
21
75
|
it "accepts more than 1 color argument" do
|
22
|
-
pending "Not implemented"
|
23
|
-
|
24
76
|
string = 'Hi dog!'
|
25
77
|
multi_formatted_string = Term::ANSIColor.red{ Term::ANSIColor.underline(string) }
|
26
78
|
Coveralls::Output.format(string, :color => 'red underline').should eq(multi_formatted_string)
|
@@ -6,10 +6,11 @@ describe Coveralls::SimpleCov::Formatter do
|
|
6
6
|
stub_api_post
|
7
7
|
end
|
8
8
|
|
9
|
+
def source_fixture(filename)
|
10
|
+
File.expand_path( File.join( File.dirname( __FILE__ ), 'fixtures', filename ) )
|
11
|
+
end
|
12
|
+
|
9
13
|
let(:result) {
|
10
|
-
def source_fixture(filename)
|
11
|
-
File.expand_path( File.join( File.dirname( __FILE__ ), 'fixtures', filename ) )
|
12
|
-
end
|
13
14
|
|
14
15
|
SimpleCov::Result.new({
|
15
16
|
source_fixture( 'sample.rb' ) => [nil, 1, 1, 1, nil, 0, 1, 1, nil, nil],
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coveralls
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Merwin
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-09-
|
12
|
+
date: 2013-09-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|