coveralls 0.8.10 → 0.8.11

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a66719787cad85905b25461aac529d559d383bf3
4
- data.tar.gz: 046a9ba8007720a67baf91e96425c3fe9ec8d66b
3
+ metadata.gz: e61500aefc96d02600f5c1f9e46bafeaca0ab065
4
+ data.tar.gz: ade2d0bd97e80983b542d4d58f181f6095cbcb3d
5
5
  SHA512:
6
- metadata.gz: 12aeda5682589c208469044a3386b42d9599468db9859f38ef08fa72ba9606946eb0e15b54be776ecd128b9d6120ffea9228f3e58e64c9397cdc369b24dbd979
7
- data.tar.gz: c0152de5216ac5b75ee38776b211474d51109de210b3349751779f793cc8262be74428f0963a1f193d1e05c2eceab5526d22453438fe62b1a238b5d5b4b760c5
6
+ metadata.gz: b376f04bbc679fdaf14a4a833eb318a9f8932635e5afc29e410df27ea3405490284ca3f051ffab45e083c62f7f417fab51d034e99d15dfd9b525261d2a63734b
7
+ data.tar.gz: 5a6edc4eae4b92be861c557c939eafc8f8705b3155772af764380629bc83f1689dfe9dd7d7d72c89a6825e5657ca29f32f2127a56fab57d95dc07db15fd8c0aa
data/Gemfile CHANGED
@@ -12,7 +12,7 @@ gem 'webmock', '>= 1.20'
12
12
 
13
13
  platforms :ruby_18 do
14
14
  gem 'mime-types', '~> 1.25'
15
- gem 'rest-client', '~> 1.6.0'
15
+ gem 'addressable', '~> 2.3.8', :group => :test
16
16
  end
17
17
 
18
18
  platforms :jruby do
@@ -20,7 +20,6 @@ Gem::Specification.new do |gem|
20
20
  gem.required_ruby_version = '>= 1.8.7'
21
21
 
22
22
  gem.add_dependency 'json', '~> 1.8'
23
- gem.add_dependency 'rest-client', '>= 1.6.8', '< 2'
24
23
  gem.add_dependency 'simplecov', '~> 0.11.0'
25
24
  gem.add_dependency 'tins', '~> 1.6.0'
26
25
  gem.add_dependency 'term-ansicolor', '~> 1.3'
@@ -1,5 +1,5 @@
1
1
  require 'json'
2
- require 'rest_client'
2
+ require 'net/https'
3
3
 
4
4
  module Coveralls
5
5
  class API
@@ -16,20 +16,33 @@ module Coveralls
16
16
 
17
17
  def self.post_json(endpoint, hash)
18
18
  disable_net_blockers!
19
- url = endpoint_to_url(endpoint)
19
+
20
+ uri = endpoint_to_uri(endpoint)
21
+
20
22
  Coveralls::Output.puts("#{ JSON.pretty_generate(hash) }", :color => "green") if ENV['COVERALLS_DEBUG']
21
- hash = apified_hash hash
22
23
  Coveralls::Output.puts("[Coveralls] Submitting to #{API_BASE}", :color => "cyan")
23
- response = RestClient::Request.execute(:method => :post, :url => url, :payload => { :json_file => hash_to_file(hash) }, :ssl_version => 'TLSv1', :verify_ssl => false)
24
- response_hash = JSON.load(response.to_str)
25
- Coveralls::Output.puts("[Coveralls] #{ response_hash['message'] }", :color => "cyan")
24
+
25
+ client = build_client(uri)
26
+ request = build_request(uri.path, hash)
27
+
28
+ response = client.request(request)
29
+
30
+ response_hash = JSON.load(response.body.to_str)
31
+
26
32
  if response_hash['message']
33
+ Coveralls::Output.puts("[Coveralls] #{ response_hash['message'] }", :color => "cyan")
34
+ end
35
+
36
+ if response_hash['url']
27
37
  Coveralls::Output.puts("[Coveralls] #{ Coveralls::Output.format(response_hash['url'], :color => "underline") }", :color => "cyan")
28
38
  end
29
- rescue RestClient::ServiceUnavailable
30
- Coveralls::Output.puts("[Coveralls] API timeout occured, but data should still be processed", :color => "red")
31
- rescue RestClient::InternalServerError
32
- Coveralls::Output.puts("[Coveralls] API internal error occured, we're on it!", :color => "red")
39
+
40
+ case response
41
+ when Net::HTTPServiceUnavailable
42
+ Coveralls::Output.puts("[Coveralls] API timeout occured, but data should still be processed", :color => "red")
43
+ when Net::HTTPInternalServerError
44
+ Coveralls::Output.puts("[Coveralls] API internal error occured, we're on it!", :color => "red")
45
+ end
33
46
  end
