mn_utils_gem 1.9.0 → 1.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mn_utils_gem.rb +1 -0
- data/lib/mn_utils_gem/gui.rb +43 -0
- data/lib/mn_utils_gem/version.rb +1 -1
- metadata +16 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36c0faee921931d517c0a35336d29633e8589619c4b5eb0c86bee99900f8d97f
|
4
|
+
data.tar.gz: 93e3463b56d466f4f70526d3755771df97922dda3d82347e792ba5b3e4159c16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7fc64f80aef99268c28e661bf5b9799f3ad34f79d4d7b36d0f71c9c0dca89bbcaedc7c2280b046468d3317445f9749541c4883f5723377803c134f17b1e501b
|
7
|
+
data.tar.gz: 2f449dad6e7ad28ef26535a090c0bc17442129c21a1f97687f2cbb3c3d55ab85534e657ca1cc3f1def79b29def02af8317a429968093377a96129bef455f7a61
|
data/lib/mn_utils_gem.rb
CHANGED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
module MnUtilsGlobal
|
4
|
+
class Gui
|
5
|
+
|
6
|
+
def self.render_component(component)
|
7
|
+
Rails.cache.fetch("gui-component-#{component}", expires_in: 1.hour) do
|
8
|
+
render_component_html(component)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def self.render_component_html(component)
|
15
|
+
validate_component(component)
|
16
|
+
response = HTTP.timeout(1).get("#{ENV['SRV_GUI_URL']}/service/gui/api/v1/component/#{component}")
|
17
|
+
json = JSON.parse(response)
|
18
|
+
validate_json(json)
|
19
|
+
json['html'].html_safe
|
20
|
+
rescue StandardError => e
|
21
|
+
logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
22
|
+
logger.error("ViewHelper::render_gui_component error #{e.backtrace}")
|
23
|
+
return ''
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.validate_component(component)
|
27
|
+
raise ArgumentError, 'Component must not be nil' \
|
28
|
+
if component.nil?
|
29
|
+
raise ArgumentError, 'Component connot be blank' \
|
30
|
+
if component.blank?
|
31
|
+
raise ArgumentError, 'Component must be a string' \
|
32
|
+
unless component.is_a?(String)
|
33
|
+
raise ArgumentError, "ENV['SRV_GUI_URL'] is required" \
|
34
|
+
unless ENV.key? 'SRV_GUI_URL'
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.validate_json(json)
|
38
|
+
raise ArgumentError, 'json is empty or nil' \
|
39
|
+
if (json.nil? || json.blank?) && (json['html'].nil? || json['html'].blank?)
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
data/lib/mn_utils_gem/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mn_utils_gem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shamim Mirzai
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: httparty
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: activesupport
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -129,6 +143,7 @@ extensions: []
|
|
129
143
|
extra_rdoc_files: []
|
130
144
|
files:
|
131
145
|
- lib/mn_utils_gem.rb
|
146
|
+
- lib/mn_utils_gem/gui.rb
|
132
147
|
- lib/mn_utils_gem/site_action.rb
|
133
148
|
- lib/mn_utils_gem/transactional_email.rb
|
134
149
|
- lib/mn_utils_gem/version.rb
|