seibii-http 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +3 -3
- data/Gemfile.lock +36 -36
- data/README.md +4 -2
- data/lib/seibii/http/clients/base.rb +4 -4
- data/lib/seibii/http/clients/json.rb +3 -2
- data/lib/seibii/http/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: acdd3800bfb951e0f2a6bc79fa037ffb42783b9f1191e9b65b363b93ebee9f5e
|
4
|
+
data.tar.gz: dab68a8d6e7abeea1333929a94f49165125c4ad3474463207d03e10bdd1aef90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b884d2bc9b57ef09f8f068d1c98cb383200a9560249671b7db5e9413c69f583892c2433b254df0ce0d0703f97c9f79a15a01adb3f5f90e8abdaff23a507860a
|
7
|
+
data.tar.gz: 8f0ee4798f38c84a4a2f42b6319364a52af6572c93b8b25f0c0bf03257ad8b74b28692a176970eb5beea3fd00a9d55626131cbc6d7288eb3528e354ffc73359c
|
data/.circleci/config.yml
CHANGED
@@ -17,7 +17,7 @@ restore_bundle_cache: &restore_bundle_cache
|
|
17
17
|
jobs:
|
18
18
|
build:
|
19
19
|
docker:
|
20
|
-
- image: circleci/ruby
|
20
|
+
- image: circleci/ruby:2.7.2
|
21
21
|
steps:
|
22
22
|
- checkout
|
23
23
|
- *restore_bundle_cache
|
@@ -29,7 +29,7 @@ jobs:
|
|
29
29
|
- vendor/bundle
|
30
30
|
rubocop:
|
31
31
|
docker:
|
32
|
-
- image: circleci/ruby
|
32
|
+
- image: circleci/ruby:2.7.2
|
33
33
|
steps:
|
34
34
|
- checkout
|
35
35
|
- *restore_bundle_cache
|
@@ -38,7 +38,7 @@ jobs:
|
|
38
38
|
- run: bundle exec rubocop
|
39
39
|
rspec:
|
40
40
|
docker:
|
41
|
-
- image: circleci/ruby
|
41
|
+
- image: circleci/ruby:2.7.2
|
42
42
|
steps:
|
43
43
|
- checkout
|
44
44
|
- *restore_bundle_cache
|
data/Gemfile.lock
CHANGED
@@ -1,19 +1,18 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
seibii-http (1.0.
|
4
|
+
seibii-http (1.0.2)
|
5
5
|
oj
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
10
|
ast (2.4.1)
|
11
|
-
codecov (0.2.
|
12
|
-
|
13
|
-
simplecov
|
11
|
+
codecov (0.2.15)
|
12
|
+
simplecov (>= 0.15, < 0.21)
|
14
13
|
coderay (1.1.3)
|
15
14
|
diff-lcs (1.4.4)
|
16
|
-
docile (1.3.
|
15
|
+
docile (1.3.4)
|
17
16
|
ffi (1.13.1)
|
18
17
|
formatador (0.2.5)
|
19
18
|
guard (2.16.2)
|
@@ -30,65 +29,66 @@ GEM
|
|
30
29
|
guard (~> 2.1)
|
31
30
|
guard-compat (~> 1.1)
|
32
31
|
rspec (>= 2.99.0, < 4.0)
|
33
|
-
guard-rubocop (1.
|
32
|
+
guard-rubocop (1.4.0)
|
34
33
|
guard (~> 2.0)
|
35
|
-
rubocop (
|
36
|
-
json (2.3.1)
|
34
|
+
rubocop (< 2.0)
|
37
35
|
listen (3.2.1)
|
38
36
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
39
37
|
rb-inotify (~> 0.9, >= 0.9.10)
|
40
|
-
lumberjack (1.2.
|
38
|
+
lumberjack (1.2.8)
|
41
39
|
method_source (1.0.0)
|
42
40
|
nenv (0.3.0)
|
43
41
|
notiffany (0.1.3)
|
44
42
|
nenv (~> 0.1)
|
45
43
|
shellany (~> 0.0)
|
46
|
-
oj (3.
|
47
|
-
parallel (1.
|
48
|
-
parser (
|
44
|
+
oj (3.11.0)
|
45
|
+
parallel (1.20.1)
|
46
|
+
parser (3.0.0.0)
|
49
47
|
ast (~> 2.4.1)
|
50
48
|
pry (0.13.1)
|
51
49
|
coderay (~> 1.1)
|
52
50
|
method_source (~> 1.0)
|
53
51
|
rainbow (3.0.0)
|
54
|
-
rake (
|
52
|
+
rake (13.0.3)
|
55
53
|
rb-fsevent (0.10.4)
|
56
54
|
rb-inotify (0.10.1)
|
57
55
|
ffi (~> 1.0)
|
58
|
-
regexp_parser (
|
56
|
+
regexp_parser (2.0.3)
|
59
57
|
rexml (3.2.4)
|
60
|
-
rspec (3.
|
61
|
-
rspec-core (~> 3.
|
62
|
-
rspec-expectations (~> 3.
|
63
|
-
rspec-mocks (~> 3.
|
64
|
-
rspec-core (3.
|
65
|
-
rspec-support (~> 3.
|
66
|
-
rspec-expectations (3.
|
58
|
+
rspec (3.10.0)
|
59
|
+
rspec-core (~> 3.10.0)
|
60
|
+
rspec-expectations (~> 3.10.0)
|
61
|
+
rspec-mocks (~> 3.10.0)
|
62
|
+
rspec-core (3.10.0)
|
63
|
+
rspec-support (~> 3.10.0)
|
64
|
+
rspec-expectations (3.10.0)
|
67
65
|
diff-lcs (>= 1.2.0, < 2.0)
|
68
|
-
rspec-support (~> 3.
|
69
|
-
rspec-mocks (3.
|
66
|
+
rspec-support (~> 3.10.0)
|
67
|
+
rspec-mocks (3.10.0)
|
70
68
|
diff-lcs (>= 1.2.0, < 2.0)
|
71
|
-
rspec-support (~> 3.
|
72
|
-
rspec-support (3.
|
73
|
-
rubocop (
|
69
|
+
rspec-support (~> 3.10.0)
|
70
|
+
rspec-support (3.10.0)
|
71
|
+
rubocop (1.8.1)
|
74
72
|
parallel (~> 1.10)
|
75
|
-
parser (>=
|
73
|
+
parser (>= 3.0.0.0)
|
76
74
|
rainbow (>= 2.2.2, < 4.0)
|
77
|
-
regexp_parser (>= 1.
|
75
|
+
regexp_parser (>= 1.8, < 3.0)
|
78
76
|
rexml
|
79
|
-
rubocop-ast (>=
|
77
|
+
rubocop-ast (>= 1.2.0, < 2.0)
|
80
78
|
ruby-progressbar (~> 1.7)
|
81
|
-
unicode-display_width (>= 1.4.0, <
|
82
|
-
rubocop-ast (
|
83
|
-
parser (>= 2.7.1.
|
84
|
-
ruby-progressbar (1.
|
79
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
80
|
+
rubocop-ast (1.4.0)
|
81
|
+
parser (>= 2.7.1.5)
|
82
|
+
ruby-progressbar (1.11.0)
|
85
83
|
shellany (0.0.1)
|
86
|
-
simplecov (0.
|
84
|
+
simplecov (0.20.0)
|
87
85
|
docile (~> 1.1)
|
88
86
|
simplecov-html (~> 0.11)
|
89
|
-
|
87
|
+
simplecov_json_formatter (~> 0.1)
|
88
|
+
simplecov-html (0.12.3)
|
89
|
+
simplecov_json_formatter (0.1.2)
|
90
90
|
thor (1.0.1)
|
91
|
-
unicode-display_width (
|
91
|
+
unicode-display_width (2.0.0)
|
92
92
|
|
93
93
|
PLATFORMS
|
94
94
|
ruby
|
data/README.md
CHANGED
@@ -20,7 +20,8 @@ def get
|
|
20
20
|
method: :get, # required
|
21
21
|
uri: URI.parse('https://example.com/example'), # required
|
22
22
|
request_body: nil, # optional
|
23
|
-
headers: { Accept: '*/*' } # optional
|
23
|
+
headers: { Accept: '*/*' }, # optional
|
24
|
+
need_verify_cert: false # optional
|
24
25
|
) #=> response body String
|
25
26
|
rescue Seibii::Http::ClientError => e # 404 will not raise exception but just return nil response
|
26
27
|
p e
|
@@ -45,7 +46,8 @@ def post
|
|
45
46
|
method: :post, # required
|
46
47
|
uri: URI.parse('https://example.com/example'), # required
|
47
48
|
params: { a: 'b', c: 'd' }, # optional
|
48
|
-
headers: { Authorization: 'Bearer token' } # optional
|
49
|
+
headers: { Authorization: 'Bearer token' }, # optional
|
50
|
+
need_verify_cert: false # optional
|
49
51
|
) #=> response json hash
|
50
52
|
rescue Seibii::Http::ClientError => e # 404 will not raise exception but just return nil response
|
51
53
|
p e
|
@@ -8,18 +8,18 @@ module Seibii
|
|
8
8
|
@logger = logger
|
9
9
|
end
|
10
10
|
|
11
|
-
def request(method:, uri:, request_body: nil, headers: {})
|
11
|
+
def request(method:, uri:, request_body: nil, headers: {}, need_verify_cert: false)
|
12
12
|
parsed_uri = URI.parse(uri)
|
13
|
-
with_logging(uri) { http(parsed_uri).request(request_object(method, parsed_uri, request_body, headers)) }
|
13
|
+
with_logging(uri) { http(parsed_uri, need_verify_cert).request(request_object(method, parsed_uri, request_body, headers)) } # rubocop:disable Layout/LineLength
|
14
14
|
.yield_self { |response| handle_http_status(response) }
|
15
15
|
end
|
16
16
|
|
17
17
|
private
|
18
18
|
|
19
|
-
def http(uri)
|
19
|
+
def http(uri, need_verify_cert)
|
20
20
|
@http ||= Net::HTTP.new(uri.host, uri.port).tap do |instance|
|
21
21
|
instance.use_ssl = uri.scheme == 'https'
|
22
|
-
instance.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
22
|
+
instance.verify_mode = need_verify_cert ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -8,12 +8,13 @@ module Seibii
|
|
8
8
|
@base = Base.new(logger: logger)
|
9
9
|
end
|
10
10
|
|
11
|
-
def request(method:, uri:, params: nil, headers: {})
|
11
|
+
def request(method:, uri:, params: nil, headers: {}, need_verify_cert: false)
|
12
12
|
response_body = @base.request(
|
13
13
|
method: method,
|
14
14
|
uri: uri,
|
15
15
|
request_body: params&.yield_self { |p| Oj.dump(p, mode: :compat) },
|
16
|
-
headers: headers.merge('Accept': 'application/json', 'Content-Type': 'application/json')
|
16
|
+
headers: headers.merge('Accept': 'application/json', 'Content-Type': 'application/json'),
|
17
|
+
need_verify_cert: need_verify_cert
|
17
18
|
)
|
18
19
|
Oj.load(response_body, mode: :compat, symbol_keys: true)
|
19
20
|
end
|
data/lib/seibii/http/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: seibii-http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuji Ueki
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|