singleton-client-test 0.7.7.2 → 0.7.7.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,15 +1,25 @@
1
1
  # Copyright 2022 VMware, Inc.
2
2
  # SPDX-License-Identifier: EPL-2.0
3
3
 
4
+ require 'forwardable'
4
5
  require_relative 'singleton-ruby'
5
6
 
6
7
  module Sgtn # :nodoc:
7
- # load configuration from a file
8
- def self.load_config(*args)
9
- SgtnClient.load(*args)
10
- end
8
+ class << self
9
+ extend Forwardable
10
+
11
+ # load configurations from a file
12
+ def load_config(config_file, env)
13
+ SgtnClient.load(config_file, env)
14
+ end
11
15
 
12
- extend SgtnClient::Translation::Implementation
16
+ def_delegator SgtnClient::Config, :instance, :config
17
+ delegate %i[translate t get_translations locale locale=] => SgtnClient::Translation,
18
+ %i[logger product_name version vip_server translation_bundle
19
+ source_bundle cache_expiry_period log_file log_level].flat_map { |m|
20
+ [m, "#{m}=".to_sym]
21
+ } => :config
22
+ end
13
23
 
14
- private_class_method :getString, :getString_p, :getString_f, :getStrings
24
+ I18nBackend = SgtnClient::I18nBackend
15
25
  end
@@ -1,8 +1,7 @@
1
1
  # Copyright 2022 VMware, Inc.
2
2
  # SPDX-License-Identifier: EPL-2.0
3
3
 
4
- require "sgtn-client/sgtn-client"
5
- require 'sgtn-client/cldr/core_ext'
6
4
  require 'twitter_cldr'
5
+ require 'sgtn-client/cldr/core_ext'
7
6
 
8
- require 'sgtn-client/exceptions.rb'
7
+ require 'sgtn-client/sgtn-client'
metadata CHANGED
@@ -1,79 +1,59 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: singleton-client-test
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.7.2
4
+ version: 0.7.7.5
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-07-07 00:00:00.000000000 Z
11
+ date: 2022-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rdoc
14
+ name: concurrent-ruby
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 2.4.2
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: '6.0'
23
- type: :development
19
+ version: '0'
20
+ type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
24
  - - ">="
28
25
  - !ruby/object:Gem::Version
29
- version: 2.4.2
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: '6.0'
33
- - !ruby/object:Gem::Dependency
34
- name: rspec
35
- requirement: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - "~>"
38
- - !ruby/object:Gem::Version
39
- version: '3.0'
40
- type: :development
41
- prerelease: false
42
- version_requirements: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - "~>"
45
- - !ruby/object:Gem::Version
46
- version: '3.0'
26
+ version: '0'
47
27
  - !ruby/object:Gem::Dependency
48
- name: rubocop
28
+ name: faraday
49
29
  requirement: !ruby/object:Gem::Requirement
50
30
  requirements:
51
31
  - - "~>"
52
32
  - !ruby/object:Gem::Version
53
- version: '0.49'
54
- type: :development
33
+ version: '1.10'
34
+ type: :runtime
55
35
  prerelease: false
56
36
  version_requirements: !ruby/object:Gem::Requirement
57
37
  requirements:
58
38
  - - "~>"
59
39
  - !ruby/object:Gem::Version
60
- version: '0.49'
40
+ version: '1.10'
61
41
  - !ruby/object:Gem::Dependency
62
- name: webmock
42
+ name: faraday_middleware
63
43
  requirement: !ruby/object:Gem::Requirement
64
44
  requirements:
65
45
  - - "~>"
66
46
  - !ruby/object:Gem::Version
67
- version: '2.0'
68
- type: :development
47
+ version: '1.2'
48
+ type: :runtime
69
49
  prerelease: false
70
50
  version_requirements: !ruby/object:Gem::Requirement
71
51
  requirements:
72
52
  - - "~>"
73
53
  - !ruby/object:Gem::Version
74
- version: '2.0'
54
+ version: '1.2'
75
55
  - !ruby/object:Gem::Dependency
76
- name: faraday
56
+ name: i18n
77
57
  requirement: !ruby/object:Gem::Requirement
78
58
  requirements:
79
59
  - - ">="
@@ -87,7 +67,7 @@ dependencies:
87
67
  - !ruby/object:Gem::Version
88
68
  version: '0'
89
69
  - !ruby/object:Gem::Dependency
90
- name: faraday_middleware
70
+ name: lumberjack
91
71
  requirement: !ruby/object:Gem::Requirement
92
72
  requirements:
93
73
  - - ">="
@@ -118,16 +98,16 @@ dependencies:
118
98
  name: request_store
119
99
  requirement: !ruby/object:Gem::Requirement
120
100
  requirements:
121
- - - ">="
101
+ - - "~>"
122
102
  - !ruby/object:Gem::Version
123
- version: '0'
103
+ version: '1.0'
124
104
  type: :runtime
125
105
  prerelease: false
126
106
  version_requirements: !ruby/object:Gem::Requirement
127
107
  requirements:
128
- - - ">="
108
+ - - "~>"
129
109
  - !ruby/object:Gem::Version
