singleton-ruby 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -4
- data/lib/sgtn-client/api/translation.rb +3 -6
- data/lib/sgtn-client/core/exceptions.rb +2 -2
- data/lib/version.rb +1 -1
- metadata +4 -52
- data/Gemfile +0 -15
- data/Rakefile +0 -140
- data/spec/config/locales/default/JAVA/default.yml +0 -5
- data/spec/config/locales/l10n/bundles/test/4.8.1/JAVA/messages_de.json +0 -8
- data/spec/config/locales/l10n/bundles/test/4.8.1/JAVA/messages_en.json +0 -8
- data/spec/config/locales/l10n/bundles/test/4.8.1/JAVA/messages_latest.json +0 -8
- data/spec/config/locales/l10n/bundles/test/4.8.1/JAVA/messages_zh-Hans.json +0 -8
- data/spec/config/locales/l10n/bundles/test/4.8.1/JAVA/messages_zh-Hant.json +0 -8
- data/spec/config/locales/l10n/bundles/test/4.8.1/creation.json +0 -10
- data/spec/config/locales/l10n/bundles/test/4.8.1/version.json +0 -38
- data/spec/config/sample_data.yml +0 -3
- data/spec/config/sgtnclient-invalidate.yml +0 -44
- data/spec/config/sgtnclient.yml +0 -44
- data/spec/log/http.log +0 -0
- data/spec/spec_helper.rb +0 -33
- data/spec/support/sample_data.rb +0 -5
- data/spec/unit/cache_spec.rb +0 -34
- data/spec/unit/config_spec.rb +0 -27
- data/spec/unit/inconfig_spec.rb +0 -17
- data/spec/unit/locale_spec.rb +0 -23
- data/spec/unit/logging_spec.rb +0 -33
- data/spec/unit/offclient_spec.rb +0 -53
- data/spec/unit/onclient_spec.rb +0 -32
- data/spec/unit/request_spec.rb +0 -22
- data/spec/unit/version_spec.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a1123e189882d4867128d6933adccda07f53b44ff5b9206ef4d90d6210cc8d7
|
4
|
+
data.tar.gz: fa5d43b9fb1b15aab4008cf0d3fa6138137d96eed5eacb8b92c26c79d75f46a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe0b2657ce521442d0987728ce63993f27b928d618a55e8a9e0b020a632ae797c37fc8ad3316295c08292dc08b3d8a2a8f57a4581e2a8e143e10ecf312182e2d
|
7
|
+
data.tar.gz: 2fe5be7449a0e5bcd2fa5b9264a35bd625e8987518539f78498ba07da09c6c3269eba4bdfe703b56a932b426c9ac68ac36ad43654866970944923ee097065eb2
|
data/README.md
CHANGED
@@ -23,7 +23,7 @@ SgtnClient::Source.loadBundles(locale)
|
|
23
23
|
@Result = SgtnClient::Translation.getString(component, key, locale)
|
24
24
|
|
25
25
|
```
|
26
|
-
## API
|
26
|
+
## API Usage
|
27
27
|
|
28
28
|
### Get a string's translation
|
29
29
|
SgtnClient::Translation.getString(component, key, locale)
|
@@ -35,10 +35,9 @@ SgtnClient::Translation.getString_f(component, key, args, locale)
|
|
35
35
|
SgtnClient::Translation.getStrings(component, locale)
|
36
36
|
|
37
37
|
|
38
|
-
## API with request_store
|
38
|
+
## API Usage(with request_store)
|
39
39
|
|
40
|
-
Before call below APIs(without locale and component arguments), it requires to set the locale
|
41
|
-
and component add the initial codes.
|
40
|
+
Before call below APIs(without locale and component arguments), it requires to set the locale and component in the initial codes.
|
42
41
|
|
43
42
|
### Get a string's translation
|
44
43
|
SgtnClient::T.s(key)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'multi_json'
|
2
2
|
|
3
3
|
module SgtnClient
|
4
4
|
|
@@ -36,10 +36,7 @@ module SgtnClient
|
|
36
36
|
|
37
37
|
def self.getString_f(component, key, args, locale)
|
38
38
|
s = getString(component, key, locale)
|
39
|
-
|
40
|
-
puts SgtnClient::Config.configurations.default
|
41
|
-
puts s
|
42
|
-
return s % args
|
39
|
+
return sprintf s % args
|
43
40
|
end
|
44
41
|
|
45
42
|
def self.getStrings(component, locale)
|
@@ -82,7 +79,7 @@ module SgtnClient
|
|
82
79
|
SgtnClient.logger.debug "Getting translations from offline bundle: " + bundlepath
|
83
80
|
begin
|
84
81
|
file = File.read(bundlepath)
|
85
|
-
data_hash =
|
82
|
+
data_hash = MultiJson.load(file)
|
86
83
|
rescue => exception
|
87
84
|
SgtnClient.logger.error exception.message
|
88
85
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'multi_json'
|
2
2
|
require 'pp'
|
3
3
|
|
4
4
|
module SgtnClient
|
@@ -13,7 +13,7 @@ module SgtnClient
|
|
13
13
|
|
14
14
|
def to_s
|
15
15
|
begin
|
16
|
-
response_body =
|
16
|
+
response_body = MultiJson.load(response.body)
|
17
17
|
debug_id = response["sgtn-debug-id"]
|
18
18
|
debug_id = response["correlation-id"] if debug_id.to_s == ''
|
19
19
|
debug_id = response_body["debug_id"] if debug_id.to_s == ''
|
data/lib/version.rb
CHANGED
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.1.
|
4
|
+
version: 0.1.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: 2021-08-
|
11
|
+
date: 2021-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -237,9 +237,7 @@ extensions: []
|
|
237
237
|
extra_rdoc_files:
|
238
238
|
- README.md
|
239
239
|
files:
|
240
|
-
- Gemfile
|
241
240
|
- README.md
|
242
|
-
- Rakefile
|
243
241
|
- lib/sgtn-client/api/source.rb
|
244
242
|
- lib/sgtn-client/api/t.rb
|
245
243
|
- lib/sgtn-client/api/translation.rb
|
@@ -254,32 +252,9 @@ files:
|
|
254
252
|
- lib/sgtn-client/util/validate-util.rb
|
255
253
|
- lib/singleton-ruby.rb
|
256
254
|
- lib/version.rb
|
257
|
-
- spec/config/locales/default/JAVA/default.yml
|
258
|
-
- spec/config/locales/l10n/bundles/test/4.8.1/JAVA/messages_de.json
|
259
|
-
- spec/config/locales/l10n/bundles/test/4.8.1/JAVA/messages_en.json
|
260
|
-
- spec/config/locales/l10n/bundles/test/4.8.1/JAVA/messages_latest.json
|
261
|
-
- spec/config/locales/l10n/bundles/test/4.8.1/JAVA/messages_zh-Hans.json
|
262
|
-
- spec/config/locales/l10n/bundles/test/4.8.1/JAVA/messages_zh-Hant.json
|
263
|
-
- spec/config/locales/l10n/bundles/test/4.8.1/creation.json
|
264
|
-
- spec/config/locales/l10n/bundles/test/4.8.1/version.json
|
265
|
-
- spec/config/sample_data.yml
|
266
|
-
- spec/config/sgtnclient-invalidate.yml
|
267
|
-
- spec/config/sgtnclient.yml
|
268
|
-
- spec/log/http.log
|
269
|
-
- spec/spec_helper.rb
|
270
|
-
- spec/support/sample_data.rb
|
271
|
-
- spec/unit/cache_spec.rb
|
272
|
-
- spec/unit/config_spec.rb
|
273
|
-
- spec/unit/inconfig_spec.rb
|
274
|
-
- spec/unit/locale_spec.rb
|
275
|
-
- spec/unit/logging_spec.rb
|
276
|
-
- spec/unit/offclient_spec.rb
|
277
|
-
- spec/unit/onclient_spec.rb
|
278
|
-
- spec/unit/request_spec.rb
|
279
|
-
- spec/unit/version_spec.rb
|
280
255
|
homepage: https://github.com/vmware/singleton
|
281
256
|
licenses:
|
282
|
-
- EPL
|
257
|
+
- EPL 2.0
|
283
258
|
metadata: {}
|
284
259
|
post_install_message:
|
285
260
|
rdoc_options: []
|
@@ -300,27 +275,4 @@ rubygems_version: 3.0.9
|
|
300
275
|
signing_key:
|
301
276
|
specification_version: 4
|
302
277
|
summary: Singleton Ruby client
|
303
|
-
test_files:
|
304
|
-
- spec/config/locales/default/JAVA/default.yml
|
305
|
-
- spec/config/locales/l10n/bundles/test/4.8.1/JAVA/messages_de.json
|
306
|
-
- spec/config/locales/l10n/bundles/test/4.8.1/JAVA/messages_en.json
|
307
|
-
- spec/config/locales/l10n/bundles/test/4.8.1/JAVA/messages_latest.json
|
308
|
-
- spec/config/locales/l10n/bundles/test/4.8.1/JAVA/messages_zh-Hans.json
|
309
|
-
- spec/config/locales/l10n/bundles/test/4.8.1/JAVA/messages_zh-Hant.json
|
310
|
-
- spec/config/locales/l10n/bundles/test/4.8.1/creation.json
|
311
|
-
- spec/config/locales/l10n/bundles/test/4.8.1/version.json
|
312
|
-
- spec/config/sample_data.yml
|
313
|
-
- spec/config/sgtnclient-invalidate.yml
|
314
|
-
- spec/config/sgtnclient.yml
|
315
|
-
- spec/log/http.log
|
316
|
-
- spec/spec_helper.rb
|
317
|
-
- spec/support/sample_data.rb
|
318
|
-
- spec/unit/cache_spec.rb
|
319
|
-
- spec/unit/config_spec.rb
|
320
|
-
- spec/unit/inconfig_spec.rb
|
321
|
-
- spec/unit/locale_spec.rb
|
322
|
-
- spec/unit/logging_spec.rb
|
323
|
-
- spec/unit/offclient_spec.rb
|
324
|
-
- spec/unit/onclient_spec.rb
|
325
|
-
- spec/unit/request_spec.rb
|
326
|
-
- spec/unit/version_spec.rb
|
278
|
+
test_files: []
|
data/Gemfile
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
source "https://rubygems.org"
|
2
|
-
|
3
|
-
if !!File::ALT_SEPARATOR
|
4
|
-
gemspec :name => 'singleton-ruby.windows'
|
5
|
-
else
|
6
|
-
gemspec :name => 'singleton-ruby'
|
7
|
-
end
|
8
|
-
|
9
|
-
gem 'rake', :require => false
|
10
|
-
|
11
|
-
group :test do
|
12
|
-
gem 'simplecov', :require => false
|
13
|
-
gem 'rspec'
|
14
|
-
gem 'webmock'
|
15
|
-
end
|
data/Rakefile
DELETED
@@ -1,140 +0,0 @@
|
|
1
|
-
# load `rake build/install/release tasks'
|
2
|
-
require 'bundler/setup'
|
3
|
-
require_relative './lib/version'
|
4
|
-
|
5
|
-
namespace :ruby do
|
6
|
-
Bundler::GemHelper.install_tasks(:name => 'singleton-ruby')
|
7
|
-
end
|
8
|
-
|
9
|
-
require "rspec/core/rake_task"
|
10
|
-
|
11
|
-
desc "Run all specs"
|
12
|
-
RSpec::Core::RakeTask.new('spec')
|
13
|
-
|
14
|
-
desc "Run unit specs"
|
15
|
-
RSpec::Core::RakeTask.new('spec:unit') do |t|
|
16
|
-
t.pattern = 'spec/unit/*_spec.rb'
|
17
|
-
end
|
18
|
-
|
19
|
-
desc "Run integration specs"
|
20
|
-
RSpec::Core::RakeTask.new('spec:integration') do |t|
|
21
|
-
t.pattern = 'spec/integration/*_spec.rb'
|
22
|
-
end
|
23
|
-
|
24
|
-
desc "Print specdocs"
|
25
|
-
RSpec::Core::RakeTask.new(:doc) do |t|
|
26
|
-
t.rspec_opts = ["--format", "specdoc", "--dry-run"]
|
27
|
-
t.pattern = 'spec/**/*_spec.rb'
|
28
|
-
end
|
29
|
-
|
30
|
-
desc "Run all examples with RCov"
|
31
|
-
RSpec::Core::RakeTask.new('rcov') do |t|
|
32
|
-
t.pattern = 'spec/*_spec.rb'
|
33
|
-
t.rcov = true
|
34
|
-
t.rcov_opts = ['--exclude', 'examples']
|
35
|
-
end
|
36
|
-
|
37
|
-
desc 'Regenerate authors file'
|
38
|
-
task :authors do
|
39
|
-
Dir.chdir(File.dirname(__FILE__)) do
|
40
|
-
File.open('AUTHORS', 'w') do |f|
|
41
|
-
f.write <<-EOM
|
42
|
-
The Ruby REST Client would not be what it is today without the help of
|
43
|
-
the following kind souls:
|
44
|
-
|
45
|
-
EOM
|
46
|
-
end
|
47
|
-
|
48
|
-
sh 'git shortlog -s | cut -f 2 >> AUTHORS'
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
task :default do
|
53
|
-
sh 'rake -T'
|
54
|
-
end
|
55
|
-
|
56
|
-
def alias_task(alias_task, original)
|
57
|
-
desc "Alias for rake #{original}"
|
58
|
-
task alias_task, Rake.application[original].arg_names => original
|
59
|
-
end
|
60
|
-
alias_task(:test, :spec)
|
61
|
-
|
62
|
-
############################
|
63
|
-
|
64
|
-
WindowsPlatforms = %w{x86-mingw32 x64-mingw32 x86-mswin32}
|
65
|
-
|
66
|
-
namespace :all do
|
67
|
-
|
68
|
-
desc "Build rest-client #{VERSION} for all platforms"
|
69
|
-
task :build => ['ruby:build'] + \
|
70
|
-
WindowsPlatforms.map {|p| "windows:#{p}:build"}
|
71
|
-
|
72
|
-
desc "Create tag v#{VERSION} and for all platforms build and " \
|
73
|
-
"push rest-client #{VERSION} to Rubygems"
|
74
|
-
task :release => ['build', 'ruby:release'] + \
|
75
|
-
WindowsPlatforms.map {|p| "windows:#{p}:push"}
|
76
|
-
|
77
|
-
end
|
78
|
-
|
79
|
-
namespace :windows do
|
80
|
-
spec_path = File.join(File.dirname(__FILE__), 'rest-client.windows.gemspec')
|
81
|
-
|
82
|
-
WindowsPlatforms.each do |platform|
|
83
|
-
namespace platform do
|
84
|
-
gem_filename = "rest-client-#{VERSION}-#{platform}.gem"
|
85
|
-
base = File.dirname(__FILE__)
|
86
|
-
pkg_dir = File.join(base, 'pkg')
|
87
|
-
gem_file_path = File.join(pkg_dir, gem_filename)
|
88
|
-
|
89
|
-
desc "Build #{gem_filename} into the pkg directory"
|
90
|
-
task 'build' do
|
91
|
-
orig_platform = ENV['BUILD_PLATFORM']
|
92
|
-
begin
|
93
|
-
ENV['BUILD_PLATFORM'] = platform
|
94
|
-
|
95
|
-
sh("gem build -V #{spec_path}") do |ok, res|
|
96
|
-
if ok
|
97
|
-
FileUtils.mkdir_p(pkg_dir)
|
98
|
-
FileUtils.mv(File.join(base, gem_filename), pkg_dir)
|
99
|
-
Bundler.ui.confirm("rest-client #{VERSION} " \
|
100
|
-
"built to pkg/#{gem_filename}")
|
101
|
-
else
|
102
|
-
abort "Command `gem build` failed: #{res}"
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
ensure
|
107
|
-
ENV['BUILD_PLATFORM'] = orig_platform
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
desc "Push #{gem_filename} to Rubygems"
|
112
|
-
task 'push' do
|
113
|
-
sh("gem push #{gem_file_path}")
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
end
|
119
|
-
|
120
|
-
############################
|
121
|
-
|
122
|
-
require 'rdoc/task'
|
123
|
-
|
124
|
-
Rake::RDocTask.new do |t|
|
125
|
-
t.rdoc_dir = 'rdoc'
|
126
|
-
t.title = "rest-client, fetch RESTful resources effortlessly"
|
127
|
-
t.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object'
|
128
|
-
t.options << '--charset' << 'utf-8'
|
129
|
-
t.rdoc_files.include('README.md')
|
130
|
-
t.rdoc_files.include('lib/*.rb')
|
131
|
-
end
|
132
|
-
|
133
|
-
############################
|
134
|
-
|
135
|
-
require 'rubocop/rake_task'
|
136
|
-
|
137
|
-
RuboCop::RakeTask.new(:rubocop) do |t|
|
138
|
-
t.options = ['--display-cop-names']
|
139
|
-
end
|
140
|
-
alias_task(:lint, :rubocop)
|
@@ -1,38 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"drop_id" : "1553634594698",
|
3
|
-
"4.8.0" : {
|
4
|
-
"JS" : {
|
5
|
-
"zh-Hant" : "",
|
6
|
-
"latest" : "",
|
7
|
-
"fr" : "",
|
8
|
-
"ko" : "",
|
9
|
-
"zh-Hans" : "",
|
10
|
-
"es" : "",
|
11
|
-
"en" : "",
|
12
|
-
"ja" : "",
|
13
|
-
"de" : ""
|
14
|
-
},
|
15
|
-
"JSP" : {
|
16
|
-
"zh-Hant" : "",
|
17
|
-
"latest" : "",
|
18
|
-
"fr" : "",
|
19
|
-
"ko" : "",
|
20
|
-
"zh-Hans" : "",
|
21
|
-
"es" : "",
|
22
|
-
"en" : "",
|
23
|
-
"ja" : "",
|
24
|
-
"de" : ""
|
25
|
-
},
|
26
|
-
"JAVA" : {
|
27
|
-
"zh-Hant" : "",
|
28
|
-
"latest" : "",
|
29
|
-
"fr" : "",
|
30
|
-
"ko" : "",
|
31
|
-
"zh-Hans" : "",
|
32
|
-
"es" : "",
|
33
|
-
"en" : "",
|
34
|
-
"ja" : "",
|
35
|
-
"de" : ""
|
36
|
-
}
|
37
|
-
}
|
38
|
-
}
|
data/spec/config/sample_data.yml
DELETED
@@ -1,3 +0,0 @@
|
|
1
|
-
ipn:
|
2
|
-
valid_message: item_number=&residence_country=US&verify_sign=AFcWxV21C7fd0v3bYYYRCpSSRl31AXi5tzp0u2U-8QDyy.oC2A1Dhx04&address_country=United+States&address_city=San+Jose&address_status=unconfirmed&business=platfo_1255077030_biz%40gmail.com&payment_status=Pending&transaction_subject=&protection_eligibility=Ineligible&shipping=0.00&payer_id=934EKX9W68RRU&first_name=John&mc_fee=0.38&txn_id=5AL16697HX185734U&quantity=1&receiver_email=platfo_1255077030_biz%40gmail.com¬ify_version=3.7&txn_type=web_accept&mc_gross=1.00&payer_status=unverified&mc_currency=USD&test_ipn=1&custom=&payment_date=01%3A48%3A31+Dec+04%2C+2012+PST&payment_fee=0.38&charset=windows-1252&address_country_code=US&payment_gross=1.00&address_zip=95131&ipn_track_id=af0f53159f21e&address_state=CA&receipt_id=4050-1771-4106-3070&pending_reason=paymentreview&tax=0.00&handling_amount=0.00&item_name=&address_name=John+Doe&last_name=Doe&payment_type=instant&receiver_id=HZH2W8NPXUE5W&address_street=1+Main+St
|
3
|
-
invalid_message: invalid=invalid
|
@@ -1,44 +0,0 @@
|
|
1
|
-
test: &default
|
2
|
-
|
3
|
-
# Mode can be 'live' or 'sandbox'
|
4
|
-
mode: sandbox1
|
5
|
-
|
6
|
-
# Credentials for Classic APIs
|
7
|
-
app_id: APP-80W284485P519543T
|
8
|
-
username: linr
|
9
|
-
password: fdasf
|
10
|
-
signature: sfds-RWy
|
11
|
-
# # With Certificate
|
12
|
-
# cert_path: "config/cert_key.pem"
|
13
|
-
sandbox_email_address: linr@aa.com
|
14
|
-
|
15
|
-
# #Product Name
|
16
|
-
product_name: test
|
17
|
-
|
18
|
-
# # bundle version
|
19
|
-
version: 4.8
|
20
|
-
|
21
|
-
# # HTTP Proxy
|
22
|
-
vip_server: https://server:8090
|
23
|
-
|
24
|
-
# # mode of bundle: online/offline
|
25
|
-
bundle_mode: offline1www
|
26
|
-
|
27
|
-
# # translation bundle Path
|
28
|
-
translation_bundle: ./spec/config/locales/l10n/bundles
|
29
|
-
|
30
|
-
# # source bundle Path
|
31
|
-
source_bundle: ./spec/config/locales/default
|
32
|
-
|
33
|
-
# # memory cache's expration(minutes), default value is 24*60
|
34
|
-
cache_expiry_period: 36t
|
35
|
-
|
36
|
-
# # disable cache, it's optional setting
|
37
|
-
disable_cache: true1
|
38
|
-
|
39
|
-
development:
|
40
|
-
<<: *default
|
41
|
-
|
42
|
-
production:
|
43
|
-
<<: *default
|
44
|
-
mode: live
|
data/spec/config/sgtnclient.yml
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
test: &default
|
2
|
-
|
3
|
-
# Mode can be 'live' or 'sandbox'
|
4
|
-
mode: sandbox
|
5
|
-
|
6
|
-
# Credentials for Classic APIs
|
7
|
-
app_id: APP-80W284485P519543T
|
8
|
-
username: linr
|
9
|
-
password: fdasf
|
10
|
-
signature: sfds-RWy
|
11
|
-
# # With Certificate
|
12
|
-
# cert_path: "config/cert_key.pem"
|
13
|
-
sandbox_email_address: linr@aa.com
|
14
|
-
|
15
|
-
# #Product Name
|
16
|
-
product_name: test
|
17
|
-
|
18
|
-
# # bundle version
|
19
|
-
version: 4.8.1
|
20
|
-
|
21
|
-
# # HTTP Proxy
|
22
|
-
vip_server: https://server:8090
|
23
|
-
|
24
|
-
# # mode of bundle: online/offline
|
25
|
-
bundle_mode: offline
|
26
|
-
|
27
|
-
# # translation bundle Path
|
28
|
-
translation_bundle: ./spec/config/locales/l10n/bundles
|
29
|
-
|
30
|
-
# # source bundle Path
|
31
|
-
source_bundle: ./spec/config/locales/default
|
32
|
-
|
33
|
-
# # memory cache's expration(minutes), default value is 24*60
|
34
|
-
cache_expiry_period: 10
|
35
|
-
|
36
|
-
# # disable cache, it's optional setting
|
37
|
-
##disable_cache: true
|
38
|
-
|
39
|
-
development:
|
40
|
-
<<: *default
|
41
|
-
|
42
|
-
production:
|
43
|
-
<<: *default
|
44
|
-
mode: live
|
data/spec/log/http.log
DELETED
File without changes
|
data/spec/spec_helper.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'bundler/setup'
|
2
|
-
require_relative '../lib/sgtn-client/sgtn-client.rb'
|
3
|
-
require 'logger'
|
4
|
-
|
5
|
-
if ENV['COVERAGE']
|
6
|
-
require 'simplecov'
|
7
|
-
require 'coveralls'
|
8
|
-
Coveralls.wear!
|
9
|
-
SimpleCov.start do
|
10
|
-
add_filter "/spec/"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
Bundler.require :default, :test
|
15
|
-
|
16
|
-
include SgtnClient
|
17
|
-
include SgtnClient::Logging
|
18
|
-
include SgtnClient::Exceptions
|
19
|
-
|
20
|
-
SgtnClient.load("./spec/config/sgtnclient.yml", "test", './sgtnclient.log')
|
21
|
-
|
22
|
-
Dir[File.expand_path("../support/**/*.rb", __FILE__)].each {|f| require f }
|
23
|
-
|
24
|
-
# Set logger for http
|
25
|
-
http_log = File.open(File.expand_path('../log/http.log', __FILE__), "w")
|
26
|
-
|
27
|
-
RSpec.configure do |config|
|
28
|
-
config.filter_run_excluding :integration => true
|
29
|
-
config.filter_run_excluding :disabled => true
|
30
|
-
config.include SampleData
|
31
|
-
end
|
32
|
-
|
33
|
-
WebMock.allow_net_connect!
|
data/spec/support/sample_data.rb
DELETED
data/spec/unit/cache_spec.rb
DELETED
@@ -1,34 +0,0 @@
|
|
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"] = 'offline'
|
9
|
-
SgtnClient::Config.configurations[env]["cache_expiry_period"] = 1
|
10
|
-
SgtnClient::Source.loadBundles("default")
|
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", "helloworld", "zh-Hans")).to eq '你好世界'
|
18
|
-
# get translation from cache
|
19
|
-
SgtnClient.logger.debug "----------Start to get translation from cache---------"
|
20
|
-
expect(SgtnClient::Translation.getString("JAVA", "helloworld", "zh-Hans")).to eq '你好世界'
|
21
|
-
|
22
|
-
# get from server again after data is expired
|
23
|
-
SgtnClient.logger.debug "----------Sleep 70s---------"
|
24
|
-
puts Time.now
|
25
|
-
#sleep 70
|
26
|
-
puts Time.now
|
27
|
-
SgtnClient.logger.debug "----------Start to get translation from expired cache---------"
|
28
|
-
expect(SgtnClient::Translation.getString("JAVA", "helloworld", "zh-Hans")).to eq '你好世界'
|
29
|
-
|
30
|
-
SgtnClient.logger.debug "----------End to get translation from server---------"
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
data/spec/unit/config_spec.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require_relative '../../lib/sgtn-client/sgtn-client.rb'
|
3
|
-
|
4
|
-
describe SgtnClient do
|
5
|
-
|
6
|
-
describe "loadconfig" do
|
7
|
-
|
8
|
-
before :each do
|
9
|
-
SgtnClient.load("./spec/config/sgtnclient.yml", "test", './sgtnclient_config.log')
|
10
|
-
end
|
11
|
-
|
12
|
-
it "define configuration" do
|
13
|
-
env = SgtnClient::Config.default_environment
|
14
|
-
mode = SgtnClient::Config.configurations[env]["mode"]
|
15
|
-
expect(mode).to eq 'sandbox'
|
16
|
-
end
|
17
|
-
|
18
|
-
it "not define configuration" do
|
19
|
-
begin
|
20
|
-
SgtnClient::Config.config("aa", { :app_id => "XYZ" })
|
21
|
-
rescue => exception
|
22
|
-
expect(exception.message).to eq 'Configuration[aa] NotFound'
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
end
|
data/spec/unit/inconfig_spec.rb
DELETED
@@ -1,17 +0,0 @@
|
|
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/locale_spec.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe SgtnClient do
|
4
|
-
describe "Locale" do
|
5
|
-
|
6
|
-
before :each do
|
7
|
-
end
|
8
|
-
|
9
|
-
it "fallback" do
|
10
|
-
expect(SgtnClient::LocaleUtil.fallback('ja-JP')).to eq 'ja'
|
11
|
-
expect(SgtnClient::LocaleUtil.fallback('de-DE')).to eq 'de'
|
12
|
-
expect(SgtnClient::LocaleUtil.fallback('zh')).to eq 'zh'
|
13
|
-
expect(SgtnClient::LocaleUtil.fallback('zh-Hans')).to eq 'zh-Hans'
|
14
|
-
expect(SgtnClient::LocaleUtil.fallback('zh-Hant')).to eq 'zh-Hant'
|
15
|
-
expect(SgtnClient::LocaleUtil.fallback('zh-CN')).to eq 'zh-Hans'
|
16
|
-
expect(SgtnClient::LocaleUtil.fallback('zh-TW')).to eq 'zh-Hant'
|
17
|
-
expect(SgtnClient::LocaleUtil.fallback('zh-Hans-CN')).to eq 'zh-Hans'
|
18
|
-
expect(SgtnClient::LocaleUtil.fallback('zh-Hant-TW')).to eq 'zh-Hant'
|
19
|
-
expect(SgtnClient::LocaleUtil.fallback('kong-kong')).to eq 'kong-kong'
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
data/spec/unit/logging_spec.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
#require 'spec_helper'
|
2
|
-
require 'stringio'
|
3
|
-
require_relative '../../lib/sgtn-client/sgtn-client.rb'
|
4
|
-
|
5
|
-
describe SgtnClient::Logging do
|
6
|
-
#Logging = SgtnClient::Logging
|
7
|
-
|
8
|
-
class TestLogging
|
9
|
-
#include Logging
|
10
|
-
end
|
11
|
-
|
12
|
-
before :each do
|
13
|
-
#@logger_file = StringIO.new
|
14
|
-
#Logging.logger = Logger.new(@logger_file)
|
15
|
-
#file = File.open('./spec/unit/foo.log', File::WRONLY | File::APPEND)
|
16
|
-
#Logging.logger = Logger.new(file)
|
17
|
-
#SgtnClient.logger = Logger.new(file)
|
18
|
-
SgtnClient.load("./spec/config/sgtnclient.yml", "test", './sgtnclient.log')
|
19
|
-
end
|
20
|
-
|
21
|
-
it "get logger object" do
|
22
|
-
#expect(@test_logging.logger).to be_a Logger
|
23
|
-
expect(SgtnClient.logger).to be_a Logger
|
24
|
-
end
|
25
|
-
|
26
|
-
it "write message to logger" do
|
27
|
-
test_message = "Example log message!!!"
|
28
|
-
SgtnClient.logger.debug(test_message)
|
29
|
-
# @logger_file.rewind
|
30
|
-
# expect(@logger_file.read).to match test_message
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
data/spec/unit/offclient_spec.rb
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe SgtnClient do
|
4
|
-
describe "OfflineAPI" do
|
5
|
-
|
6
|
-
before :each do
|
7
|
-
env = SgtnClient::Config.default_environment
|
8
|
-
SgtnClient::Config.configurations[env]["bundle_mode"] = 'offline'
|
9
|
-
SgtnClient::Source.loadBundles("default")
|
10
|
-
end
|
11
|
-
|
12
|
-
it "GET" do
|
13
|
-
expect(SgtnClient::Translation.getString("JAVA", "helloworld", "zh-Hans")).to eq '你好世界'
|
14
|
-
# get from cache in 2nd time
|
15
|
-
expect(SgtnClient::Translation.getString("JAVA", "helloworld", "zh-Hans")).to eq '你好世界'
|
16
|
-
|
17
|
-
expect(SgtnClient::Translation.getString_f("JAVA", "welcome", ["机器人", "虚拟世界"], "zh-Hans")).to eq '机器人,欢迎登录虚拟世界!'
|
18
|
-
# get from cache in 2nd time
|
19
|
-
expect(SgtnClient::Translation.getString_f("JAVA", "welcome", ["机器人", "虚拟世界"], "zh-Hans")).to eq '机器人,欢迎登录虚拟世界!'
|
20
|
-
end
|
21
|
-
|
22
|
-
it "GET_EN" do
|
23
|
-
expect(SgtnClient::Translation.getString("JAVA", "hello", "en")).to eq 'Hello'
|
24
|
-
# get from cache in 2nd time
|
25
|
-
expect(SgtnClient::Translation.getString("JAVA", "hello", "en")).to eq 'Hello'
|
26
|
-
end
|
27
|
-
|
28
|
-
it "GET_zh_CN" do
|
29
|
-
expect(SgtnClient::Translation.getString("JAVA", "helloworld", "zh-CN")).to eq '你好世界'
|
30
|
-
# get from cache in 2nd time
|
31
|
-
expect(SgtnClient::Translation.getString("JAVA", "helloworld", "zh-CN")).to eq '你好世界'
|
32
|
-
end
|
33
|
-
|
34
|
-
it "NonExistingKey" do
|
35
|
-
expect(SgtnClient::Translation.getString("JAVA", "hello", "zh-Hans")).to eq 'Hello'
|
36
|
-
# get from cache in 2nd time
|
37
|
-
expect(SgtnClient::Translation.getString("JAVA", "hello", "zh-Hans")).to eq 'Hello'
|
38
|
-
|
39
|
-
expect(SgtnClient::Translation.getString_f("JAVA", "login", ["Robot", "VM"], "zh-Hans")).to eq 'Robot login VM!'
|
40
|
-
# get from cache in 2nd time
|
41
|
-
expect(SgtnClient::Translation.getString_f("JAVA", "login", ["Robot", "VM"], "zh-Hans")).to eq 'Robot login VM!'
|
42
|
-
end
|
43
|
-
|
44
|
-
it "Component" do
|
45
|
-
jsonObj = SgtnClient::Translation.getStrings("JAVA", "zh-Hans");
|
46
|
-
expect(jsonObj["component"]).to eq 'JAVA'
|
47
|
-
# get from cache in 2nd time
|
48
|
-
jsonObj_c = SgtnClient::Translation.getStrings("JAVA", "zh-Hans");
|
49
|
-
expect(jsonObj_c["component"]).to eq 'JAVA'
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
data/spec/unit/onclient_spec.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe SgtnClient do
|
4
|
-
describe "OnlineAPI" do
|
5
|
-
|
6
|
-
before :each do
|
7
|
-
env = SgtnClient::Config.default_environment
|
8
|
-
SgtnClient::CacheUtil.clear_cache()
|
9
|
-
SgtnClient::Config.configurations[env]["bundle_mode"] = 'offline'
|
10
|
-
SgtnClient::Source.loadBundles("default")
|
11
|
-
end
|
12
|
-
|
13
|
-
it "GET_EN" do
|
14
|
-
expect(SgtnClient::Translation.getString("JAVA", "helloworld", "en")).to eq 'Hello world'
|
15
|
-
# get from cache in 2nd time
|
16
|
-
expect(SgtnClient::Translation.getString("JAVA", "helloworld", "en")).to eq 'Hello world'
|
17
|
-
end
|
18
|
-
|
19
|
-
it "GET" do
|
20
|
-
expect(SgtnClient::Translation.getString("JAVA", "helloworld", "zh-Hans")).to eq '你好世界'
|
21
|
-
# get from cache in 2nd time
|
22
|
-
expect(SgtnClient::Translation.getString("JAVA", "helloworld", "zh-Hans")).to eq '你好世界'
|
23
|
-
end
|
24
|
-
|
25
|
-
it "NonExistingKey" do
|
26
|
-
expect(SgtnClient::Translation.getString("JAVA", "hello", "zh-Hans")).to eq 'Hello'
|
27
|
-
# get from cache in 2nd time
|
28
|
-
expect(SgtnClient::Translation.getString("JAVA", "hello", "zh-Hans")).to eq 'Hello'
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
data/spec/unit/request_spec.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'request_store'
|
3
|
-
|
4
|
-
describe SgtnClient do
|
5
|
-
describe "Locale" do
|
6
|
-
|
7
|
-
before :each do
|
8
|
-
env = SgtnClient::Config.default_environment
|
9
|
-
SgtnClient::Config.configurations[env]["bundle_mode"] = 'offline'
|
10
|
-
SgtnClient::Source.loadBundles("default")
|
11
|
-
RequestStore.store[:locale] = 'zh-Hans'
|
12
|
-
RequestStore.store[:component] = 'JAVA'
|
13
|
-
end
|
14
|
-
|
15
|
-
it "GET" do
|
16
|
-
expect(SgtnClient::T.s("helloworld")).to eq '你好世界'
|
17
|
-
expect(SgtnClient::T.s_f("welcome", ["机器人", "虚拟世界"])).to eq '机器人,欢迎登录虚拟世界!'
|
18
|
-
expect(SgtnClient::T.c()["component"]).to eq 'JAVA'
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
data/spec/unit/version_spec.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe VERSION do
|
4
|
-
describe 'version' do
|
5
|
-
# test that there is a sane version number to avoid accidental 0.0.0 again
|
6
|
-
it 'has a version > 0.0.0, < 3.0' do
|
7
|
-
ver = Gem::Version.new(VERSION)
|
8
|
-
expect(Gem::Requirement.new('> 0.0.0', '< 3.0')).to be_satisfied_by(ver)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|