netologiest 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/netologiest/http_client.rb +24 -22
- data/lib/netologiest/version.rb +1 -1
- 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: 9880e1f8101a1fe1e1d53408bb5679871a561c69
|
4
|
+
data.tar.gz: e6c8d1f4b74d93e113f885b10fb5ad8d7e3919a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2697d8c8c2e0e5ee4719f019c02b305c515e194dd702b8c459116dfdfb4e49d683c8543997a5c29a3503f8c30f727d9b01f5f3693a9c6b6edd6a16b363fa2968
|
7
|
+
data.tar.gz: ef01966b368ecea3c9012a81a07510e7148442d5c5dbc0da960ac819b869f63ea48745b2aa119d9bb8e571af443b2c552620c2b3933636fe3b5ed0f44cd8147c
|
@@ -1,32 +1,34 @@
|
|
1
|
-
|
2
|
-
class
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
1
|
+
module Netologiest
|
2
|
+
class HttpClient
|
3
|
+
class << self
|
4
|
+
def get(url, params: {})
|
5
|
+
uri = URI(url)
|
6
|
+
uri.query = URI.encode_www_form(params)
|
7
|
+
response = Response.new(Net::HTTP.get_response(uri))
|
8
|
+
if block_given?
|
9
|
+
yield response
|
10
|
+
else
|
11
|
+
response
|
12
|
+
end
|
11
13
|
end
|
12
14
|
end
|
13
|
-
end
|
14
15
|
|
15
|
-
|
16
|
-
|
16
|
+
class Response
|
17
|
+
attr_reader :body, :code
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
def success?
|
20
|
+
response.is_a?(Net::HTTPSuccess)
|
21
|
+
end
|
21
22
|
|
22
|
-
|
23
|
+
private
|
23
24
|
|
24
|
-
|
25
|
+
attr_reader :response
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
def initialize(response)
|
28
|
+
@response = response
|
29
|
+
@body = response.body
|
30
|
+
@code = response.code.to_i
|
31
|
+
end
|
30
32
|
end
|
31
33
|
end
|
32
34
|
end
|
data/lib/netologiest/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: netologiest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vlad Dem
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|