domoscio_viz 0.2.3 → 0.2.4
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/domoscio_viz.rb +17 -10
- data/lib/domoscio_viz/errors.rb +4 -4
- data/lib/domoscio_viz/generators/install_generator.rb +1 -1
- data/lib/domoscio_viz/http_calls.rb +1 -6
- data/lib/domoscio_viz/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 887c55dd8caa52f79ff7cdb18b53f7ed134b538f0d3783d5f4826bbe99efe0db
|
4
|
+
data.tar.gz: 6229db276d697d67b482d5c6bedf8bf0cd5a236ce3336f73f5187ab4d995af85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 665710baedb373e38e2cfb5a821f95ce52d5ba80d16de6d56127a8cc90ad1b80cbd9391ae45a377f679f6316bff32623f99e5c1598c1bd4122207d6dae616c4e
|
7
|
+
data.tar.gz: e02a53ce48feffc03b70377f129339dd3e4c7ad43f0b776be02baa67d9d8741ec9fc2544ba19e762d36576f8d2bdd1f2a7eb2a433bb9d69cbfce5fb704ffae79
|
data/lib/domoscio_viz.rb
CHANGED
@@ -32,9 +32,9 @@ module DomoscioViz
|
|
32
32
|
def root_url
|
33
33
|
if @preproduction == true
|
34
34
|
if @test == true
|
35
|
-
@root_url || "https://domoscio-viz-engine-preprod.azurewebsites.net"
|
35
|
+
@root_url || "https://domoscio-viz-engine-v2-preprod.azurewebsites.net"
|
36
36
|
else
|
37
|
-
@root_url || "https://
|
37
|
+
@root_url || "https://visualization-engine.domoscio.com"
|
38
38
|
end
|
39
39
|
else
|
40
40
|
@root_url || "http://localhost:3002"
|
@@ -55,20 +55,16 @@ module DomoscioViz
|
|
55
55
|
URI(configuration.root_url + url)
|
56
56
|
end
|
57
57
|
|
58
|
-
#
|
59
58
|
def self.request(method, url, params={}, filters={}, headers = request_headers, before_request_proc = nil)
|
60
59
|
return false if @disabled
|
61
60
|
uri = api_uri(url)
|
62
61
|
uri.query = URI.encode_www_form(filters) unless filters.empty?
|
63
62
|
res = DomoscioViz.send_request(uri, method, params, headers, before_request_proc)
|
64
63
|
return res if res.kind_of? DomoscioViz::ProcessingError
|
65
|
-
|
66
|
-
|
64
|
+
begin
|
65
|
+
raise_http_failure(uri, res, params)
|
67
66
|
data = DomoscioViz::JSON.load(res.body.nil? ? '' : res.body)
|
68
|
-
|
69
|
-
unless (res.kind_of? Net::HTTPClientError) || (res.kind_of? Net::HTTPServerError)
|
70
|
-
DomoscioViz::AuthorizationToken::Manager.storage.store({access_token: res['Accesstoken'], refresh_token: res['Refreshtoken']})
|
71
|
-
end
|
67
|
+
DomoscioViz::AuthorizationToken::Manager.storage.store({access_token: res['Accesstoken'], refresh_token: res['Refreshtoken']})
|
72
68
|
rescue MultiJson::LoadError => exception
|
73
69
|
return ProcessingError.new(uri, 500, exception, res.body, params)
|
74
70
|
rescue ResponseError => exception
|
@@ -86,12 +82,23 @@ module DomoscioViz
|
|
86
82
|
http.request req
|
87
83
|
end
|
88
84
|
rescue Timeout::Error, Errno::EINVAL, HTTP::ConnectionError, Errno::ECONNREFUSED, Errno::ECONNRESET, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => exception
|
89
|
-
ProcessingError.new(uri, 500, exception, res
|
85
|
+
ProcessingError.new(uri, 500, exception, res, params)
|
90
86
|
end
|
91
87
|
end
|
92
88
|
|
93
89
|
private
|
94
90
|
|
91
|
+
def self.raise_http_failure(uri, res, params)
|
92
|
+
unless res.kind_of? Net::HTTPSuccess
|
93
|
+
if res.blank?
|
94
|
+
raise ResponseError.new(uri, 500, {error: {status: 500, message: 'VisualizationEngine not available'}}, {}, params)
|
95
|
+
else
|
96
|
+
body = DomoscioRails::JSON.load((res.body.nil? ? '' : res.body), :symbolize_keys => true)
|
97
|
+
raise ResponseError.new(uri, res.code.to_i, body, res.body, params)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
95
102
|
def self.user_agent
|
96
103
|
@uname ||= get_uname
|
97
104
|
{
|
data/lib/domoscio_viz/errors.rb
CHANGED
@@ -4,20 +4,20 @@ module DomoscioViz
|
|
4
4
|
# Currently only single subclass used.
|
5
5
|
class Error < StandardError
|
6
6
|
end
|
7
|
-
#
|
7
|
+
# ResponseError from VizEngine
|
8
8
|
class ResponseError < Error
|
9
9
|
attr_reader :request_url, :code, :details, :body, :request_params
|
10
|
-
def initialize(request_url, code, details, body, request_params)
|
10
|
+
def initialize(request_url, code, details = {}, body = nil, request_params = {})
|
11
11
|
@request_url, @code, @details, @body, @request_params = request_url, code, details, body, request_params
|
12
12
|
super(message) if message
|
13
13
|
end
|
14
|
-
def message; @details.dig(:error, :message)
|
14
|
+
def message; @details.is_a?(Hash) ? @details.dig(:error, :message) : @details; end
|
15
15
|
end
|
16
16
|
|
17
17
|
# ProcessingError from Domoscio_viz
|
18
18
|
class ProcessingError < Error
|
19
19
|
attr_reader :request_url, :code, :details, :body, :request_params
|
20
|
-
def initialize(request_url, code, details, body, request_params)
|
20
|
+
def initialize(request_url, code, details = {}, body = nil, request_params = {})
|
21
21
|
@request_url, @code, @details, @body, @request_params = request_url, code, details, body, request_params
|
22
22
|
super(message) if message
|
23
23
|
end
|
@@ -4,7 +4,7 @@ module DomoscioViz
|
|
4
4
|
source_root File.expand_path('../templates', __FILE__)
|
5
5
|
desc "Generate config file for DomoscioViz configuration"
|
6
6
|
def install
|
7
|
-
|
7
|
+
copy_file "install.rb", "config/initializers/domoscio_viz.rb"
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
@@ -2,15 +2,10 @@ module DomoscioViz
|
|
2
2
|
module HTTPCalls
|
3
3
|
module GetUrl
|
4
4
|
module ClassMethods
|
5
|
-
# In order to catch current SocketsTimeoutError that seem to appear when the VizEngine stays Idle for too long
|
6
|
-
# Perform the request a second time if it fails the fisrt time
|
7
5
|
def get_url(util_name = nil, params = {})
|
8
|
-
|
9
|
-
response = DomoscioViz.request(:post, url(util_name), params) unless response && response.is_a?(Hash) && response['url'] && response['success'] == true
|
10
|
-
response
|
6
|
+
DomoscioViz.request(:post, url(util_name), params)
|
11
7
|
end
|
12
8
|
end
|
13
|
-
|
14
9
|
def self.included(base)
|
15
10
|
base.extend(ClassMethods)
|
16
11
|
end
|
data/lib/domoscio_viz/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: domoscio_viz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benoit Praly
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -63,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
63
63
|
- !ruby/object:Gem::Version
|
64
64
|
version: '0'
|
65
65
|
requirements: []
|
66
|
-
rubygems_version: 3.
|
66
|
+
rubygems_version: 3.1.2
|
67
67
|
signing_key:
|
68
68
|
specification_version: 4
|
69
69
|
summary: Summary of DomoscioViz.
|