130
- version: '0'
110
+ version: '1.0'
131
111
  - !ruby/object:Gem::Dependency
132
112
  name: twitter_cldr
133
113
  requirement: !ruby/object:Gem::Requirement
@@ -158,14 +138,15 @@ files:
158
138
  - lib/sgtn-client/cldr/localized_datetime.rb
159
139
  - lib/sgtn-client/cldr/localized_str.rb
160
140
  - lib/sgtn-client/cldr/localized_time.rb
141
+ - lib/sgtn-client/common.rb
161
142
  - lib/sgtn-client/common/data.rb
162
143
  - lib/sgtn-client/common/single_operation.rb
163
- - lib/sgtn-client/core/cache.rb
164
144
  - lib/sgtn-client/core/config.rb
165
145
  - lib/sgtn-client/core/exceptions.rb
166
- - lib/sgtn-client/core/logging.rb
167
146
  - lib/sgtn-client/exceptions.rb
168
147
  - lib/sgtn-client/formatters/plurals/plural_formatter.rb
148
+ - lib/sgtn-client/i18n_backend.rb
149
+ - lib/sgtn-client/loader.rb
169
150
  - lib/sgtn-client/loader/cache.rb
170
151
  - lib/sgtn-client/loader/chain_loader.rb
171
152
  - lib/sgtn-client/loader/consts.rb
@@ -176,7 +157,6 @@ files:
176
157
  - lib/sgtn-client/loader/source.rb
177
158
  - lib/sgtn-client/loader/source_comparer.rb
178
159
  - lib/sgtn-client/sgtn-client.rb
179
- - lib/sgtn-client/util/cache-util.rb
180
160
  - lib/sgtn-client/util/locale-util.rb
181
161
  - lib/sgtn-client/util/string-util.rb
182
162
  - lib/sgtn-client/util/validate-util.rb
@@ -1,34 +0,0 @@
1
- # Copyright 2022 VMware, Inc.
2
- # SPDX-License-Identifier: EPL-2.0
3
-
4
- require 'date'
5
-
6
- module SgtnClient::Core
7
- class Cache
8
- Entry = Struct.new(:expiry, :items)
9
-
10
- def self.initialize(disabled=false, opts={})
11
- @@opts = opts
12
- SgtnClient.logger.debug "[Cache][initialize] Disable cache? #{disabled}"
13
- @@data = Hash.new
14
- end
15
-
16
- def self.get(key)
17
- SgtnClient.logger.debug "[Cache][get]get cache for key: " + key
18
- return @@data&.dig(key)
19
- end
20
-
21
- def self.put(key, items, ttl=nil)
22
- ttl ||= @@opts[:ttl]
23
- # hours from new
24
- SgtnClient.logger.debug "[Cache][put]put cache for key '" + key + "' with expired time at'" + (Time.now + ttl*60).to_s
25
- @@data[key] = Entry.new(Time.now + ttl*60, items)
26
- end
27
-
28
- def self.clear
29
- SgtnClient.logger.debug "[Cache][clear]clear cache!"
30
- @@data = Hash.new
31
- end
32
- end
33
-
34
- end
@@ -1,52 +0,0 @@
1
- # Copyright 2022 VMware, Inc.
2
- # SPDX-License-Identifier: EPL-2.0
3
-
4
- require 'logger'
5
-
6
- module SgtnClient
7
-
8
- # Include Logging module to provide logger functionality.
9
- # == Configure logger
10
- # Logging.logger = Logger.new(STDERR)
11
- #
12
- # == Example
13
- # include Logger
14
- # logger.info "Debug message"
15
- module Logging
16
-
17
- # Get logger object
18
- def logger
19
- @logger ||= Logging.logger
20
- end
21
-
22
- def log_event(message, &block)
23
- start_time = Time.now
24
- block.call
25
- ensure
26
- logger.info sprintf("[%.3fs] %s", Time.now - start_time, message)
27
- end
28
-
29
- class << self
30
-
31
- # Get or Create configured logger based on the default environment configuration
32
- def logger
33
- @logger ||= Logger.new(STDERR)
34
- end
35
-
36
- # Set logger directly and clear the loggers cache.
37
- # === Attributes
38
- # * <tt>logger</tt> -- Logger object
39
- # === Example
40
- # Logging.logger = Logger.new(STDERR)
41
- def logger=(logger)
42
- @logger = logger
43
- if Config.config.mode.eql? 'live' and @logger.level == Logger::DEBUG
44
- @logger.warn "DEBUG log level not allowed in live mode for security of confidential information. Changing log level to INFO..."
45
- @logger.level = Logger::INFO
46
- end
47
- end
48
-
49
- end
50
- end
51
-
52
- end
@@ -1,40 +0,0 @@
1
- # Copyright 2022 VMware, Inc.
2
- # SPDX-License-Identifier: EPL-2.0
3
-
4
- module SgtnClient
5
- module Core
6
- autoload :Cache, 'sgtn-client/core/cache'
7
- end
8
-
9
- class CacheUtil
10
- def self.get_cache(cache_key)
11
- SgtnClient::Core::Cache.get(cache_key)
12
- end
13
-
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?
20
-
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