copy_tuner_client 0.18.0 → 0.20.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 +5 -9
- data/README.md +1 -10
- data/copy_tuner_client.gemspec +6 -7
- data/gemfiles/{6.1.gemfile → 7.2.gemfile} +1 -1
- data/gemfiles/{7.0.gemfile → 8.0.gemfile} +1 -1
- data/lib/copy_tuner_client/configuration.rb +38 -29
- data/lib/copy_tuner_client/version.rb +1 -1
- metadata +10 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ce432696e671bc407815e22ccf03721f4eddfc9925b0635d7dae2320089cb74
|
4
|
+
data.tar.gz: 9c3b366f16333adbea8da1e9b5c105727533b051b128eee2beb08d3f9927520b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee4336da02431de843726a2f33338d52977b2f0978e9b4378e892d191dc5e495119f7c3f5fef07762e1e3029678adf555208cc355afcdc2916c8393c38428d58
|
7
|
+
data.tar.gz: 5944df5005b58ef08a07fc7badb882a07e9fd223c69893ca84a68c9ec878fea6b3e33b159beea9179b254a5158f4fd8b493202448c8e081f07f8dcf1e5aff730
|
data/.github/workflows/rspec.yml
CHANGED
@@ -22,17 +22,13 @@ jobs:
|
|
22
22
|
strategy:
|
23
23
|
fail-fast: false
|
24
24
|
matrix:
|
25
|
-
ruby: [
|
26
|
-
gemfile: ["
|
25
|
+
ruby: ['3.1', '3.2', '3.3', '3.4']
|
26
|
+
gemfile: ["7.1", "7.2", "8.0", "main"]
|
27
27
|
exclude:
|
28
|
-
- ruby: "3.0"
|
29
|
-
gemfile: "main"
|
30
28
|
- ruby: "3.1"
|
31
|
-
gemfile: "
|
32
|
-
- ruby: "3.
|
33
|
-
gemfile: "
|
34
|
-
- ruby: "3.3"
|
35
|
-
gemfile: "6.1"
|
29
|
+
gemfile: "8.0"
|
30
|
+
- ruby: "3.1"
|
31
|
+
gemfile: "main"
|
36
32
|
steps:
|
37
33
|
- name: Install packages
|
38
34
|
run: |
|
data/README.md
CHANGED
@@ -16,6 +16,7 @@ Create config/initializers/copy_tuner.rb
|
|
16
16
|
```
|
17
17
|
CopyTunerClient.configure do |config|
|
18
18
|
config.api_key = 'YOUR-API-KEY'
|
19
|
+
config.project_id = 77
|
19
20
|
config.host = 'COPY-TUNER-HOST-NAME'
|
20
21
|
config.html_escape = true
|
21
22
|
|
@@ -34,16 +35,6 @@ bundle exec rake copy_tuner:export
|
|
34
35
|
|
35
36
|
これで、`config/locales/copy_tuner.yml` に翻訳ファイルが作成されます。
|
36
37
|
|
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
38
|
Development
|
48
39
|
=================
|
49
40
|
|
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.1'
|
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
|
@@ -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,17 @@ module CopyTunerClient
|
|
137
136
|
# @return [Proc]
|
138
137
|
attr_accessor :ignored_key_handler
|
139
138
|
|
140
|
-
|
139
|
+
# @return [Integer] The project id
|
140
|
+
attr_accessor :project_id
|
141
|
+
|
142
|
+
alias secure? secure
|
141
143
|
|
142
144
|
# Instantiated from {CopyTunerClient.configure}. Sets defaults.
|
143
145
|
def initialize
|
144
146
|
self.client_name = 'CopyTuner Client'
|
145
147
|
self.client_url = 'https://rubygems.org/gems/copy_tuner_client'
|
146
148
|
self.client_version = VERSION
|
147
|
-
self.development_environments = %w
|
149
|
+
self.development_environments = %w[development staging]
|
148
150
|
self.host = 'copy-tuner.com'
|
149
151
|
self.http_open_timeout = 5
|
150
152
|
self.http_read_timeout = 5
|
@@ -153,14 +155,15 @@ module CopyTunerClient
|
|
153
155
|
self.sync_interval = 60
|
154
156
|
self.sync_interval_staging = 0
|
155
157
|
self.secure = true
|
156
|
-
self.test_environments = %w
|
158
|
+
self.test_environments = %w[test cucumber]
|
157
159
|
self.upload_disabled_environments = %w[production staging]
|
158
|
-
self.s3_host = 'copy-tuner-
|
160
|
+
self.s3_host = 'copy-tuner.sg-apps.com' # NOTE: cloudfront host
|
159
161
|
self.disable_copyray_comment_injection = false
|
160
162
|
# TODO: 0.18.0以降のバージョンで初期値をtrueにしたい
|
161
163
|
self.html_escape = nil
|
162
164
|
self.ignored_keys = []
|
163
|
-
self.ignored_key_handler = ->
|
165
|
+
self.ignored_key_handler = ->(e) { raise e }
|
166
|
+
self.project_id = nil
|
164
167
|
|
165
168
|
@applied = false
|
166
169
|
end
|
@@ -238,13 +241,11 @@ module CopyTunerClient
|
|
238
241
|
#
|
239
242
|
# When {#test?} returns +false+, the poller will be started.
|
240
243
|
def apply
|
241
|
-
self.locales ||=
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
end
|
247
|
-
end
|
244
|
+
self.locales ||= self.locales = if defined?(::Rails)
|
245
|
+
::Rails.application.config.i18n.available_locales.presence || Array(::Rails.application.config.i18n.default_locale)
|
246
|
+
else
|
247
|
+
[:en]
|
248
|
+
end
|
248
249
|
|
249
250
|
self.client ||= Client.new(to_hash)
|
250
251
|
self.cache ||= Cache.new(client, to_hash)
|
@@ -253,8 +254,8 @@ module CopyTunerClient
|
|
253
254
|
I18n.backend = I18nBackend.new(cache)
|
254
255
|
|
255
256
|
if enable_middleware?
|
256
|
-
logger.info
|
257
|
-
request_sync_options = {:
|
257
|
+
logger.info 'Using copytuner sync middleware'
|
258
|
+
request_sync_options = { poller: @poller, cache:, interval: sync_interval, ignore_regex: sync_ignore_path_regex }
|
258
259
|
if middleware_position.is_a?(Hash) && middleware_position[:before]
|
259
260
|
middleware.insert_before middleware_position[:before], RequestSync, request_sync_options
|
260
261
|
middleware.insert_before middleware_position[:before], CopyTunerClient::CopyrayMiddleware
|
@@ -266,7 +267,7 @@ module CopyTunerClient
|
|
266
267
|
middleware.use CopyTunerClient::CopyrayMiddleware
|
267
268
|
end
|
268
269
|
else
|
269
|
-
logger.info
|
270
|
+
logger.info '[[[Warn]]] Not using copytuner sync middleware' unless middleware
|
270
271
|
end
|
271
272
|
|
272
273
|
@applied = true
|
@@ -278,8 +279,8 @@ module CopyTunerClient
|
|
278
279
|
process_guard.start
|
279
280
|
end
|
280
281
|
|
281
|
-
|
282
|
-
logger.info
|
282
|
+
unless test? && disable_test_translation
|
283
|
+
logger.info 'Download translation now'
|
283
284
|
cache.download
|
284
285
|
end
|
285
286
|
end
|
@@ -302,19 +303,19 @@ module CopyTunerClient
|
|
302
303
|
# @return [String] a description of the environment in which this configuration was built.
|
303
304
|
def environment_info
|
304
305
|
parts = ["Ruby: #{RUBY_VERSION}", framework, "Env: #{environment_name}"]
|
305
|
-
parts.compact.map { |part| "[#{part}]" }.join(
|
306
|
+
parts.compact.map { |part| "[#{part}]" }.join(' ')
|
306
307
|
end
|
307
308
|
|
308
309
|
# Wraps the given logger in a PrefixedLogger. This way, CopyTunerClient
|
309
310
|
# log messages are recognizable.
|
310
311
|
# @param original_logger [Logger] the upstream logger to use, which must respond to the standard +Logger+ severity methods.
|
311
312
|
def logger=(original_logger)
|
312
|
-
@logger = PrefixedLogger.new(
|
313
|
+
@logger = PrefixedLogger.new('** [CopyTuner]', original_logger)
|
313
314
|
end
|
314
315
|
|
315
316
|
# Sync interval for Rack Middleware
|
316
317
|
def sync_interval
|
317
|
-
if environment_name ==
|
318
|
+
if environment_name == 'staging'
|
318
319
|
@sync_interval_staging
|
319
320
|
else
|
320
321
|
@sync_interval
|
@@ -323,7 +324,15 @@ module CopyTunerClient
|
|
323
324
|
|
324
325
|
# @return [String] current project url by api_key
|
325
326
|
def project_url
|
326
|
-
|
327
|
+
path =
|
328
|
+
if project_id
|
329
|
+
"/projects/#{project_id}"
|
330
|
+
else
|
331
|
+
ActiveSupport::Deprecation.new.warn('Please set project_id.')
|
332
|
+
"/projects/#{api_key}"
|
333
|
+
end
|
334
|
+
|
335
|
+
URI::Generic.build(scheme: self.protocol, host: self.host, port: self.port.to_i, path:).to_s
|
327
336
|
end
|
328
337
|
|
329
338
|
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.20.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SonicGarden
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-03-05 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.1'
|
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.1'
|
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
|
-
- gemfiles/7.0.gemfile
|
206
204
|
- gemfiles/7.1.gemfile
|
205
|
+
- gemfiles/7.2.gemfile
|
206
|
+
- gemfiles/8.0.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: []
|