super_parser 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/super_parser/client.rb +10 -12
- data/lib/super_parser/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 176c6ac3b2f40ff38ce140c0039214ea60be539551d4cd660157d0aa66e851aa
|
4
|
+
data.tar.gz: 4621470b5e42eb7cfc0f1ac242a6816d3f7f3df6e6a18ac53ea522539ba29bac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f83cf590b3c663f743771909b33b9f0abea5639d77b09e783a6b4049d5ac1eac7134b36feeabfa792d0c6bd97f9328d892fb5daa95e7fcd907bd71539fe30661
|
7
|
+
data.tar.gz: f0a04af71ee6edea83bdb1795fa2aa89b109595bbeca695542f8a93cfd0a34c08f62d461c12b645e1eb3742d8707f9ca6083d248b3d230fbcbd45fd521acfa0b
|
data/Gemfile.lock
CHANGED
data/lib/super_parser/client.rb
CHANGED
@@ -5,25 +5,23 @@ require_relative 'client_error'
|
|
5
5
|
|
6
6
|
module SuperParser # :nodoc:
|
7
7
|
class Client
|
8
|
-
def parse(
|
8
|
+
def parse(file)
|
9
9
|
uri = URI('https://api.superparser.com/parse')
|
10
10
|
request = Net::HTTP::Post.new(uri)
|
11
11
|
request['X-API-KEY'] = SuperParser.api_key
|
12
12
|
request['accept'] = 'application/json'
|
13
13
|
|
14
|
-
|
15
|
-
form_data = [['file_name', file]]
|
14
|
+
form_data = [['file_name', file]]
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
request.set_form form_data, 'multipart/form-data'
|
17
|
+
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
|
18
|
+
http.request(request)
|
19
|
+
end
|
21
20
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
21
|
+
if response.code != 200
|
22
|
+
SuperParser::ClientError.new response
|
23
|
+
else
|
24
|
+
SuperParser::Response.new(response.body)
|
27
25
|
end
|
28
26
|
end
|
29
27
|
end
|
data/lib/super_parser/version.rb
CHANGED