copy_tuner_client 0.17.1 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/rspec.yml +3 -11
- data/README.md +0 -10
- data/copy_tuner_client.gemspec +6 -7
- data/lib/copy_tuner_client/cache.rb +8 -0
- data/lib/copy_tuner_client/configuration.rb +26 -29
- data/lib/copy_tuner_client/version.rb +1 -1
- metadata +9 -31
- /data/gemfiles/{6.1.gemfile → 7.2.gemfile} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 835387c50adc34ebee7981c52d9d823f6e3ff2652308b088c95846b6fa98e9f4
|
4
|
+
data.tar.gz: 8aba55013580f79332739062ac41c65585e1a434e74228a24398dd7ebb5cab88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d361717f3f6ac6ad26f29a14e61979e2e7293f07df766fd80d766aa63cb1fad57a9f323ef3807cbe3f17f3e7cda4fbc6c949e73f7d19a9c61988821c09e5b5b
|
7
|
+
data.tar.gz: 6da23e3bd4602be2fc05331896620675c15783c227dabb64644be347f2fe689b87f8784052aa100a2d484df742cdb87acd4ffe20a0108aba321d84548b6bdf33
|
data/.github/workflows/rspec.yml
CHANGED
@@ -22,17 +22,9 @@ jobs:
|
|
22
22
|
strategy:
|
23
23
|
fail-fast: false
|
24
24
|
matrix:
|
25
|
-
ruby: [
|
26
|
-
gemfile: ["
|
27
|
-
exclude:
|
28
|
-
- ruby: "3.0"
|
29
|
-
gemfile: "main"
|
30
|
-
- ruby: "3.1"
|
31
|
-
gemfile: "6.1"
|
32
|
-
- ruby: "3.2"
|
33
|
-
gemfile: "6.1"
|
34
|
-
- ruby: "3.3"
|
35
|
-
gemfile: "6.1"
|
25
|
+
ruby: [3.1, 3.2, 3,3]
|
26
|
+
gemfile: ["7.0", "7.1", "7.2", "main"]
|
27
|
+
exclude: []
|
36
28
|
steps:
|
37
29
|
- name: Install packages
|
38
30
|
run: |
|
data/README.md
CHANGED
@@ -34,16 +34,6 @@ bundle exec rake copy_tuner:export
|
|
34
34
|
|
35
35
|
これで、`config/locales/copy_tuner.yml` に翻訳ファイルが作成されます。
|
36
36
|
|
37
|
-
## IE等のレガシーブラウザ対応が必要な場合
|
38
|
-
|
39
|
-
以下のスクリプトタグを追加する。(必要なpolyfillを個別に読み込んでも可)
|
40
|
-
|
41
|
-
```
|
42
|
-
<script src="https://cdn.polyfill.io/v2/polyfill.min.js"></script>
|
43
|
-
```
|
44
|
-
|
45
|
-
[Polyfill service](https://cdn.polyfill.io/v2/docs/)
|
46
|
-
|
47
37
|
Development
|
48
38
|
=================
|
49
39
|
|
data/copy_tuner_client.gemspec
CHANGED
@@ -1,13 +1,12 @@
|
|
1
|
-
|
2
|
-
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
|
1
|
+
$LOAD_PATH.push File.expand_path('lib', __dir__)
|
3
2
|
require 'copy_tuner_client/version'
|
4
3
|
|
5
4
|
Gem::Specification.new do |s|
|
6
|
-
s.required_ruby_version = '>= 3.
|
5
|
+
s.required_ruby_version = '>= 3.1.0'
|
7
6
|
s.add_dependency 'i18n', '>= 0.5.0'
|
8
7
|
s.add_dependency 'json'
|
9
8
|
s.add_dependency 'nokogiri'
|
10
|
-
s.add_development_dependency 'rails', '~>
|
9
|
+
s.add_development_dependency 'rails', '~> 7.0'
|
11
10
|
s.add_development_dependency 'rake'
|
12
11
|
s.add_development_dependency 'rspec'
|
13
12
|
s.add_development_dependency 'sham_rack'
|
@@ -17,14 +16,14 @@ Gem::Specification.new do |s|
|
|
17
16
|
s.add_development_dependency 'webmock'
|
18
17
|
s.add_development_dependency 'yard'
|
19
18
|
s.authors = ['SonicGarden']
|
20
|
-
s.email
|
19
|
+
s.email = 'info@sonicgarden.jp'
|
21
20
|
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
22
21
|
s.files = `git ls-files`.split("\n")
|
23
22
|
s.homepage = 'https://github.com/SonicGarden/copy-tuner-ruby-client'
|
24
|
-
s.name
|
23
|
+
s.name = 'copy_tuner_client'
|
25
24
|
s.platform = Gem::Platform::RUBY
|
26
25
|
s.require_paths = ['lib']
|
27
26
|
s.summary = 'Client for the CopyTuner copy management service'
|
28
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
29
27
|
s.version = CopyTunerClient::VERSION
|
28
|
+
s.metadata['rubygems_mfa_required'] = 'true'
|
30
29
|
end
|
@@ -18,6 +18,8 @@ module CopyTunerClient
|
|
18
18
|
@mutex = Mutex.new
|
19
19
|
@exclude_key_regexp = options[:exclude_key_regexp]
|
20
20
|
@upload_disabled = options[:upload_disabled]
|
21
|
+
@ignored_keys = options.fetch(:ignored_keys, [])
|
22
|
+
@ignored_key_handler = options.fetch(:ignored_key_handler, -> (e) { raise e })
|
21
23
|
@locales = Array(options[:locales]).map(&:to_s)
|
22
24
|
# mutable states
|
23
25
|
@blurbs = {}
|
@@ -44,6 +46,12 @@ module CopyTunerClient
|
|
44
46
|
return if @locales.present? && !@locales.member?(key.split('.').first)
|
45
47
|
return if @upload_disabled
|
46
48
|
|
49
|
+
# NOTE: config/locales以下のファイルに除外キーが残っていた場合の対応
|
50
|
+
key_without_locale = key.split('.')[1..].join('.')
|
51
|
+
if @ignored_keys.include?(key_without_locale)
|
52
|
+
@ignored_key_handler.call(IgnoredKey.new("Ignored key: #{key_without_locale}"))
|
53
|
+
end
|
54
|
+
|
47
55
|
lock do
|
48
56
|
return if @blank_keys.member?(key) || @blurbs.key?(key)
|
49
57
|
|
@@ -11,15 +11,14 @@ require 'copy_tuner_client/copyray_middleware'
|
|
11
11
|
module CopyTunerClient
|
12
12
|
# Used to set up and modify settings for the client.
|
13
13
|
class Configuration
|
14
|
-
|
15
14
|
# These options will be present in the Hash returned by {#to_hash}.
|
16
|
-
OPTIONS = [
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
15
|
+
OPTIONS = %i[api_key development_environments environment_name host
|
16
|
+
http_open_timeout http_read_timeout client_name client_url
|
17
|
+
client_version port protocol proxy_host proxy_pass
|
18
|
+
proxy_port proxy_user secure polling_delay sync_interval
|
19
|
+
sync_interval_staging sync_ignore_path_regex logger
|
20
|
+
framework middleware disable_middleware disable_test_translation
|
21
|
+
ca_file exclude_key_regexp s3_host locales ignored_keys ignored_key_handler].freeze
|
23
22
|
|
24
23
|
# @return [String] The API key for your project, found on the project edit form.
|
25
24
|
attr_accessor :api_key
|
@@ -137,14 +136,14 @@ module CopyTunerClient
|
|
137
136
|
# @return [Proc]
|
138
137
|
attr_accessor :ignored_key_handler
|
139
138
|
|
140
|
-
|
139
|
+
alias secure? secure
|
141
140
|
|
142
141
|
# Instantiated from {CopyTunerClient.configure}. Sets defaults.
|
143
142
|
def initialize
|
144
143
|
self.client_name = 'CopyTuner Client'
|
145
144
|
self.client_url = 'https://rubygems.org/gems/copy_tuner_client'
|
146
145
|
self.client_version = VERSION
|
147
|
-
self.development_environments = %w
|
146
|
+
self.development_environments = %w[development staging]
|
148
147
|
self.host = 'copy-tuner.com'
|
149
148
|
self.http_open_timeout = 5
|
150
149
|
self.http_read_timeout = 5
|
@@ -153,14 +152,14 @@ module CopyTunerClient
|
|
153
152
|
self.sync_interval = 60
|
154
153
|
self.sync_interval_staging = 0
|
155
154
|
self.secure = true
|
156
|
-
self.test_environments = %w
|
155
|
+
self.test_environments = %w[test cucumber]
|
157
156
|
self.upload_disabled_environments = %w[production staging]
|
158
|
-
self.s3_host = 'copy-tuner-
|
157
|
+
self.s3_host = 'copy-tuner.sg-apps.com' # NOTE: cloudfront host
|
159
158
|
self.disable_copyray_comment_injection = false
|
160
159
|
# TODO: 0.18.0以降のバージョンで初期値をtrueにしたい
|
161
160
|
self.html_escape = nil
|
162
161
|
self.ignored_keys = []
|
163
|
-
self.ignored_key_handler = ->
|
162
|
+
self.ignored_key_handler = ->(e) { raise e }
|
164
163
|
|
165
164
|
@applied = false
|
166
165
|
end
|
@@ -238,13 +237,11 @@ module CopyTunerClient
|
|
238
237
|
#
|
239
238
|
# When {#test?} returns +false+, the poller will be started.
|
240
239
|
def apply
|
241
|
-
self.locales ||=
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
end
|
247
|
-
end
|
240
|
+
self.locales ||= self.locales = if defined?(::Rails)
|
241
|
+
::Rails.application.config.i18n.available_locales.presence || Array(::Rails.application.config.i18n.default_locale)
|
242
|
+
else
|
243
|
+
[:en]
|
244
|
+
end
|
248
245
|
|
249
246
|
self.client ||= Client.new(to_hash)
|
250
247
|
self.cache ||= Cache.new(client, to_hash)
|
@@ -253,8 +250,8 @@ module CopyTunerClient
|
|
253
250
|
I18n.backend = I18nBackend.new(cache)
|
254
251
|
|
255
252
|
if enable_middleware?
|
256
|
-
logger.info
|
257
|
-
request_sync_options = {:
|
253
|
+
logger.info 'Using copytuner sync middleware'
|
254
|
+
request_sync_options = { poller: @poller, cache:, interval: sync_interval, ignore_regex: sync_ignore_path_regex }
|
258
255
|
if middleware_position.is_a?(Hash) && middleware_position[:before]
|
259
256
|
middleware.insert_before middleware_position[:before], RequestSync, request_sync_options
|
260
257
|
middleware.insert_before middleware_position[:before], CopyTunerClient::CopyrayMiddleware
|
@@ -266,7 +263,7 @@ module CopyTunerClient
|
|
266
263
|
middleware.use CopyTunerClient::CopyrayMiddleware
|
267
264
|
end
|
268
265
|
else
|
269
|
-
logger.info
|
266
|
+
logger.info '[[[Warn]]] Not using copytuner sync middleware' unless middleware
|
270
267
|
end
|
271
268
|
|
272
269
|
@applied = true
|
@@ -278,8 +275,8 @@ module CopyTunerClient
|
|
278
275
|
process_guard.start
|
279
276
|
end
|
280
277
|
|
281
|
-
|
282
|
-
logger.info
|
278
|
+
unless test? && disable_test_translation
|
279
|
+
logger.info 'Download translation now'
|
283
280
|
cache.download
|
284
281
|
end
|
285
282
|
end
|
@@ -302,19 +299,19 @@ module CopyTunerClient
|
|
302
299
|
# @return [String] a description of the environment in which this configuration was built.
|
303
300
|
def environment_info
|
304
301
|
parts = ["Ruby: #{RUBY_VERSION}", framework, "Env: #{environment_name}"]
|
305
|
-
parts.compact.map { |part| "[#{part}]" }.join(
|
302
|
+
parts.compact.map { |part| "[#{part}]" }.join(' ')
|
306
303
|
end
|
307
304
|
|
308
305
|
# Wraps the given logger in a PrefixedLogger. This way, CopyTunerClient
|
309
306
|
# log messages are recognizable.
|
310
307
|
# @param original_logger [Logger] the upstream logger to use, which must respond to the standard +Logger+ severity methods.
|
311
308
|
def logger=(original_logger)
|
312
|
-
@logger = PrefixedLogger.new(
|
309
|
+
@logger = PrefixedLogger.new('** [CopyTuner]', original_logger)
|
313
310
|
end
|
314
311
|
|
315
312
|
# Sync interval for Rack Middleware
|
316
313
|
def sync_interval
|
317
|
-
if environment_name ==
|
314
|
+
if environment_name == 'staging'
|
318
315
|
@sync_interval_staging
|
319
316
|
else
|
320
317
|
@sync_interval
|
@@ -323,7 +320,7 @@ module CopyTunerClient
|
|
323
320
|
|
324
321
|
# @return [String] current project url by api_key
|
325
322
|
def project_url
|
326
|
-
URI::Generic.build(:
|
323
|
+
URI::Generic.build(scheme: self.protocol, host: self.host, port: self.port.to_i, path: "/projects/#{self.api_key}").to_s
|
327
324
|
end
|
328
325
|
|
329
326
|
private
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: copy_tuner_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.19.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SonicGarden
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '7.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '7.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -201,9 +201,9 @@ files:
|
|
201
201
|
- app/assets/javascripts/copytuner.js
|
202
202
|
- app/assets/stylesheets/copytuner.css
|
203
203
|
- copy_tuner_client.gemspec
|
204
|
-
- gemfiles/6.1.gemfile
|
205
204
|
- gemfiles/7.0.gemfile
|
206
205
|
- gemfiles/7.1.gemfile
|
206
|
+
- gemfiles/7.2.gemfile
|
207
207
|
- gemfiles/main.gemfile
|
208
208
|
- index.html
|
209
209
|
- lib/copy_tuner_client.rb
|
@@ -266,7 +266,8 @@ files:
|
|
266
266
|
- yarn.lock
|
267
267
|
homepage: https://github.com/SonicGarden/copy-tuner-ruby-client
|
268
268
|
licenses: []
|
269
|
-
metadata:
|
269
|
+
metadata:
|
270
|
+
rubygems_mfa_required: 'true'
|
270
271
|
post_install_message:
|
271
272
|
rdoc_options: []
|
272
273
|
require_paths:
|
@@ -275,7 +276,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
275
276
|
requirements:
|
276
277
|
- - ">="
|
277
278
|
- !ruby/object:Gem::Version
|
278
|
-
version: 3.
|
279
|
+
version: 3.1.0
|
279
280
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
280
281
|
requirements:
|
281
282
|
- - ">="
|
@@ -286,27 +287,4 @@ rubygems_version: 3.4.10
|
|
286
287
|
signing_key:
|
287
288
|
specification_version: 4
|
288
289
|
summary: Client for the CopyTuner copy management service
|
289
|
-
test_files:
|
290
|
-
- spec/copy_tuner_client/cache_spec.rb
|
291
|
-
- spec/copy_tuner_client/client_spec.rb
|
292
|
-
- spec/copy_tuner_client/configuration_spec.rb
|
293
|
-
- spec/copy_tuner_client/copyray_spec.rb
|
294
|
-
- spec/copy_tuner_client/dotted_hash_spec.rb
|
295
|
-
- spec/copy_tuner_client/helper_extension_spec.rb
|
296
|
-
- spec/copy_tuner_client/i18n_backend_spec.rb
|
297
|
-
- spec/copy_tuner_client/poller_spec.rb
|
298
|
-
- spec/copy_tuner_client/prefixed_logger_spec.rb
|
299
|
-
- spec/copy_tuner_client/process_guard_spec.rb
|
300
|
-
- spec/copy_tuner_client/request_sync_spec.rb
|
301
|
-
- spec/copy_tuner_client_spec.rb
|
302
|
-
- spec/spec_helper.rb
|
303
|
-
- spec/support/client_spec_helpers.rb
|
304
|
-
- spec/support/defines_constants.rb
|
305
|
-
- spec/support/fake_client.rb
|
306
|
-
- spec/support/fake_copy_tuner_app.rb
|
307
|
-
- spec/support/fake_html_safe_string.rb
|
308
|
-
- spec/support/fake_logger.rb
|
309
|
-
- spec/support/fake_passenger.rb
|
310
|
-
- spec/support/fake_unicorn.rb
|
311
|
-
- spec/support/middleware_stack.rb
|
312
|
-
- spec/support/writing_cache.rb
|
290
|
+
test_files: []
|
File without changes
|