rorvswild 1.0.0.pre.alpha5 → 1.0.0.pre.alpha6
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/lib/rorvswild/client.rb +14 -11
- data/lib/rorvswild/version.rb +1 -1
- data/rorvswild.gemspec +2 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 492dae0df8044448c77cf1d9822d0a38c620eb5d
|
4
|
+
data.tar.gz: 046530a1906c3987c082b077da9358dd8bb8c692
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ab27a731ee5e63c9e08c11e89d6fe02376f943f7a5263652865ddebd5071e5faea20e66a52e11a3a619b5fa9505899cdc0aae599d61eb757f16facc03c9ccff
|
7
|
+
data.tar.gz: cdd6af7ec6ec368499e8f5ff8cb7da967474f2e56b3827baf4d54a24857f364ad333e20109bf63acea81a6410633f9524123ec7dd69b823a5e9fea0216f788ba
|
data/lib/rorvswild/client.rb
CHANGED
@@ -1,37 +1,40 @@
|
|
1
1
|
require "set"
|
2
2
|
require "uri"
|
3
|
-
require "net/http"
|
4
3
|
require "json/ext"
|
4
|
+
require "net/http"
|
5
|
+
require "net/http/persistent"
|
5
6
|
|
6
7
|
module RorVsWild
|
7
8
|
class Client
|
8
9
|
HTTPS = "https".freeze
|
9
10
|
CERTIFICATE_AUTHORITIES_PATH = File.expand_path("../../../cacert.pem", __FILE__)
|
11
|
+
DEFAULT_TIMEOUT = 1
|
10
12
|
|
11
|
-
attr_reader :api_url, :api_key, :threads
|
13
|
+
attr_reader :api_url, :api_key, :timeout, :threads
|
12
14
|
|
13
15
|
def initialize(config)
|
14
16
|
Kernel.at_exit(&method(:at_exit))
|
15
17
|
@api_url = config[:api_url]
|
16
18
|
@api_key = config[:api_key]
|
19
|
+
@timeout ||= config[:timeout] || DEFAULT_TIMEOUT
|
17
20
|
@threads = Set.new
|
18
21
|
end
|
19
22
|
|
20
23
|
def post(path, data)
|
21
24
|
uri = URI(api_url + path)
|
22
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
23
|
-
|
24
|
-
if uri.scheme == HTTPS
|
25
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
26
|
-
http.ca_file = CERTIFICATE_AUTHORITIES_PATH
|
27
|
-
http.use_ssl = true
|
28
|
-
end
|
29
|
-
|
30
25
|
post = Net::HTTP::Post.new(uri.path, "X-Gem-Version".freeze => RorVsWild::VERSION)
|
31
26
|
post.content_type = "application/json".freeze
|
32
27
|
post.basic_auth(nil, api_key)
|
33
28
|
post.body = data.to_json
|
34
|
-
http.request(post)
|
29
|
+
http.request(uri, post)
|
30
|
+
end
|
31
|
+
|
32
|
+
def http
|
33
|
+
return @http if @http
|
34
|
+
http = Net::HTTP::Persistent.new
|
35
|
+
http.retry_change_requests = true
|
36
|
+
http.open_timeout = timeout
|
37
|
+
@http = http
|
35
38
|
end
|
36
39
|
|
37
40
|
def post_async(path, data)
|
data/lib/rorvswild/version.rb
CHANGED
data/rorvswild.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rorvswild
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.pre.
|
4
|
+
version: 1.0.0.pre.alpha6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexis Bernard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: net-http-persistent
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.9.4
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.9.4
|
27
41
|
description: Performances & quality insights for rails developers.
|
28
42
|
email:
|
29
43
|
- alexis@bernard.io
|