rasper_client 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rasper_client/client.rb +19 -3
- data/lib/rasper_client/version.rb +1 -1
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e095ad00114767244b0b647545500383c9b1ed138934afd5cb0d0aad3ca3334d
|
4
|
+
data.tar.gz: 94d5c03f652b4e7044d7a95118ed18069f3d23a327ada852df25dac0e5181129
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b37451fddf6dcb7dc397f966331c1509645d1652e58bb7f50012e39ed32bd1006781ef4e8b0fde5f041cb208db728b924e52753bb8008c206e9e2ba1a842259
|
7
|
+
data.tar.gz: a3947cbe7e623c748f75b829a5a57d1877d06a87d2a3b032f51ed5e3cff9b350d393efde588aba6f40ef9437108bc224bf0137ac9b1ea5a5599d25559c8bf168
|
data/lib/rasper_client/client.rb
CHANGED
@@ -4,8 +4,11 @@ require 'json'
|
|
4
4
|
|
5
5
|
module RasperClient
|
6
6
|
class Client
|
7
|
-
def initialize(
|
8
|
-
@host
|
7
|
+
def initialize(host:, port:, timeout: nil, empty_nil_values: false)
|
8
|
+
@host = host
|
9
|
+
@port = port
|
10
|
+
@timeout = timeout
|
11
|
+
@empty_nil_values = empty_nil_values
|
9
12
|
@request_params = build_request_params
|
10
13
|
end
|
11
14
|
|
@@ -14,12 +17,13 @@ module RasperClient
|
|
14
17
|
encode_options(options)
|
15
18
|
response = execute_request(:add, options)
|
16
19
|
JSON.parse(response.body) == { 'success' => true }
|
17
|
-
rescue Errno::ECONNREFUSED
|
20
|
+
rescue Errno::ECONNREFUSED, Errno::EADDRNOTAVAIL
|
18
21
|
raise ConnectionRefusedError
|
19
22
|
end
|
20
23
|
|
21
24
|
def generate(options)
|
22
25
|
symbolize_keys(options)
|
26
|
+
empty_nil_values(options) if @empty_nil_values
|
23
27
|
options = encode_data(options)
|
24
28
|
response = execute_request(:generate, options)
|
25
29
|
result = JSON.parse(response.body)
|
@@ -71,6 +75,18 @@ module RasperClient
|
|
71
75
|
{ data: Base64.encode64(options.to_json) }
|
72
76
|
end
|
73
77
|
|
78
|
+
def empty_nil_values(hash)
|
79
|
+
hash.each_key do |key|
|
80
|
+
if hash[key].is_a?(Hash)
|
81
|
+
empty_nil_values(hash[key])
|
82
|
+
elsif hash[key].is_a?(Array)
|
83
|
+
hash[key].each {|item| empty_nil_values(item) if item.is_a?(Hash) }
|
84
|
+
else
|
85
|
+
hash[key] = '' if hash[key].nil?
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
74
90
|
def uri_for(action)
|
75
91
|
"http://#{@host}:#{@port}/#{action}"
|
76
92
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rasper_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rodrigo Manhães
|
@@ -115,8 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: '0'
|
117
117
|
requirements: []
|
118
|
-
|
119
|
-
rubygems_version: 2.7.6
|
118
|
+
rubygems_version: 3.0.3
|
120
119
|
signing_key:
|
121
120
|
specification_version: 4
|
122
121
|
summary: JRuby client to RasperServer.
|