coveralls 0.7.0 → 0.7.1

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
  SHA1:
3
- metadata.gz: 37fb125236b8084bb66698ff83b734e7c50019c7
4
- data.tar.gz: 5c14c65f7b7a093ab62b7b3219c8a18d9102b84a
3
+ metadata.gz: 2b4b79d112b23fa2383f40994e33d8c197566ded
4
+ data.tar.gz: e10986ebd08afe821cf47dcaecd79e72b9b735af
5
5
  SHA512:
6
- metadata.gz: d1e17590b229ed02769fc5004ad45ad2469f647913af1259049b7ff59c9f2d6130b450a28472e707306fb143171a7c6f007e047584fcc48cd52a1103325cc755
7
- data.tar.gz: 9e3f728924b192cddbb5b608f7f5f596a250a716f27c1acf39fc8b227b7ac4c7164062caf11435271afe6114138167b402fbe0df90f9c5f25bfcb95400eb7091
6
+ metadata.gz: 8b3108e79e523aa7893b0854737adf155ed77ff1e91387583227027e851307f45d2f6a8922231c5178f7425946772660fabb1cab0409813bdcda09b47f0b5637
7
+ data.tar.gz: cb485eec58a0e30d51c411738a5762a267c86668c0d357d107dc1500608515d2bc1c47c4e0dc61bac8c97e6e6675e44943f1387af69adbe9c67228c5c7f2d365
@@ -1,10 +1,11 @@
1
1
  language: ruby
2
2
  rvm:
3
- - rbx-19mode
3
+ - rbx
4
4
  - jruby-19mode
5
5
  - 1.9.2
6
6
  - 1.9.3
7
7
  - 2.0.0
8
+ - 2.1.0
8
9
  - ruby-head
9
10
  matrix:
10
11
  allow_failures:
data/Gemfile CHANGED
@@ -3,4 +3,10 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in coveralls-ruby.gemspec
4
4
  gemspec
5
5
 
6
- gem 'simplecov', :require => false
6
+ gem 'simplecov', :require => false
7
+
8
+ platform :rbx do
9
+ gem 'rubysl', '~> 2.0'
10
+ gem 'json'
11
+ gem 'rubinius-developer_tools'
12
+ end
@@ -4,9 +4,15 @@ module Coveralls
4
4
  require 'multi_json'
5
5
  require 'rest_client'
6
6
 
7
- API_HOST = ENV['COVERALLS_DEVELOPMENT'] ? "localhost:3000" : "coveralls.io"
8
- API_PROTOCOL = ENV['COVERALLS_DEVELOPMENT'] ? "http" : "https"
9
- API_DOMAIN = "#{API_PROTOCOL}://#{API_HOST}"
7
+ if ENV['COVERALLS_ENDPOINT']
8
+ API_HOST = ENV['COVERALLS_ENDPOINT']
9
+ API_DOMAIN = ENV['COVERALLS_ENDPOINT']
10
+ else
11
+ API_HOST = ENV['COVERALLS_DEVELOPMENT'] ? "localhost:3000" : "coveralls.io"
12
+ API_PROTOCOL = ENV['COVERALLS_DEVELOPMENT'] ? "http" : "https"
13
+ API_DOMAIN = "#{API_PROTOCOL}://#{API_HOST}"
14
+ end
15
+
10
16
  API_BASE = "#{API_DOMAIN}/api/v1"
11
17
 
12
18
  def self.post_json(endpoint, hash)
@@ -17,34 +17,57 @@ module Coveralls
17
17
  config[:repo_token] = ENV['COVERALLS_REPO_TOKEN']
18
18
  end
19
19
  if ENV['TRAVIS']
20
- config[:service_job_id] = ENV['TRAVIS_JOB_ID']
21
- config[:service_name] = (yml ? yml['service_name'] : nil) || 'travis-ci'
20
+ set_service_params_for_travis(config, yml ? yml['service_name'] : nil)
22
21
  elsif ENV['CIRCLECI']
23
- config[:service_name] = 'circleci'
24
- config[:service_number] = ENV['CIRCLE_BUILD_NUM']
22
+ set_service_params_for_circleci(config)
25
23
  elsif ENV['SEMAPHORE']
26
- config[:service_name] = 'semaphore'
27
- config[:service_number] = ENV['SEMAPHORE_BUILD_NUMBER']
24
+ set_service_params_for_semaphore(config)
28
25
  elsif ENV['JENKINS_URL']
