singleton-client-test 0.7.0.31 → 0.7.0.34
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sgtn-client/api/source.rb +10 -66
- data/lib/sgtn-client/api/t.rb +20 -18
- data/lib/sgtn-client/api/translation.rb +82 -117
- data/lib/sgtn-client/cldr/core_ext.rb +4 -1
- data/lib/sgtn-client/cldr/localized_date.rb +4 -1
- data/lib/sgtn-client/cldr/localized_datetime.rb +4 -1
- data/lib/sgtn-client/cldr/localized_str.rb +3 -1
- data/lib/sgtn-client/cldr/localized_time.rb +4 -1
- data/lib/sgtn-client/common/data.rb +30 -0
- data/lib/sgtn-client/common/single_operation.rb +34 -0
- data/lib/sgtn-client/core/cache.rb +14 -80
- data/lib/sgtn-client/core/config.rb +39 -3
- data/lib/sgtn-client/core/exceptions.rb +3 -0
- data/lib/sgtn-client/core/logging.rb +3 -1
- data/lib/sgtn-client/exceptions.rb +6 -0
- data/lib/sgtn-client/formatters/plurals/plural_formatter.rb +4 -1
- data/lib/sgtn-client/loader/cache.rb +71 -0
- data/lib/sgtn-client/loader/chain_loader.rb +49 -0
- data/lib/sgtn-client/loader/consts.rb +15 -0
- data/lib/sgtn-client/loader/loader_factory.rb +33 -0
- data/lib/sgtn-client/loader/local_translation.rb +50 -0
- data/lib/sgtn-client/loader/server.rb +94 -0
- data/lib/sgtn-client/loader/single_loader.rb +46 -0
- data/lib/sgtn-client/loader/source.rb +53 -0
- data/lib/sgtn-client/loader/source_comparer.rb +58 -0
- data/lib/sgtn-client/sgtn-client.rb +7 -1
- data/lib/sgtn-client/util/cache-util.rb +33 -44
- data/lib/sgtn-client/util/locale-util.rb +48 -31
- data/lib/sgtn-client/util/string-util.rb +12 -0
- data/lib/sgtn-client/util/validate-util.rb +4 -7
- data/lib/singleton-client.rb +15 -0
- data/lib/singleton-ruby.rb +5 -0
- data/lib/version.rb +2 -0
- metadata +43 -147
- data/lib/sgtn-client/core/request.rb +0 -21
- data/lib/sgtn-client/util/file-util.rb +0 -34
@@ -1,51 +1,40 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# Copyright 2022 VMware, Inc.
|
2
|
+
# SPDX-License-Identifier: EPL-2.0
|
3
3
|
|
4
4
|
module SgtnClient
|
5
|
-
|
6
5
|
module Core
|
7
|
-
autoload :Cache,
|
6
|
+
autoload :Cache, 'sgtn-client/core/cache'
|
8
7
|
end
|
9
|
-
|
8
|
+
|
10
9
|
class CacheUtil
|
10
|
+
def self.get_cache(cache_key)
|
11
|
+
SgtnClient::Core::Cache.get(cache_key)
|
12
|
+
end
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
def self.clear_cache()
|
19
|
-
SgtnClient::Core::Cache.clear()
|
20
|
-
SgtnClient.logger.debug "[CacheUtil]clear cache"
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.write_cache(cache_key, items)
|
24
|
-
if items.nil?
|
25
|
-
return nil
|
26
|
-
end
|
27
|
-
env = SgtnClient::Config.default_environment
|
28
|
-
cache_expiry_period = SgtnClient::Config.configurations[env]["cache_expiry_period"]
|
29
|
-
# expired after 24 hours
|
30
|
-
if cache_expiry_period == nil
|
31
|
-
cache_expiry_period = 24*60
|
32
|
-
end
|
33
|
-
SgtnClient.logger.debug "[CacheUtil]write cache with key #{cache_key}, cache_expiry_period #{cache_expiry_period}, itmes #{items}"
|
34
|
-
SgtnClient::Core::Cache.put(cache_key, items, cache_expiry_period)
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.get_cachekey(component, locale)
|
38
|
-
env = SgtnClient::Config.default_environment
|
39
|
-
product_name = SgtnClient::Config.configurations[env]["product_name"]
|
40
|
-
version = SgtnClient::Config.configurations[env]["version"].to_s
|
41
|
-
default_l = SgtnClient::Config.configurations[env]["default_language"]
|
42
|
-
if default_l == nil
|
43
|
-
default_l = 'en'
|
44
|
-
end
|
45
|
-
lc = locale == default_l ? SgtnClient::Config.configurations.default: locale
|
46
|
-
SgtnClient.logger.debug "[CacheUtil]get cache key: #{lc}"
|
47
|
-
return product_name + "_" + version + "_" + component + "_" + lc
|
48
|
-
end
|
49
|
-
end
|
14
|
+
def self.clear_cache
|
15
|
+
SgtnClient::Core::Cache.clear
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.write_cache(cache_key, items)
|
19
|
+
return nil if items.nil? || items.empty?
|
50
20
|
|
51
|
-
|
21
|
+
env = SgtnClient::Config.default_environment
|
22
|
+
cache_expiry_period = SgtnClient::Config.configurations[env]['cache_expiry_period']
|
23
|
+
# expired after 24 hours
|
24
|
+
cache_expiry_period = 24 * 60 if cache_expiry_period.nil?
|
25
|
+
SgtnClient::Core::Cache.put(cache_key, items, cache_expiry_period)
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.get_cachekey(component, locale)
|
29
|
+
env = SgtnClient::Config.default_environment
|
30
|
+
product_name = SgtnClient::Config.configurations[env]['product_name']
|
31
|
+
version = SgtnClient::Config.configurations[env]['version'].to_s
|
32
|
+
product_name + '_' + version + '_' + component + '_' + locale
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.is_expired(cache_item)
|
36
|
+
cache_item[:expiry] < Time.now
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -1,35 +1,52 @@
|
|
1
|
+
# Copyright 2022 VMware, Inc.
|
2
|
+
# SPDX-License-Identifier: EPL-2.0
|
3
|
+
require 'set'
|
4
|
+
|
1
5
|
module SgtnClient
|
6
|
+
class LocaleUtil
|
7
|
+
MAP_LOCALES = {
|
8
|
+
'zh-CN' => 'zh-Hans',
|
9
|
+
'zh-TW' => 'zh-Hant',
|
10
|
+
'zh-Hans-CN' => 'zh-Hans',
|
11
|
+
'zh-Hant-TW' => 'zh-Hant'
|
12
|
+
}.freeze
|
2
13
|
|
3
|
-
|
14
|
+
def self.get_best_locale(locale)
|
15
|
+
return get_fallback_locale if locale.nil?
|
4
16
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
"zh-Hant-TW" =>"zh-Hant",
|
10
|
-
}
|
11
|
-
|
12
|
-
class LocaleUtil
|
13
|
-
def self.process_locale(locale=nil)
|
14
|
-
locale ||= SgtnClient::Config.configurations.default
|
15
|
-
locale.to_s
|
16
|
-
end
|
17
|
-
def self.fallback(locale)
|
18
|
-
found = SgtnClient::DEFAULT_LOCALES.select {|e| e == locale}
|
19
|
-
if !found.empty?
|
20
|
-
return found[0]
|
21
|
-
end
|
22
|
-
if SgtnClient::MAP_LOCALES.key?(locale)
|
23
|
-
return SgtnClient::MAP_LOCALES[locale]
|
24
|
-
end
|
25
|
-
parts = locale.split("-")
|
26
|
-
if parts.size > 1
|
27
|
-
f = SgtnClient::DEFAULT_LOCALES.select {|e| e == parts[0]}
|
28
|
-
if !f.empty?
|
29
|
-
return f[0]
|
30
|
-
end
|
31
|
-
end
|
32
|
-
return locale
|
33
|
-
end
|
17
|
+
locale = locale.to_s
|
18
|
+
return get_fallback_locale if locale.empty?
|
19
|
+
|
20
|
+
get_best_match(locale.gsub('_', '-'))
|
34
21
|
end
|
35
|
-
|
22
|
+
|
23
|
+
def self.is_source_locale(locale = nil)
|
24
|
+
locale == get_source_locale
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.get_best_match(locale)
|
28
|
+
locale = MAP_LOCALES[locale] || locale
|
29
|
+
return locale if Config.available_locales.include?(locale)
|
30
|
+
|
31
|
+
index = locale.rindex('-')
|
32
|
+
return get_fallback_locale if index.nil?
|
33
|
+
|
34
|
+
get_best_match(locale[0...index])
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.get_source_locale
|
38
|
+
'en'
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.get_default_locale
|
42
|
+
env = SgtnClient::Config.default_environment
|
43
|
+
SgtnClient::Config.configurations[env]['default_language']
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.get_fallback_locale
|
47
|
+
@fallback_locale ||= get_default_locale || get_source_locale || 'en'
|
48
|
+
end
|
49
|
+
|
50
|
+
private_class_method :get_best_match
|
51
|
+
end
|
52
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# Copyright 2022 VMware, Inc.
|
2
|
+
# SPDX-License-Identifier: EPL-2.0
|
1
3
|
|
2
4
|
module SgtnClient
|
3
5
|
|
@@ -12,12 +14,7 @@ module SgtnClient
|
|
12
14
|
if mode != 'sandbox' && mode != 'live'
|
13
15
|
messages = messages + "Configuration[mode] has to be 'sandbox' or 'live'!\n"
|
14
16
|
end
|
15
|
-
|
16
|
-
bundle_mode = SgtnClient::Config.configurations[env]["bundle_mode"]
|
17
|
-
if bundle_mode != 'offline' && bundle_mode != 'online'
|
18
|
-
messages = messages + "Configuration[bundle_mode] has to be 'offline' or 'online'!\n"
|
19
|
-
end
|
20
|
-
|
17
|
+
|
21
18
|
#version = SgtnClient::Config.configurations[env]["version"]
|
22
19
|
#if version.is_a? Integer
|
23
20
|
#messages = messages + "Configuration[version] has to be standard as '#.#.#, e.g '1.0.0'!\n"
|
@@ -40,4 +37,4 @@ module SgtnClient
|
|
40
37
|
|
41
38
|
end
|
42
39
|
|
43
|
-
end
|
40
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Copyright 2022 VMware, Inc.
|
2
|
+
# SPDX-License-Identifier: EPL-2.0
|
3
|
+
|
4
|
+
require_relative 'singleton-ruby'
|
5
|
+
|
6
|
+
module Singleton # :nodoc:
|
7
|
+
# load configuration from a file
|
8
|
+
def self.load_config(*args)
|
9
|
+
SgtnClient.load(*args)
|
10
|
+
end
|
11
|
+
|
12
|
+
extend SgtnClient::Translation::Implementation
|
13
|
+
|
14
|
+
private_class_method :getString, :getString_p, :getString_f, :getStrings
|
15
|
+
end
|
data/lib/singleton-ruby.rb
CHANGED
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,85 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: singleton-client-test
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.0.
|
4
|
+
version: 0.7.0.34
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- VMware G11n Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '2.0'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '2.0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: multi_json
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '1.0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '1.0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: request_store
|
14
|
+
name: rdoc
|
43
15
|
requirement: !ruby/object:Gem::Requirement
|
44
16
|
requirements:
|
45
|
-
- - "
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '1.1'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
17
|
+
- - ">="
|
53
18
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
55
|
-
-
|
56
|
-
name: twitter_cldr
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
19
|
+
version: 2.4.2
|
20
|
+
- - "<"
|
60
21
|
- !ruby/object:Gem::Version
|
61
|
-
version: '6.
|
22
|
+
version: '6.0'
|
62
23
|
type: :development
|
63
24
|
prerelease: false
|
64
25
|
version_requirements: !ruby/object:Gem::Requirement
|
65
26
|
requirements:
|
66
|
-
- - "
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '6.6'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: webmock
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
27
|
+
- - ">="
|
74
28
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
76
|
-
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
29
|
+
version: 2.4.2
|
30
|
+
- - "<"
|
81
31
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
32
|
+
version: '6.0'
|
83
33
|
- !ruby/object:Gem::Dependency
|
84
34
|
name: rspec
|
85
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,54 +44,6 @@ dependencies:
|
|
94
44
|
- - "~>"
|
95
45
|
- !ruby/object:Gem::Version
|
96
46
|
version: '3.0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: pry
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - "~>"
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: pry-doc
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - "~>"
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - "~>"
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '0'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: rdoc
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - ">="
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: 2.4.2
|
132
|
-
- - "<"
|
133
|
-
- !ruby/object:Gem::Version
|
134
|
-
version: '6.0'
|
135
|
-
type: :development
|
136
|
-
prerelease: false
|
137
|
-
version_requirements: !ruby/object:Gem::Requirement
|
138
|
-
requirements:
|
139
|
-
- - ">="
|
140
|
-
- !ruby/object:Gem::Version
|
141
|
-
version: 2.4.2
|
142
|
-
- - "<"
|
143
|
-
- !ruby/object:Gem::Version
|
144
|
-
version: '6.0'
|
145
47
|
- !ruby/object:Gem::Dependency
|
146
48
|
name: rubocop
|
147
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -157,93 +59,75 @@ dependencies:
|
|
157
59
|
- !ruby/object:Gem::Version
|
158
60
|
version: '0.49'
|
159
61
|
- !ruby/object:Gem::Dependency
|
160
|
-
name:
|
62
|
+
name: webmock
|
161
63
|
requirement: !ruby/object:Gem::Requirement
|
162
64
|
requirements:
|
163
|
-
- - "
|
164
|
-
- !ruby/object:Gem::Version
|
165
|
-
version: 1.7.0
|
166
|
-
- - "<"
|
65
|
+
- - "~>"
|
167
66
|
- !ruby/object:Gem::Version
|
168
67
|
version: '2.0'
|
169
|
-
type: :
|
68
|
+
type: :development
|
170
69
|
prerelease: false
|
171
70
|
version_requirements: !ruby/object:Gem::Requirement
|
172
71
|
requirements:
|
173
|
-
- - "
|
174
|
-
- !ruby/object:Gem::Version
|
175
|
-
version: 1.7.0
|
176
|
-
- - "<"
|
72
|
+
- - "~>"
|
177
73
|
- !ruby/object:Gem::Version
|
178
74
|
version: '2.0'
|
179
75
|
- !ruby/object:Gem::Dependency
|
180
|
-
name:
|
76
|
+
name: faraday
|
181
77
|
requirement: !ruby/object:Gem::Requirement
|
182
78
|
requirements:
|
183
79
|
- - ">="
|
184
80
|
- !ruby/object:Gem::Version
|
185
|
-
version:
|
186
|
-
- - "<"
|
187
|
-
- !ruby/object:Gem::Version
|
188
|
-
version: '2.0'
|
81
|
+
version: '0'
|
189
82
|
type: :runtime
|
190
83
|
prerelease: false
|
191
84
|
version_requirements: !ruby/object:Gem::Requirement
|
192
85
|
requirements:
|
193
86
|
- - ">="
|
194
87
|
- !ruby/object:Gem::Version
|
195
|
-
version:
|
196
|
-
- - "<"
|
197
|
-
- !ruby/object:Gem::Version
|
198
|
-
version: '2.0'
|
88
|
+
version: '0'
|
199
89
|
- !ruby/object:Gem::Dependency
|
200
|
-
name:
|
90
|
+
name: faraday_middleware
|
201
91
|
requirement: !ruby/object:Gem::Requirement
|
202
92
|
requirements:
|
203
93
|
- - ">="
|
204
94
|
- !ruby/object:Gem::Version
|
205
|
-
version: '
|
206
|
-
- - "<"
|
207
|
-
- !ruby/object:Gem::Version
|
208
|
-
version: '4.0'
|
95
|
+
version: '0'
|
209
96
|
type: :runtime
|
210
97
|
prerelease: false
|
211
98
|
version_requirements: !ruby/object:Gem::Requirement
|
212
99
|
requirements:
|
213
100
|
- - ">="
|
214
101
|
- !ruby/object:Gem::Version
|
215
|
-
version: '
|
216
|
-
- - "<"
|
217
|
-
- !ruby/object:Gem::Version
|
218
|
-
version: '4.0'
|
102
|
+
version: '0'
|
219
103
|
- !ruby/object:Gem::Dependency
|
220
|
-
name:
|
104
|
+
name: multi_json
|
221
105
|
requirement: !ruby/object:Gem::Requirement
|
222
106
|
requirements:
|
223
107
|
- - "~>"
|
224
108
|
- !ruby/object:Gem::Version
|
225
|
-
version: '0
|
109
|
+
version: '1.0'
|
226
110
|
type: :runtime
|
227
111
|
prerelease: false
|
228
112
|
version_requirements: !ruby/object:Gem::Requirement
|
229
113
|
requirements:
|
230
114
|
- - "~>"
|
231
115
|
- !ruby/object:Gem::Version
|
232
|
-
version: '0
|
116
|
+
version: '1.0'
|
233
117
|
- !ruby/object:Gem::Dependency
|
234
|
-
name:
|
118
|
+
name: request_store
|
235
119
|
requirement: !ruby/object:Gem::Requirement
|
236
120
|
requirements:
|
237
|
-
- - "
|
121
|
+
- - ">="
|
238
122
|
- !ruby/object:Gem::Version
|
239
|
-
version: '
|
123
|
+
version: '0'
|
240
124
|
type: :runtime
|
241
125
|
prerelease: false
|
242
126
|
version_requirements: !ruby/object:Gem::Requirement
|
243
127
|
requirements:
|
244
|
-
- - "
|
128
|
+
- - ">="
|
245
129
|
- !ruby/object:Gem::Version
|
246
|
-
version: '
|
130
|
+
version: '0'
|
247
131
|
- !ruby/object:Gem::Dependency
|
248
132
|
name: twitter_cldr
|
249
133
|
requirement: !ruby/object:Gem::Requirement
|
@@ -274,17 +158,29 @@ files:
|
|
274
158
|
- lib/sgtn-client/cldr/localized_datetime.rb
|
275
159
|
- lib/sgtn-client/cldr/localized_str.rb
|
276
160
|
- lib/sgtn-client/cldr/localized_time.rb
|
161
|
+
- lib/sgtn-client/common/data.rb
|
162
|
+
- lib/sgtn-client/common/single_operation.rb
|
277
163
|
- lib/sgtn-client/core/cache.rb
|
278
164
|
- lib/sgtn-client/core/config.rb
|
279
165
|
- lib/sgtn-client/core/exceptions.rb
|
280
166
|
- lib/sgtn-client/core/logging.rb
|
281
|
-
- lib/sgtn-client/
|
167
|
+
- lib/sgtn-client/exceptions.rb
|
282
168
|
- lib/sgtn-client/formatters/plurals/plural_formatter.rb
|
169
|
+
- lib/sgtn-client/loader/cache.rb
|
170
|
+
- lib/sgtn-client/loader/chain_loader.rb
|
171
|
+
- lib/sgtn-client/loader/consts.rb
|
172
|
+
- lib/sgtn-client/loader/loader_factory.rb
|
173
|
+
- lib/sgtn-client/loader/local_translation.rb
|
174
|
+
- lib/sgtn-client/loader/server.rb
|
175
|
+
- lib/sgtn-client/loader/single_loader.rb
|
176
|
+
- lib/sgtn-client/loader/source.rb
|
177
|
+
- lib/sgtn-client/loader/source_comparer.rb
|
283
178
|
- lib/sgtn-client/sgtn-client.rb
|
284
179
|
- lib/sgtn-client/util/cache-util.rb
|
285
|
-
- lib/sgtn-client/util/file-util.rb
|
286
180
|
- lib/sgtn-client/util/locale-util.rb
|
181
|
+
- lib/sgtn-client/util/string-util.rb
|
287
182
|
- lib/sgtn-client/util/validate-util.rb
|
183
|
+
- lib/singleton-client.rb
|
288
184
|
- lib/singleton-ruby.rb
|
289
185
|
- lib/version.rb
|
290
186
|
homepage: https://github.com/vmware/singleton
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'rest-client'
|
2
|
-
require 'multi_json'
|
3
|
-
|
4
|
-
module SgtnClient::Core
|
5
|
-
class Request
|
6
|
-
def self.get(url)
|
7
|
-
SgtnClient.logger.debug "[Request][get]url=#{url}"
|
8
|
-
res = RestClient::Resource.new(
|
9
|
-
url,
|
10
|
-
:verify_ssl => false
|
11
|
-
).get
|
12
|
-
begin
|
13
|
-
obj = MultiJson.load(res)
|
14
|
-
rescue MultiJson::ParseError => exception
|
15
|
-
exception.data
|
16
|
-
exception.cause
|
17
|
-
end
|
18
|
-
return obj
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'erb'
|
2
|
-
require 'yaml'
|
3
|
-
|
4
|
-
module SgtnClient
|
5
|
-
|
6
|
-
class FileUtil
|
7
|
-
|
8
|
-
@mutex = Mutex.new
|
9
|
-
|
10
|
-
def self.read_json(bundlepath)
|
11
|
-
SgtnClient.logger.debug "[FileUtil]read json file from: " + bundlepath
|
12
|
-
@mutex.synchronize do
|
13
|
-
data_hash = nil
|
14
|
-
begin
|
15
|
-
file = File.read(bundlepath)
|
16
|
-
data_hash = MultiJson.load(file)
|
17
|
-
rescue => exception
|
18
|
-
SgtnClient.logger.error exception.message
|
19
|
-
end
|
20
|
-
return data_hash
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.read_yml(file_name)
|
25
|
-
SgtnClient.logger.debug "[FileUtil]read yml file from: " + file_name
|
26
|
-
@mutex.synchronize do
|
27
|
-
erb = ERB.new(File.read(file_name))
|
28
|
-
erb.filename = file_name
|
29
|
-
YAML.load(erb.result)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|