singleton-client-test 0.7.0.33 → 0.7.0.34

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.
@@ -1,24 +0,0 @@
1
- # Copyright 2022 VMware, Inc.
2
- # SPDX-License-Identifier: EPL-2.0
3
-
4
- require 'rest-client'
5
- require 'multi_json'
6
-
7
- module SgtnClient::Core
8
- class Request
9
- def self.get(url)
10
- SgtnClient.logger.debug "[Request][get]url=#{url}"
11
- res = RestClient::Resource.new(
12
- url,
13
- :verify_ssl => false
14
- ).get
15
- begin
16
- obj = MultiJson.load(res)
17
- rescue MultiJson::ParseError => exception
18
- exception.data
19
- exception.cause
20
- end
21
- return obj
22
- end
23
- end
24
- end
@@ -1,13 +0,0 @@
1
- # Copyright 2022 VMware, Inc.
2
- # SPDX-License-Identifier: EPL-2.0
3
-
4
- module SgtnClient::TranslationLoader::LocalBundle
5
- def load_bundle(component, locale)
6
- env = SgtnClient::Config.default_environment
7
- product_name = SgtnClient::Config.configurations[env]['product_name']
8
- version = SgtnClient::Config.configurations[env]['version'].to_s
9
- translation_bundle = SgtnClient::Config.configurations[env]['translation_bundle']
10
- bundlepath = translation_bundle + '/' + product_name + '/' + version + '/' + component + '/messages_' + locale + '.json'
11
- SgtnClient::FileUtil.read_json(bundlepath)
12
- end
13
- end
@@ -1,29 +0,0 @@
1
- # Copyright 2022 VMware, Inc.
2
- # SPDX-License-Identifier: EPL-2.0
3
-
4
- module SgtnClient
5
- class Source
6
- def self.load_bundle(component)
7
- SgtnClient.logger.debug "[Source][getBundle]component=#{component}"
8
- env = SgtnClient::Config.default_environment
9
- source_bundle = SgtnClient::Config.configurations[env]['source_bundle']
10
- component_path = "#{source_bundle}/#{component}"
11
- total_messages = nil
12
- Dir.glob('**/*.{yml, yaml}', base: component_path) do |f|
13
- bundle = SgtnClient::FileUtil.read_yml("#{component_path}/#{f}")
14
- if total_messages.nil?
15
- total_messages = bundle&.first&.last
16
- else
17
- total_messages.merge!(bundle&.first&.last)
18
- end
19
- end
20
-
21
- if total_messages
22
- return { 'component' => component, 'locale' => SgtnClient::LocaleUtil.get_source_locale, 'messages' => total_messages }
23
- end
24
- rescue StandardError => e
25
- SgtnClient.logger.error e.message
26
- nil
27
- end
28
- end
29
- end
@@ -1,22 +0,0 @@
1
- # Copyright 2022 VMware, Inc.
2
- # SPDX-License-Identifier: EPL-2.0
3
-
4
- module SgtnClient::Core
5
- autoload :Request, 'sgtn-client/core/request'
6
- end
7
-
8
- module SgtnClient::TranslationLoader::ServerBundle
9
- def load_bundle(component, locale)
10
- env = SgtnClient::Config.default_environment
11
- product_name = SgtnClient::Config.configurations[env]['product_name']
12
- vip_server = SgtnClient::Config.configurations[env]['vip_server']
13
- version = SgtnClient::Config.configurations[env]['version'].to_s
14
- url = vip_server + '/i18n/api/v2/translation/products/' + product_name + '/versions/' + version + '/locales/' + locale + '/components/' + component + '?checkTranslationStatus=false&machineTranslation=false&pseudo=false'
15
- begin
16
- obj = SgtnClient::Core::Request.get(url)
17
- rescue StandardError => e
18
- SgtnClient.logger.error e.message
19
- end
20
- obj && obj['data']
21
- end
22
- end
@@ -1,24 +0,0 @@
1
- # Copyright 2022 VMware, Inc.
2
- # SPDX-License-Identifier: EPL-2.0
3
-
4
- autoload :YAML, 'yaml'
5
- autoload :MultiJson, 'multi_json'
6
-
7
- module SgtnClient
8
-
9
- class FileUtil
10
- def self.read_json(bundlepath)
11
- SgtnClient.logger.debug "[FileUtil]read json file from: " + bundlepath
12
- begin
13
- return MultiJson.load(File.read(bundlepath))
14
- rescue => exception
15
- SgtnClient.logger.error exception.message
16
- end
17
- nil
18
- end
19
-
20
- def self.read_yml(file_name)
21
- YAML::load(File.read(file_name))
22
- end
23
- end
24
- end