29
- config[:service_name] = 'jenkins'
30
- config[:service_number] = ENV['BUILD_NUMBER']
31
- elsif ENV["COVERALLS_RUN_LOCALLY"] || Coveralls.testing
32
- config[:service_job_id] = nil
33
- config[:service_name] = 'coveralls-ruby'
34
- config[:service_event_type] = 'manual'
35
-
26
+ set_service_params_for_jenkins(config)
27
+ elsif ENV['COVERALLS_RUN_LOCALLY'] || Coveralls.testing
28
+ set_service_params_for_coveralls_local(config)
36
29
  # standardized env vars
37
30
  elsif ENV['CI_NAME']
38
- config[:service_name] = ENV['CI_NAME']
39
- config[:service_number] = ENV['CI_BUILD_NUMBER']
40
- config[:service_build_url] = ENV['CI_BUILD_URL']
41
- config[:service_branch] = ENV['CI_BRANCH']
42
- config[:service_pull_request] = ENV['CI_PULL_REQUEST']
31
+ set_service_params_for_generic_ci(config)
43
32
  end
44
33
 
45
34
  config
46
35
  end
47
36
 
37
+ def self.set_service_params_for_travis(config, service_name)
38
+ config[:service_job_id] = ENV['TRAVIS_JOB_ID']
39
+ config[:service_name] = service_name || 'travis-ci'
40
+ end
41
+
42
+ def self.set_service_params_for_circleci(config)
43
+ config[:service_name] = 'circleci'
44
+ config[:service_number] = ENV['CIRCLE_BUILD_NUM']
45
+ end
46
+
47
+ def self.set_service_params_for_semaphore(config)
48
+ config[:service_name] = 'semaphore'
49
+ config[:service_number] = ENV['SEMAPHORE_BUILD_NUMBER']
50
+ end
51
+
52
+ def self.set_service_params_for_jenkins(config)
53
+ config[:service_name] = 'jenkins'
54
+ config[:service_number] = ENV['BUILD_NUMBER']
55
+ end
56
+
57
+ def self.set_service_params_for_coveralls_local(config)
58
+ config[:service_job_id] = nil
59
+ config[:service_name] = 'coveralls-ruby'
60
+ config[:service_event_type] = 'manual'
61
+ end
62
+
63
+ def self.set_service_params_for_generic_ci(config)
64
+ config[:service_name] = ENV['CI_NAME']
65
+ config[:service_number] = ENV['CI_BUILD_NUMBER']
66
+ config[:service_build_url] = ENV['CI_BUILD_URL']
67
+ config[:service_branch] = ENV['CI_BRANCH']
68
+ config[:service_pull_request] = ENV['CI_PULL_REQUEST']
69
+ end
70
+
48
71
  def self.yaml_config
49
72
  if self.configuration_path && File.exists?(self.configuration_path)
50
73
  YAML::load_file(self.configuration_path)
@@ -26,10 +26,13 @@ module Coveralls
26
26
  # or set this environment variable:
27
27
  #
28
28
  # COVERALLS_SILENT
29
+ #
30
+ # To disable color completely:
31
+ #
32
+ # Coveralls::Output.no_color = true
29
33
 
30
34
  module Output
31
- require 'term/ansicolor'
32
- attr_accessor :silent
35
+ attr_accessor :silent, :no_color
33
36
  attr_writer :output
34
37
  extend self
35
38
 
@@ -37,6 +40,10 @@ module Coveralls
37
40
  (defined?(@output) && @output) || $stdout
38
41
  end
39
42
 
43
+ def no_color?
44
+ (defined?(@no_color)) && @no_color
45
+ end
46
+
40
47
  # Public: Formats the given string with the specified color
41
48
  # through Term::ANSIColor
42
49
  #
@@ -52,10 +59,13 @@ module Coveralls
52
59
  #
53
60
  # Returns the formatted string.
54
61
  def format(string, options = {})
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)
62
+ unless no_color?
63
+ require 'term/ansicolor'
64
+ if options[:color]
65
+ options[:color].split(/\s/).reverse_each do |color|
66
+ if Term::ANSIColor.respond_to?(color.to_sym)
67
+ string = Term::ANSIColor.send(color.to_sym, string)
68
+ end
59
69
  end
60
70
  end
61
71
  end
@@ -1,3 +1,3 @@
1
1
  module Coveralls
2
- VERSION = "0.7.0"
2
+ VERSION = "0.7.1"
3
3
  end
