singleton-ruby 0.0.4 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -2
- data/README.md +3 -0
- data/lib/sgtn-client/api/source.rb +2 -3
- data/lib/sgtn-client/api/translation.rb +5 -5
- data/lib/sgtn-client/core/cache.rb +43 -4
- data/lib/sgtn-client/core/config.rb +1 -1
- data/lib/sgtn-client/sgtn-client.rb +11 -3
- data/lib/sgtn-client/util/cache-util.rb +8 -3
- data/lib/sgtn-client/util/validate-util.rb +44 -0
- data/lib/version.rb +1 -1
- data/spec/config/locales/l10n/bundles/logInsight/4.8.1/JAVA/messages_en.json +1 -0
- data/spec/config/locales/l10n/bundles/logInsight/4.8.1/JAVA/messages_zh_CN.json +11 -0
- data/spec/config/sgtnclient-invalidate.yml +48 -0
- data/spec/config/sgtnclient.yml +8 -2
- data/spec/spec_helper.rb +1 -0
- data/spec/unit/cache_spec.rb +35 -0
- data/spec/unit/inconfig_spec.rb +17 -0
- data/spec/unit/offclient_spec.rb +7 -1
- metadata +54 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2e9bf60e2c6e5a1c59e1d0b25a9acb3d7f645c08aab5365d725895bd5a0c5f0
|
4
|
+
data.tar.gz: 54d2803ac84376f0df6223d9aa3d4eb1a553f8b93214acc1591c95566de5346d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e8775d0142dddcfef46c2ba781ed0885f16854fccab273f2483f1fbd0e6744cc1a360d569f3e32c92acc40ebd001864c45448eeaa70443095952a81eab79b2d
|
7
|
+
data.tar.gz: 3b009b345f63e0c97fcbe983b15673ea82199264fef1135ac3e0922677bf07fd1695ba5c011ad5932730266cb08228dccb5d5ff68670289df80ae98f146a13cd
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -28,7 +28,7 @@ module SgtnClient
|
|
28
28
|
def self.loadBundles(locale)
|
29
29
|
env = SgtnClient::Config.default_environment
|
30
30
|
source_bundle = SgtnClient::Config.configurations[env]["source_bundle"]
|
31
|
-
SgtnClient.logger.debug "Loading bundles from path: " + source_bundle
|
31
|
+
SgtnClient.logger.debug "Loading [" + locale + "] bundles from path: " + source_bundle
|
32
32
|
Dir.children(source_bundle).each do |component|
|
33
33
|
yamlfile = File.join(source_bundle, component + "/" + locale + ".yml")
|
34
34
|
bundle = read_yml(yamlfile)
|
@@ -46,8 +46,7 @@ module SgtnClient
|
|
46
46
|
bundlepath = source_bundle + "/" + component + "/en.yml"
|
47
47
|
SgtnClient.logger.debug "Getting source from bundle: " + bundlepath
|
48
48
|
begin
|
49
|
-
bundle =
|
50
|
-
puts bundle
|
49
|
+
bundle = read_yml(bundlepath)
|
51
50
|
rescue => exception
|
52
51
|
SgtnClient.logger.error exception.message
|
53
52
|
end
|
@@ -20,10 +20,10 @@ module SgtnClient
|
|
20
20
|
SgtnClient.logger.debug "Getting translations from cache with key: " + cache_key
|
21
21
|
end
|
22
22
|
if items.nil?
|
23
|
-
return key
|
23
|
+
return SgtnClient::Source.getSource(component, key)
|
24
24
|
end
|
25
|
-
str = items["messages"][key]
|
26
25
|
|
26
|
+
str = items["messages"][key]
|
27
27
|
if str.nil?
|
28
28
|
return SgtnClient::Source.getSource(component, key)
|
29
29
|
else
|
@@ -47,9 +47,9 @@ module SgtnClient
|
|
47
47
|
def self.get_offbundle(component, locale)
|
48
48
|
env = SgtnClient::Config.default_environment
|
49
49
|
product_name = SgtnClient::Config.configurations[env]["product_name"]
|
50
|
-
version = SgtnClient::Config.configurations[env]["version"]
|
50
|
+
version = SgtnClient::Config.configurations[env]["version"].to_s
|
51
51
|
translation_bundle = SgtnClient::Config.configurations[env]["translation_bundle"]
|
52
|
-
bundlepath = translation_bundle + product_name + "/" + version + "/" + component + "/messages_" + locale + ".json"
|
52
|
+
bundlepath = translation_bundle + "/" + product_name + "/" + version + "/" + component + "/messages_" + locale + ".json"
|
53
53
|
SgtnClient.logger.debug "Getting translations from offline bundle: " + bundlepath
|
54
54
|
begin
|
55
55
|
file = File.read(bundlepath)
|
@@ -65,7 +65,7 @@ module SgtnClient
|
|
65
65
|
product_name = SgtnClient::Config.configurations[env]["product_name"]
|
66
66
|
vip_server = SgtnClient::Config.configurations[env]["vip_server"]
|
67
67
|
SgtnClient.logger.debug "Getting translations from server: " + vip_server
|
68
|
-
version = SgtnClient::Config.configurations[env]["version"]
|
68
|
+
version = SgtnClient::Config.configurations[env]["version"].to_s
|
69
69
|
url = vip_server + "/i18n/api/v2/translation/products/" + product_name + "/versions/" + version + "/locales/" + locale + "/components/" + component+ "?checkTranslationStatus=false&machineTranslation=false&pseudo=false"
|
70
70
|
begin
|
71
71
|
obj = SgtnClient::Core::Request.get(url)
|
@@ -4,39 +4,78 @@ module SgtnClient::Core
|
|
4
4
|
class Cache
|
5
5
|
Entry = Struct.new(:expiry, :value)
|
6
6
|
|
7
|
-
def self.initialize(opts={})
|
8
|
-
$data = Hash.new
|
7
|
+
def self.initialize(disabled=false, opts={})
|
9
8
|
$opts = opts
|
9
|
+
SgtnClient.logger.debug "Initialize cache......"
|
10
|
+
if disabled == false
|
11
|
+
$data = Hash.new
|
12
|
+
SgtnClient.logger.debug "Cache is enabled!"
|
13
|
+
else
|
14
|
+
SgtnClient.logger.debug "Cache is disabled!"
|
15
|
+
end
|
10
16
|
end
|
11
17
|
|
12
18
|
def self.keys
|
19
|
+
if $data == nil
|
20
|
+
return nil
|
21
|
+
end
|
22
|
+
SgtnClient.logger.debug "Get cache keys"
|
13
23
|
$data.keys
|
14
24
|
end
|
15
25
|
|
16
26
|
def self.get(key)
|
27
|
+
if $data == nil
|
28
|
+
return nil
|
29
|
+
end
|
30
|
+
SgtnClient.logger.debug "Get cache for key: " + key
|
31
|
+
invalidate
|
17
32
|
$data[key][:value] if has(key)
|
18
33
|
end
|
19
34
|
|
20
35
|
def self.has(key)
|
36
|
+
if $data == nil
|
37
|
+
return nil
|
38
|
+
end
|
39
|
+
SgtnClient.logger.debug "Has cache for key: " + key
|
21
40
|
$data.has_key? key
|
22
41
|
end
|
23
42
|
|
24
43
|
def self.put(key, value, ttl=nil)
|
44
|
+
if $data == nil
|
45
|
+
return nil
|
46
|
+
end
|
25
47
|
ttl ||= @opts[:ttl]
|
26
48
|
# hours from new
|
27
|
-
|
49
|
+
SgtnClient.logger.debug "Put cache for key '" + key + "' with expired time at'" + (Time.now + ttl*60).to_s
|
50
|
+
$data[key] = Entry.new(Time.now + ttl*60, value)
|
28
51
|
end
|
29
52
|
|
30
53
|
def self.delete(key)
|
54
|
+
if $data == nil
|
55
|
+
return nil
|
56
|
+
end
|
57
|
+
SgtnClient.logger.debug "Delete cache for key: " + key
|
31
58
|
$data.delete key
|
32
59
|
end
|
33
60
|
|
34
61
|
def self.clear
|
62
|
+
if $data == nil
|
63
|
+
return nil
|
64
|
+
end
|
65
|
+
SgtnClient.logger.debug "Clear cache!"
|
35
66
|
$data = Hash.new
|
36
67
|
end
|
37
68
|
|
38
69
|
def self.invalidate
|
39
|
-
|
70
|
+
if $data == nil
|
71
|
+
return nil
|
72
|
+
end
|
73
|
+
SgtnClient.logger.debug "Invalidating expired cache......"
|
74
|
+
now = Time.now
|
75
|
+
$data.each {
|
76
|
+
|k, v|
|
77
|
+
SgtnClient.logger.debug "Checking cache: key=#{k}, expiredtime=#{v[:expiry]}, now=#{now}, expired=#{(v[:expiry] < now)}"
|
78
|
+
}
|
40
79
|
$data.delete_if {|k, v| v[:expiry] < now}
|
41
80
|
end
|
42
81
|
end
|
@@ -40,7 +40,7 @@ module SgtnClient
|
|
40
40
|
:rest_endpoint, :rest_token_endpoint, :client_id, :client_secret,
|
41
41
|
:openid_endpoint, :openid_redirect_uri, :openid_client_id, :openid_client_secret,
|
42
42
|
:verbose_logging, :product_name, :version, :vip_server, :bundle_mode,
|
43
|
-
:translation_bundle, :source_bundle
|
43
|
+
:translation_bundle, :source_bundle, :cache_expiry_period, :disable_cache
|
44
44
|
|
45
45
|
|
46
46
|
# Create Config object
|
@@ -1,12 +1,14 @@
|
|
1
1
|
module SgtnClient
|
2
2
|
module Core
|
3
|
-
autoload :Cache,
|
3
|
+
autoload :Cache, "sgtn-client/core/cache"
|
4
4
|
end
|
5
|
+
|
5
6
|
autoload :Translation, "sgtn-client/api/translation"
|
6
7
|
autoload :Source, "sgtn-client/api/source"
|
7
8
|
autoload :Config, "sgtn-client/core/config"
|
8
9
|
autoload :Logging, "sgtn-client/core/logging"
|
9
10
|
autoload :Exceptions, "sgtn-client/core/exceptions"
|
11
|
+
autoload :ValidateUtil, "sgtn-client/util/validate-util"
|
10
12
|
|
11
13
|
class << self
|
12
14
|
def configure(options = {}, &block)
|
@@ -18,6 +20,7 @@ module SgtnClient
|
|
18
20
|
# load configuration file
|
19
21
|
begin
|
20
22
|
SgtnClient::Config.load(args[0], args[1])
|
23
|
+
SgtnClient::ValidateUtil.validate_config()
|
21
24
|
rescue => exception
|
22
25
|
file = File.open('./error.log', 'a')
|
23
26
|
file.sync = true
|
@@ -45,7 +48,12 @@ module SgtnClient
|
|
45
48
|
end
|
46
49
|
|
47
50
|
# initialize cache
|
48
|
-
SgtnClient::
|
51
|
+
disable_cache = SgtnClient::Config.configurations[env]["disable_cache"]
|
52
|
+
if disable_cache != nil
|
53
|
+
SgtnClient::Core::Cache.initialize(disable_cache)
|
54
|
+
else
|
55
|
+
SgtnClient::Core::Cache.initialize()
|
56
|
+
end
|
49
57
|
end
|
50
58
|
|
51
59
|
def logger
|
@@ -57,4 +65,4 @@ module SgtnClient
|
|
57
65
|
end
|
58
66
|
end
|
59
67
|
|
60
|
-
end
|
68
|
+
end
|
@@ -8,21 +8,26 @@ module SgtnClient
|
|
8
8
|
end
|
9
9
|
|
10
10
|
class CacheUtil
|
11
|
-
|
11
|
+
|
12
12
|
def self.get_cache(cache_key)
|
13
13
|
items = SgtnClient::Core::Cache.get(cache_key)
|
14
14
|
return items
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.write_cache(cache_key, items)
|
18
|
+
env = SgtnClient::Config.default_environment
|
19
|
+
cache_expiry_period = SgtnClient::Config.configurations[env]["cache_expiry_period"]
|
18
20
|
# expired after 24 hours
|
19
|
-
|
21
|
+
if cache_expiry_period == nil
|
22
|
+
cache_expiry_period = 24*60
|
23
|
+
end
|
24
|
+
SgtnClient::Core::Cache.put(cache_key, items, cache_expiry_period)
|
20
25
|
end
|
21
26
|
|
22
27
|
def self.get_cachekey(component, locale)
|
23
28
|
env = SgtnClient::Config.default_environment
|
24
29
|
product_name = SgtnClient::Config.configurations[env]["product_name"]
|
25
|
-
version = SgtnClient::Config.configurations[env]["version"]
|
30
|
+
version = SgtnClient::Config.configurations[env]["version"].to_s
|
26
31
|
return product_name + "_" + version + "_" + component + "_" + locale
|
27
32
|
end
|
28
33
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
|
2
|
+
module SgtnClient
|
3
|
+
|
4
|
+
class ValidateUtil
|
5
|
+
|
6
|
+
def self.validate_config()
|
7
|
+
SgtnClient.logger.debug "-----------Start to validate configuration's setting itmes-----------"
|
8
|
+
env = SgtnClient::Config.default_environment
|
9
|
+
messages = "\n"
|
10
|
+
|
11
|
+
mode = SgtnClient::Config.configurations[env]["mode"]
|
12
|
+
if mode != 'sandbox' && mode != 'live'
|
13
|
+
messages = messages + "Configuration[mode] has to be 'sandbox' or 'live'!\n"
|
14
|
+
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
|
+
|
21
|
+
#version = SgtnClient::Config.configurations[env]["version"]
|
22
|
+
#if version.is_a? Integer
|
23
|
+
#messages = messages + "Configuration[version] has to be standard as '#.#.#, e.g '1.0.0'!\n"
|
24
|
+
#end
|
25
|
+
|
26
|
+
cache_expiry_period = SgtnClient::Config.configurations[env]["cache_expiry_period"]
|
27
|
+
if cache_expiry_period != nil && (cache_expiry_period.is_a? Integer) == false
|
28
|
+
messages = messages + "Configuration[cache_expiry_period] has to be a number!\n"
|
29
|
+
end
|
30
|
+
|
31
|
+
disable_cache = SgtnClient::Config.configurations[env]["disable_cache"]
|
32
|
+
if disable_cache != nil && disable_cache != false && disable_cache != true
|
33
|
+
messages = messages + "Configuration[disable_cache] has to be a 'true' or 'false'!\n"
|
34
|
+
end
|
35
|
+
|
36
|
+
if messages != "\n"
|
37
|
+
raise SgtnClient::Exceptions::MissingConfig.new(messages)
|
38
|
+
end
|
39
|
+
SgtnClient.logger.debug "-----------End to validate configuration's setting itmes-----------"
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
data/lib/version.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"component" : "JAVA",
|
3
3
|
"messages" : {
|
4
|
+
"hello": "@hello@",
|
4
5
|
"com.vmware.loginsight.web.settings.stats.StatsTable.host" : "Host",
|
5
6
|
"com.vmware.loginsight.web.settings.stats.StatsTableType.eventsIngestionRatePerSecond" : "Events Ingestion Rate (Per Second)",
|
6
7
|
"com.vmware.loginsight.web.settings.stats.StatsTableType.eventsIngestionRatePerSecond.help" : "The actual ingestion rate (syslog + API) of each node after message rebalancing.<br />Log Insight nodes will rebalance messages to attempt uniform ingestion per node for balanced retention and performance.<br /><br />Note that the ingestion rate of each node must be below the ingestion rate configuration maximum for a node.<br /><br />For the actual rate of events being sent directly to each node prior to message rebalancing, see the Syslog Events Incoming Rate (Per Second) and API Events Incoming Rate (Per Second) tables below.",
|
@@ -0,0 +1,11 @@
|
|
1
|
+
{
|
2
|
+
"component" : "JAVA",
|
3
|
+
"messages" : {
|
4
|
+
"com.vmware.loginsight.web.settings.stats.StatsTable.host" : "主机",
|
5
|
+
"com.vmware.loginsight.web.settings.stats.StatsTableType.eventsIngestionRatePerSecond" : "事件载入速率 (每秒)",
|
6
|
+
"com.vmware.loginsight.web.settings.stats.StatsTableType.eventsIngestionRatePerSecond.help" : "消息再平衡之后每个节点的实际载入速率 (syslog + API)。<br />Log Insight 节点将再平衡消息以尝试每节点的统一载入,从而实现平衡保留和性能。<br /><br />请注意,每个节点的载入速率必须低于配置的最大节点载入速率。<br /><br />有关消息再平衡之前直接发送到每个节点的事件的实际速率,请参见下述“Syslog 事件入站速率 (每秒)”和“API 事件入站速率 (每秒)”表。",
|
7
|
+
"com.vmware.loginsight.web.settings.stats.StatsTableType.syslogEventsIncomingRatePerSecond" : "Syslog 事件入站速率 (每秒)",
|
8
|
+
"com.vmware.loginsight.web.utilities.EmailUtil.upgrade.body48" : "{0} 现在正在运行版本 {1}。下面是 {1} 版本中新增的一些出色功能。我们感谢您一如既往地支持,同时非常重视您通过 Twitter 针对我们的 {3} 和 {4} 提供的反馈。<br /><br /><b>vRealize Log Insight 服务器功能</b><br />• TODO 增加服务器功能。<br /><br /><b>vRealize Log Insight 代理功能</b><br />• TODO 增加代理功能。<br /><br />有关 {0} 的新功能的详细信息,请查看 {0} v{1} {2}。<br /><br />祝您使用愉快!<br />{0} 团队<br /><br />"
|
9
|
+
},
|
10
|
+
"locale" : "zh-Hans"
|
11
|
+
}
|
@@ -0,0 +1,48 @@
|
|
1
|
+
test: &default
|
2
|
+
|
3
|
+
# Credentials for REST APIs
|
4
|
+
client_id: tee
|
5
|
+
client_secret: 89987
|
6
|
+
|
7
|
+
# Mode can be 'live' or 'sandbox'
|
8
|
+
mode: sandbox1
|
9
|
+
|
10
|
+
# Credentials for Classic APIs
|
11
|
+
app_id: APP-80W284485P519543T
|
12
|
+
username: linr
|
13
|
+
password: fdasf
|
14
|
+
signature: sfds-RWy
|
15
|
+
# # With Certificate
|
16
|
+
# cert_path: "config/cert_key.pem"
|
17
|
+
sandbox_email_address: linr@vmware.com
|
18
|
+
|
19
|
+
# #Product Name
|
20
|
+
product_name: logInsight
|
21
|
+
|
22
|
+
# # bundle version
|
23
|
+
version: 4.8
|
24
|
+
|
25
|
+
# # HTTP Proxy
|
26
|
+
vip_server: https://g11n-vip-dev-1.eng.vmware.com:8090
|
27
|
+
|
28
|
+
# # mode of bundle: online/offline
|
29
|
+
bundle_mode: offline1www
|
30
|
+
|
31
|
+
# # translation bundle Path
|
32
|
+
translation_bundle: ./spec/config/locales/l10n/bundles
|
33
|
+
|
34
|
+
# # source bundle Path
|
35
|
+
source_bundle: ./spec/config/locales/default
|
36
|
+
|
37
|
+
# # memory cache's expration(minutes), default value is 24*60
|
38
|
+
cache_expiry_period: 36t
|
39
|
+
|
40
|
+
# # disable cache, it's optional setting
|
41
|
+
disable_cache: true1
|
42
|
+
|
43
|
+
development:
|
44
|
+
<<: *default
|
45
|
+
|
46
|
+
production:
|
47
|
+
<<: *default
|
48
|
+
mode: live
|
data/spec/config/sgtnclient.yml
CHANGED
@@ -28,12 +28,18 @@ test: &default
|
|
28
28
|
# # mode of bundle: online/offline
|
29
29
|
bundle_mode: offline
|
30
30
|
|
31
|
-
# #
|
31
|
+
# # translation bundle Path
|
32
32
|
translation_bundle: ./spec/config/locales/l10n/bundles
|
33
33
|
|
34
|
-
# #
|
34
|
+
# # source bundle Path
|
35
35
|
source_bundle: ./spec/config/locales/default
|
36
36
|
|
37
|
+
# # memory cache's expration(minutes), default value is 24*60
|
38
|
+
cache_expiry_period: 10
|
39
|
+
|
40
|
+
# # disable cache, it's optional setting
|
41
|
+
##disable_cache: true
|
42
|
+
|
37
43
|
development:
|
38
44
|
<<: *default
|
39
45
|
|
data/spec/spec_helper.rb
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SgtnClient do
|
4
|
+
describe "Cache" do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
env = SgtnClient::Config.default_environment
|
8
|
+
SgtnClient::Config.configurations[env]["bundle_mode"] = 'online'
|
9
|
+
SgtnClient::Config.configurations[env]["cache_expiry_period"] = 1
|
10
|
+
SgtnClient::Source.loadBundles("en")
|
11
|
+
end
|
12
|
+
|
13
|
+
it "GETTranslation" do
|
14
|
+
|
15
|
+
# get translation from server
|
16
|
+
SgtnClient.logger.debug "----------Start to get translation from server---------"
|
17
|
+
expect(SgtnClient::Translation.getString("JAVA", "com.vmware.loginsight.web.settings.stats.StatsTable.host", "zh-Hans")).to eq '主机'
|
18
|
+
|
19
|
+
# get translation from cache
|
20
|
+
SgtnClient.logger.debug "----------Start to get translation from cache---------"
|
21
|
+
expect(SgtnClient::Translation.getString("JAVA", "com.vmware.loginsight.web.settings.stats.StatsTable.host", "zh-Hans")).to eq '主机'
|
22
|
+
|
23
|
+
# get from server again after data is expired
|
24
|
+
SgtnClient.logger.debug "----------Sleep 70s---------"
|
25
|
+
puts Time.now
|
26
|
+
#sleep 70
|
27
|
+
puts Time.now
|
28
|
+
SgtnClient.logger.debug "----------Start to get translation from expired cache---------"
|
29
|
+
expect(SgtnClient::Translation.getString("JAVA", "com.vmware.loginsight.web.settings.stats.StatsTable.host", "zh-Hans")).to eq '主机'
|
30
|
+
|
31
|
+
SgtnClient.logger.debug "----------End to get translation from server---------"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require_relative '../../lib/sgtn-client/sgtn-client.rb'
|
3
|
+
|
4
|
+
describe SgtnClient do
|
5
|
+
|
6
|
+
describe "loadinconfig" do
|
7
|
+
|
8
|
+
before :each do
|
9
|
+
#SgtnClient.load("./spec/config/sgtnclient-invalide.yml", "test", './sgtnclient_config.log')
|
10
|
+
end
|
11
|
+
|
12
|
+
it "validate_configuration" do
|
13
|
+
SgtnClient.load("./spec/config/sgtnclient-invalidate.yml", "test", './sgtnclient_config.log')
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
data/spec/unit/offclient_spec.rb
CHANGED
@@ -5,7 +5,7 @@ describe SgtnClient do
|
|
5
5
|
|
6
6
|
before :each do
|
7
7
|
env = SgtnClient::Config.default_environment
|
8
|
-
SgtnClient::Config.configurations[env]["bundle_mode"] = '
|
8
|
+
SgtnClient::Config.configurations[env]["bundle_mode"] = 'offline'
|
9
9
|
SgtnClient::Source.loadBundles("en")
|
10
10
|
end
|
11
11
|
|
@@ -15,6 +15,12 @@ describe SgtnClient do
|
|
15
15
|
expect(SgtnClient::Translation.getString("JAVA", "com.vmware.loginsight.web.settings.stats.StatsTable.host", "zh-Hans")).to eq '主机'
|
16
16
|
end
|
17
17
|
|
18
|
+
it "GET_zh_CN" do
|
19
|
+
expect(SgtnClient::Translation.getString("JAVA", "com.vmware.loginsight.web.settings.stats.StatsTable.host", "zh_CN")).to eq '主机'
|
20
|
+
# get from cache in 2nd time
|
21
|
+
expect(SgtnClient::Translation.getString("JAVA", "com.vmware.loginsight.web.settings.stats.StatsTable.host", "zh_CN")).to eq '主机'
|
22
|
+
end
|
23
|
+
|
18
24
|
it "NonExistingKey" do
|
19
25
|
expect(SgtnClient::Translation.getString("JAVA", "hello", "zh-Hans")).to eq 'Hello world'
|
20
26
|
# get from cache in 2nd time
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: singleton-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
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: 2021-
|
11
|
+
date: 2021-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -202,6 +202,48 @@ dependencies:
|
|
202
202
|
- - "~>"
|
203
203
|
- !ruby/object:Gem::Version
|
204
204
|
version: '0.8'
|
205
|
+
- !ruby/object:Gem::Dependency
|
206
|
+
name: rest-client
|
207
|
+
requirement: !ruby/object:Gem::Requirement
|
208
|
+
requirements:
|
209
|
+
- - "~>"
|
210
|
+
- !ruby/object:Gem::Version
|
211
|
+
version: '2.0'
|
212
|
+
type: :runtime
|
213
|
+
prerelease: false
|
214
|
+
version_requirements: !ruby/object:Gem::Requirement
|
215
|
+
requirements:
|
216
|
+
- - "~>"
|
217
|
+
- !ruby/object:Gem::Version
|
218
|
+
version: '2.0'
|
219
|
+
- !ruby/object:Gem::Dependency
|
220
|
+
name: multi_json
|
221
|
+
requirement: !ruby/object:Gem::Requirement
|
222
|
+
requirements:
|
223
|
+
- - "~>"
|
224
|
+
- !ruby/object:Gem::Version
|
225
|
+
version: '1.0'
|
226
|
+
type: :runtime
|
227
|
+
prerelease: false
|
228
|
+
version_requirements: !ruby/object:Gem::Requirement
|
229
|
+
requirements:
|
230
|
+
- - "~>"
|
231
|
+
- !ruby/object:Gem::Version
|
232
|
+
version: '1.0'
|
233
|
+
- !ruby/object:Gem::Dependency
|
234
|
+
name: twitter_cldr
|
235
|
+
requirement: !ruby/object:Gem::Requirement
|
236
|
+
requirements:
|
237
|
+
- - "~>"
|
238
|
+
- !ruby/object:Gem::Version
|
239
|
+
version: '6.6'
|
240
|
+
type: :runtime
|
241
|
+
prerelease: false
|
242
|
+
version_requirements: !ruby/object:Gem::Requirement
|
243
|
+
requirements:
|
244
|
+
- - "~>"
|
245
|
+
- !ruby/object:Gem::Version
|
246
|
+
version: '6.6'
|
205
247
|
description: A Singleton client for Ruby
|
206
248
|
email: li@vmware.com
|
207
249
|
executables: []
|
@@ -225,6 +267,7 @@ files:
|
|
225
267
|
- lib/sgtn-client/core/request.rb
|
226
268
|
- lib/sgtn-client/sgtn-client.rb
|
227
269
|
- lib/sgtn-client/util/cache-util.rb
|
270
|
+
- lib/sgtn-client/util/validate-util.rb
|
228
271
|
- lib/singleton-ruby.rb
|
229
272
|
- lib/version.rb
|
230
273
|
- spec/config/locales/default/JAVA/en.yml
|
@@ -233,14 +276,18 @@ files:
|
|
233
276
|
- spec/config/locales/l10n/bundles/logInsight/4.8.1/JAVA/messages_latest.json
|
234
277
|
- spec/config/locales/l10n/bundles/logInsight/4.8.1/JAVA/messages_zh-Hans.json
|
235
278
|
- spec/config/locales/l10n/bundles/logInsight/4.8.1/JAVA/messages_zh-Hant.json
|
279
|
+
- spec/config/locales/l10n/bundles/logInsight/4.8.1/JAVA/messages_zh_CN.json
|
236
280
|
- spec/config/locales/l10n/bundles/logInsight/4.8.1/creation.json
|
237
281
|
- spec/config/locales/l10n/bundles/logInsight/4.8.1/version.json
|
238
282
|
- spec/config/sample_data.yml
|
283
|
+
- spec/config/sgtnclient-invalidate.yml
|
239
284
|
- spec/config/sgtnclient.yml
|
240
285
|
- spec/log/http.log
|
241
286
|
- spec/spec_helper.rb
|
242
287
|
- spec/support/sample_data.rb
|
288
|
+
- spec/unit/cache_spec.rb
|
243
289
|
- spec/unit/config_spec.rb
|
290
|
+
- spec/unit/inconfig_spec.rb
|
244
291
|
- spec/unit/logging_spec.rb
|
245
292
|
- spec/unit/offclient_spec.rb
|
246
293
|
- spec/unit/restclient_spec.rb
|
@@ -264,7 +311,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
264
311
|
- !ruby/object:Gem::Version
|
265
312
|
version: '0'
|
266
313
|
requirements: []
|
267
|
-
rubygems_version: 3.
|
314
|
+
rubygems_version: 3.1.4
|
268
315
|
signing_key:
|
269
316
|
specification_version: 4
|
270
317
|
summary: Singleton client for Ruby.
|
@@ -275,14 +322,18 @@ test_files:
|
|
275
322
|
- spec/config/locales/l10n/bundles/logInsight/4.8.1/JAVA/messages_latest.json
|
276
323
|
- spec/config/locales/l10n/bundles/logInsight/4.8.1/JAVA/messages_zh-Hans.json
|
277
324
|
- spec/config/locales/l10n/bundles/logInsight/4.8.1/JAVA/messages_zh-Hant.json
|
325
|
+
- spec/config/locales/l10n/bundles/logInsight/4.8.1/JAVA/messages_zh_CN.json
|
278
326
|
- spec/config/locales/l10n/bundles/logInsight/4.8.1/creation.json
|
279
327
|
- spec/config/locales/l10n/bundles/logInsight/4.8.1/version.json
|
280
328
|
- spec/config/sample_data.yml
|
329
|
+
- spec/config/sgtnclient-invalidate.yml
|
281
330
|
- spec/config/sgtnclient.yml
|
282
331
|
- spec/log/http.log
|
283
332
|
- spec/spec_helper.rb
|
284
333
|
- spec/support/sample_data.rb
|
334
|
+
- spec/unit/cache_spec.rb
|
285
335
|
- spec/unit/config_spec.rb
|
336
|
+
- spec/unit/inconfig_spec.rb
|
286
337
|
- spec/unit/logging_spec.rb
|
287
338
|
- spec/unit/offclient_spec.rb
|
288
339
|
- spec/unit/restclient_spec.rb
|