singleton-client-test 0.7.7.3 → 0.7.7.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,32 +6,22 @@ module SgtnClient
6
6
  class ValidateUtil
7
7
 
8
8
  def self.validate_config()
9
- env = SgtnClient::Config.default_environment
10
- SgtnClient.logger.debug "[ValidateUtil][validate_config] env = #{env}"
11
- messages = "\n"
9
+ puts "validating config..."
10
+ messages = ""
12
11
 
13
- mode = SgtnClient::Config.configurations[env]["mode"]
14
- if mode != 'sandbox' && mode != 'live'
15
- messages = messages + "Configuration[mode] has to be 'sandbox' or 'live'!\n"
12
+ version = SgtnClient.config.version
13
+ SgtnClient.config.version = version.to_s
14
+ if version.to_s !~ /\A(\d+\.)*\d+\z/
15
+ messages = messages + "Configuration[version] has to be standard as '#.#.#, e.g '1.0.0'!\n"
16
16
  end
17
-
18
- #version = SgtnClient::Config.configurations[env]["version"]
19
- #if version.is_a? Integer
20
- #messages = messages + "Configuration[version] has to be standard as '#.#.#, e.g '1.0.0'!\n"
21
- #end
22
17
 
23
- cache_expiry_period = SgtnClient::Config.configurations[env]["cache_expiry_period"]
18
+ cache_expiry_period = SgtnClient.config.cache_expiry_period
24
19
  if cache_expiry_period != nil && (cache_expiry_period.is_a? Integer) == false
25
20
  messages = messages + "Configuration[cache_expiry_period] has to be a number!\n"
26
21
  end
27
-
28
- disable_cache = SgtnClient::Config.configurations[env]["disable_cache"]
29
- if disable_cache != nil && disable_cache != false && disable_cache != true
30
- messages = messages + "Configuration[disable_cache] has to be a 'true' or 'false'!\n"
31
- end
32
-
33
- if messages != "\n"
34
- raise SgtnClient::Exceptions::MissingConfig.new(messages)
22
+
23
+ if messages != ""
24
+ raise Exceptions::MissingConfig.new(messages)
35
25
  end
36
26
  end
37
27
 
@@ -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.3
4
+ version: 0.7.7.4
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-11 00:00:00.000000000 Z
11
+ date: 2022-07-12 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,16 @@ 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
144
  - lib/sgtn-client/core/cache.rb
164
145
  - lib/sgtn-client/core/config.rb
165
146
  - lib/sgtn-client/core/exceptions.rb
166
- - lib/sgtn-client/core/logging.rb
167
147
  - lib/sgtn-client/exceptions.rb
168
148
  - lib/sgtn-client/formatters/plurals/plural_formatter.rb
149
+ - lib/sgtn-client/i18n_backend.rb
150
+ - lib/sgtn-client/loader.rb
169
151
  - lib/sgtn-client/loader/cache.rb
170
152
  - lib/sgtn-client/loader/chain_loader.rb
171
153
  - lib/sgtn-client/loader/consts.rb
@@ -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