@@ -1,10 +1,259 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Coveralls::Configuration do
4
+ before do
5
+ ENV.stub(:[]).and_return(nil)
6
+ end
7
+
8
+ describe '.configuration' do
9
+ it "returns a hash with the default keys" do
10
+ config = Coveralls::Configuration.configuration
11
+ config.should be_a(Hash)
12
+ config.keys.should include(:environment)
13
+ config.keys.should include(:git)
14
+ end
15
+
16
+ context 'yaml_config' do
17
+ let(:repo_token) { SecureRandom.hex(4) }
18
+ let(:repo_secret_token) { SecureRandom.hex(4) }
19
+ let(:yaml_config) {
20
+ {
21
+ 'repo_token' => repo_token,
22
+ 'repo_secret_token' => repo_secret_token
23
+ }
24
+ }
25
+
26
+ before do
27
+ Coveralls::Configuration.stub(:yaml_config).and_return(yaml_config)
28
+ end
29
+
30
+ it 'sets the Yaml config and associated variables if present' do
31
+ config = Coveralls::Configuration.configuration
32
+ config[:configuration].should eq(yaml_config)
33
+ config[:repo_token].should eq(repo_token)
34
+ end
35
+
36
+ it 'uses the repo_secret_token if the repo_token is not set' do
37
+ yaml_config.delete('repo_token')
38
+ config = Coveralls::Configuration.configuration
39
+ config[:configuration].should eq(yaml_config)
40
+ config[:repo_token].should eq(repo_secret_token)
41
+ end
42
+ end
43
+
44
+ context 'repo_token in environment' do
45
+ let(:repo_token) { SecureRandom.hex(4) }
46
+
47
+ before do
48
+ ENV.stub(:[]).with('COVERALLS_REPO_TOKEN').and_return(repo_token)
49
+ end
50
+
51
+ it 'pulls the repo token from the environment if set' do
52
+ config = Coveralls::Configuration.configuration
53
+ config[:repo_token].should eq(repo_token)
54
+ end
55
+ end
56
+
57
+ context 'Services' do
58
+ context 'on Travis' do
59
+ before do
60
+ ENV.stub(:[]).with('TRAVIS').and_return('1')
61
+ end
62
+
63
+ it 'should set service parameters for this service and no other' do
64
+ Coveralls::Configuration.should_receive(:set_service_params_for_travis).with(anything, anything)
65
+ Coveralls::Configuration.should_not_receive(:set_service_params_for_circleci)
66
+ Coveralls::Configuration.should_not_receive(:set_service_params_for_semaphore)
67
+ Coveralls::Configuration.should_not_receive(:set_service_params_for_jenkins)
68
+ Coveralls::Configuration.should_not_receive(:set_service_params_for_coveralls_local)
69
+ Coveralls::Configuration.should_not_receive(:set_service_params_for_generic_ci)
70
+ Coveralls::Configuration.configuration
71
+ end
72
+ end
73
+
74
+ context 'on CircleCI' do
75
+ before do
76
+ ENV.stub(:[]).with('CIRCLECI').and_return('1')
77
+ end
78
+
79
+ it 'should set service parameters for this service and no other' do
80
+ Coveralls::Configuration.should_not_receive(:set_service_params_for_travis)
81
+ Coveralls::Configuration.should_receive(:set_service_params_for_circleci)
82
+ Coveralls::Configuration.should_not_receive(:set_service_params_for_semaphore)
83
+ Coveralls::Configuration.should_not_receive(:set_service_params_for_jenkins)
84
+ Coveralls::Configuration.should_not_receive(:set_service_params_for_coveralls_local)
85
+ Coveralls::Configuration.should_not_receive(:set_service_params_for_generic_ci)
86
+ Coveralls::Configuration.configuration
87
+ end
88
+ end
89
+
90
+ context 'on Semaphore' do
91
+ before do
92
+ ENV.stub(:[]).with('SEMAPHORE').and_return('1')
93
+ end
94
+
95
+ it 'should set service parameters for this service and no other' do
96
+ Coveralls::Configuration.should_not_receive(:set_service_params_for_travis)
97
+ Coveralls::Configuration.should_not_receive(:set_service_params_for_circleci)
98
+ Coveralls::Configuration.should_receive(:set_service_params_for_semaphore)
99
+ Coveralls::Configuration.should_not_receive(:set_service_params_for_jenkins)
100
+ Coveralls::Configuration.should_not_receive(:set_service_params_for_coveralls_local)
101
+ Coveralls::Configuration.should_not_receive(:set_service_params_for_generic_ci)
102
+ Coveralls::Configuration.configuration
103
+ end
104
+ end
105
+
106
+ context 'when using Jenkins' do
107
+ before do
108
+ ENV.stub(:[]).with('JENKINS_URL').and_return('1')
109
+ end
110
+
111
+ it 'should set service parameters for this service and no other' do
112
+ Coveralls::Configuration.should_not_receive(:set_service_params_for_travis)
113
+ Coveralls::Configuration.should_not_receive(:set_service_params_for_circleci)
114
+ Coveralls::Configuration.should_not_receive(:set_service_params_for_semaphore)
115
+ Coveralls::Configuration.should_receive(:set_service_params_for_jenkins)
116
+ Coveralls::Configuration.should_not_receive(:set_service_params_for_coveralls_local)
117
+ Coveralls::Configuration.should_not_receive(:set_service_params_for_generic_ci)
118
+ Coveralls::Configuration.configuration
119
+ end
120
+ end
121
+
122
+ context 'when running Coveralls locally' do
123
+ before do
124
+ ENV.stub(:[]).with('COVERALLS_RUN_LOCALLY').and_return('1')
125
+ end
126
+
127
+ it 'should set service parameters for this service and no other' do
128
+ Coveralls::Configuration.should_not_receive(:set_service_params_for_travis)
129
+ Coveralls::Configuration.should_not_receive(:set_service_params_for_circleci)
130
+ Coveralls::Configuration.should_not_receive(:set_service_params_for_semaphore)
131
+ Coveralls::Configuration.should_not_receive(:set_service_params_for_jenkins)
132
+ Coveralls::Configuration.should_receive(:set_service_params_for_coveralls_local)
133
+ Coveralls::Configuration.should_not_receive(:set_service_params_for_generic_ci)
134
+ Coveralls::Configuration.configuration
135
+ end
136
+ end
137
+
138
+ context 'for generic CI' do
139
+ before do
140
+ ENV.stub(:[]).with('CI_NAME').and_return('1')
141
+ end
4
142
 
