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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ff9559b71c211fca5e4e77ffd822962f3b0116769b28fa733ad773379ccd8cb4
4
- data.tar.gz: 320245dda3483b9eda05b20c01a40ee1ff6f4e7f4f51e06ca9bac6a6a3d83828
3
+ metadata.gz: 36c0faee921931d517c0a35336d29633e8589619c4b5eb0c86bee99900f8d97f
4
+ data.tar.gz: 93e3463b56d466f4f70526d3755771df97922dda3d82347e792ba5b3e4159c16
5
5
  SHA512:
6
- metadata.gz: a1bd7857d15d245f8e02b4c3ebb42ae21a08d9c9db868313c0bb83b8ca0845b1fee7ca53efbae7b010061bc37bbb9151cc6d108fbe1392f0450181f6ac3b5ffc
7
- data.tar.gz: 393968a8b0e8ab19fb3376fd9414d710d201bf219d462b4db633a4ef06a040e962f07df8845d984b0dcbf45a193e54b15204b5a5b524fc8337c857156366a32f
6
+ metadata.gz: e7fc64f80aef99268c28e661bf5b9799f3ad34f79d4d7b36d0f71c9c0dca89bbcaedc7c2280b046468d3317445f9749541c4883f5723377803c134f17b1e501b
7
+ data.tar.gz: 2f449dad6e7ad28ef26535a090c0bc17442129c21a1f97687f2cbb3c3d55ab85534e657ca1cc3f1def79b29def02af8317a429968093377a96129bef455f7a61
@@ -1,5 +1,6 @@
1
1
  require "mn_utils_gem/version"
2
2
  require "mn_utils_gem/site_action"
3
+ require "mn_utils_gem/gui"
3
4
  require "mn_utils_gem/transactional_email"
4
5
 
5
6
  module MnUtilsGem
@@ -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
@@ -1,3 +1,3 @@
1
1
  module MnUtilsGem
2
- VERSION = "1.9.0"
2
+ VERSION = "1.10.0"
3
3
  end
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.9.0
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