34
47
 
35
48
  private
@@ -47,8 +60,43 @@ module Coveralls
47
60
  end
48
61
  end
49
62
 
50
- def self.endpoint_to_url(endpoint)
51
- "#{API_BASE}/#{endpoint}"
63
+ def self.endpoint_to_uri(endpoint)
64
+ URI.parse("#{API_BASE}/#{endpoint}")
65
+ end
66
+
67
+ def self.build_client(uri)
68
+ client = Net::HTTP.new(uri.host, uri.port)
69
+ client.use_ssl = true if uri.port == 443
70
+ client.verify_mode = OpenSSL::SSL::VERIFY_NONE
71
+
72
+ unless client.respond_to?(:ssl_version=)
73
+ Net::HTTP.ssl_context_accessor("ssl_version")
74
+ end
75
+
76
+ client.ssl_version = 'TLSv1'
77
+
78
+ client
79
+ end
80
+
81
+ def self.build_request(path, hash)
82
+ request = Net::HTTP::Post.new(path)
83
+ boundary = rand(1_000_000).to_s
84
+
85
+ request.body = build_request_body(hash, boundary)
86
+ request.content_type = "multipart/form-data, boundary=#{boundary}"
87
+
88
+ request
89
+ end
90
+
91
+ def self.build_request_body(hash, boundary)
92
+ hash = apified_hash(hash)
93
+ file = hash_to_file(hash)
94
+
95
+ "--#{boundary}\r\n" \
96
+ "Content-Disposition: form-data; name=\"json_file\"; filename=\"#{File.basename(file.path)}\"\r\n" \
97
+ "Content-Type: text/plain\r\n\r\n" +
98
+ File.read(file.path) +
99
+ "\r\n--#{boundary}--\r\n"
52
100
  end
53
101
 
54
102
  def self.hash_to_file(hash)
@@ -62,7 +110,7 @@ module Coveralls
62
110
 
63
111
  def self.apified_hash hash
64
112
  config = Coveralls::Configuration.configuration
65
- if ENV['CI'] || ENV['COVERALLS_DEBUG'] || Coveralls.testing
113
+ if ENV['COVERALLS_DEBUG'] || Coveralls.testing
66
114
  Coveralls::Output.puts "[Coveralls] Submitting with config:", :color => "yellow"
67
115
  output = JSON.pretty_generate(config).gsub(/"repo_token": ?"(.*?)"/,'"repo_token": "[secure]"')
68
116
  Coveralls::Output.puts output, :color => "yellow"
@@ -1,3 +1,3 @@
1
1
  module Coveralls
2
- VERSION = "0.8.10"
2
+ VERSION = "0.8.11"
3
3
  end
@@ -62,7 +62,8 @@ describe Coveralls::SimpleCov::Formatter do
62
62
 
63
63
  context "with api error" do
64
64
  it "rescues" do
65
- e = RestClient::ResourceNotFound.new double('HTTP Response', :code => '502')
65
+ e = SocketError.new
66
+
66
67
  silence do
67
68
  Coveralls::SimpleCov::Formatter.new.display_error(e).should be_falsy
68
69
  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.8.10
4
+ version: 0.8.11
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: 2015-11-30 00:00:00.000000000 Z
12
+ date: 2016-02-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -25,26 +25,6 @@ dependencies:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
27
  version: '1.8'
28
- - !ruby/object:Gem::Dependency
29
- name: rest-client
30
- requirement: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: 1.6.8
35
- - - "<"
36
- - !ruby/object:Gem::Version
37
- version: '2'
38
- type: :runtime
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- version: 1.6.8
45
- - - "<"
46
- - !ruby/object:Gem::Version
47
- version: '2'
48
28
  - !ruby/object:Gem::Dependency
49
29
  name: simplecov
50
30
  requirement: !ruby/object:Gem::Requirement
@@ -175,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
155
  version: '0'
176
156
  requirements: []
177
157
  rubyforge_project:
178
- rubygems_version: 2.2.2
158
+ rubygems_version: 2.4.5
179
159
  signing_key:
180
160
  specification_version: 4
181
161
  summary: A Ruby implementation of the Coveralls API.