5
- it "asserts true" do
6
- config = Coveralls::Configuration.configuration
7
- config.should_not be_nil
143
+ it 'should set service parameters for this service and no other' do
144
+ Coveralls::Configuration.should_not_receive(:set_service_params_for_travis)
145
+ Coveralls::Configuration.should_not_receive(:set_service_params_for_circleci)
146
+ Coveralls::Configuration.should_not_receive(:set_service_params_for_semaphore)
147
+ Coveralls::Configuration.should_not_receive(:set_service_params_for_jenkins)
148
+ Coveralls::Configuration.should_not_receive(:set_service_params_for_coveralls_local)
149
+ Coveralls::Configuration.should_receive(:set_service_params_for_generic_ci)
150
+ Coveralls::Configuration.configuration
151
+ end
152
+ end
153
+ end
8
154
  end
9
155
 
156
+ describe '.set_service_params_for_travis' do
157
+ let(:travis_job_id) { SecureRandom.hex(4) }
158
+ before do
159
+ ENV.stub(:[]).with('TRAVIS_JOB_ID').and_return(travis_job_id)
160
+ end
161
+
162
+ it 'should set the service_job_id' do
163
+ config = {}
164
+ Coveralls::Configuration.set_service_params_for_travis(config, nil)
165
+ config[:service_job_id].should eq(travis_job_id)
166
+ end
167
+
168
+ it 'should set the service_name to travis-ci by default' do
169
+ config = {}
170
+ Coveralls::Configuration.set_service_params_for_travis(config, nil)
171
+ config[:service_name].should eq('travis-ci')
172
+ end
173
+
174
+ it 'should set the service_name to a value if one is passed in' do
175
+ config = {}
176
+ service_name = SecureRandom.hex(4)
177
+ Coveralls::Configuration.set_service_params_for_travis(config, service_name)
178
+ config[:service_name].should eq(service_name)
179
+ end
180
+ end
181
+
182
+ describe '.set_service_params_for_circleci' do
183
+ let(:circle_build_num) { SecureRandom.hex(4) }
184
+ before do
185
+ ENV.stub(:[]).with('CIRCLE_BUILD_NUM').and_return(circle_build_num)
186
+ end
187
+
188
+ it 'should set the expected parameters' do
189
+ config = {}
190
+ Coveralls::Configuration.set_service_params_for_circleci(config)
191
+ config[:service_name].should eq('circleci')
192
+ config[:service_number].should eq(circle_build_num)
193
+ end
194
+ end
195
+
196
+ describe '.set_service_params_for_semaphore' do
197
+ let(:semaphore_build_num) { SecureRandom.hex(4) }
198
+ before do
199
+ ENV.stub(:[]).with('SEMAPHORE_BUILD_NUMBER').and_return(semaphore_build_num)
200
+ end
201
+
202
+ it 'should set the expected parameters' do
203
+ config = {}
204
+ Coveralls::Configuration.set_service_params_for_semaphore(config)
205
+ config[:service_name].should eq('semaphore')
206
+ config[:service_number].should eq(semaphore_build_num)
207
+ end
208
+ end
209
+
210
+ describe '.set_service_params_for_jenkins' do
211
+ let(:build_num) { SecureRandom.hex(4) }
212
+ before do
213
+ ENV.stub(:[]).with('BUILD_NUMBER').and_return(build_num)
214
+ end
215
+
216
+ it 'should set the expected parameters' do
217
+ config = {}
218
+ Coveralls::Configuration.set_service_params_for_jenkins(config)
219
+ config[:service_name].should eq('jenkins')
220
+ config[:service_number].should eq(build_num)
221
+ end
222
+ end
223
+
224
+ describe '.set_service_params_for_coveralls_local' do
225
+ it 'should set the expected parameters' do
226
+ config = {}
227
+ Coveralls::Configuration.set_service_params_for_coveralls_local(config)
228
+ config[:service_name].should eq('coveralls-ruby')
229
+ config[:service_job_id].should be_nil
230
+ config[:service_event_type].should eq('manual')
231
+ end
232
+ end
233
+
234
+ describe '.set_service_params_for_generic_ci' do
235
+ let(:service_name) { SecureRandom.hex(4) }
236
+ let(:service_number) { SecureRandom.hex(4) }
237
+ let(:service_build_url) { SecureRandom.hex(4) }
238
+ let(:service_branch) { SecureRandom.hex(4) }
239
+ let(:service_pull_request) { SecureRandom.hex(4) }
240
+
241
+ before do
242
+ ENV.stub(:[]).with('CI_NAME').and_return(service_name)
243
+ ENV.stub(:[]).with('CI_BUILD_NUMBER').and_return(service_number)
244
+ ENV.stub(:[]).with('CI_BUILD_URL').and_return(service_build_url)
245
+ ENV.stub(:[]).with('CI_BRANCH').and_return(service_branch)
246
+ ENV.stub(:[]).with('CI_PULL_REQUEST').and_return(service_pull_request)
247
+ end
248
+
249
+ it 'should set the expected parameters' do
250
+ config = {}
251
+ Coveralls::Configuration.set_service_params_for_generic_ci(config)
252
+ config[:service_name].should eq(service_name)
253
+ config[:service_number].should eq(service_number)
254
+ config[:service_build_url].should eq(service_build_url)
255
+ config[:service_branch].should eq(service_branch)
256
+ config[:service_pull_request].should eq(service_pull_request)
257
+ end
258
+ end
10
259
  end
@@ -57,6 +57,7 @@ describe Coveralls::Output do
57
57
 
58
58
  describe '.format' do
59
59
  it "accepts a color argument" do
60
+ require 'term/ansicolor'
60
61
  string = 'Hello'
61
62
  ansi_color_string = Term::ANSIColor.red(string)
62
63
  Coveralls::Output.format(string, :color => 'red').should eq(ansi_color_string)
@@ -77,5 +78,15 @@ describe Coveralls::Output do
77
78
  multi_formatted_string = Term::ANSIColor.red{ Term::ANSIColor.underline(string) }
78
79
  Coveralls::Output.format(string, :color => 'red underline').should eq(multi_formatted_string)
79
80
  end
81
+
82
+ context "no color" do
83
+ before { Coveralls::Output.no_color = true }
84
+
85
+ it "does not add color to string" do
86
+ unformatted_string = "Hi Doggie!"
87
+ Coveralls::Output.format(unformatted_string, :color => 'red').
88
+ should eq(unformatted_string)
89
+ end
90
+ end
80
91
  end
81
92
  end
@@ -73,4 +73,4 @@ module Kernel
73
73
  ensure
74
74
  stream.reopen(old_stream)
75
75
  end
76
- end
76
+ end
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.7.0
4
+ version: 0.7.1
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-18 00:00:00.000000000 Z
12
+ date: 2014-08-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
@@ -197,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
197
197
  version: '0'
198
198
  requirements: []
199
199
  rubyforge_project:
200
- rubygems_version: 2.0.0
200
+ rubygems_version: 2.1.5
201
201
  signing_key:
202
202
  specification_version: 4
203
203
  summary: A Ruby implementation of the Coveralls API.