copy_tuner_client 1.3.0 → 1.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d298d7f59a4cacd30c925e2a0af2b6026fbd3610d4564fae70e5b6efbad4ad0c
4
- data.tar.gz: 0f7e09019505a1b49353550b696a2f4a0a4a40eaf74573e4a4e916ec547bd1e9
3
+ metadata.gz: 10935db209e8b915ac8101dfa324bf5a40da15978124e8300746c0be13407862
4
+ data.tar.gz: faa6e39b7149540c342ec9fcefce9f0c47425614c4f361fa8b8b597ff932d69c
5
5
  SHA512:
6
- metadata.gz: 934b99a1624d8dd517c9f2df68c37ffb667128beca73222db458b5f973534398eda88f01c6550c48219e54205fb14b6e47d9731f9556ec0c55d06ce5b47b3729
7
- data.tar.gz: 11e6f16e6792603ee6d5c74f4888f293895cf483d10f88d57298bc80bd54a05cb50da5dcdba2c9ade055bf6d57afe66a398b355de806a87a0528dea9e19efaae
6
+ metadata.gz: 83ea46e846b20d110366e5d8d7ecb5c415a082a700e45682931e2303a7516e50c6d1b0fcdce5ea7deada42dd3ef7e6f9df07ff4084c3b211db0cb42d1de1d422
7
+ data.tar.gz: 194dc1188ab23b9776b030ec08c453444513a8f55d6b674d4b06b6953c652409951690bbfad569b1e2524a02c7951f5faeb55a4fe0d1eafbfd77c61d72cb2a45
@@ -0,0 +1,18 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "github-actions"
4
+ directory: "/"
5
+ cooldown:
6
+ default-days: 5
7
+ ignore:
8
+ - dependency-name: "ruby/setup-ruby"
9
+ update-types:
10
+ - "version-update:semver-patch"
11
+ - "version-update:semver-minor"
12
+ - dependency-name: "actions/checkout"
13
+ update-types:
14
+ - "version-update:semver-patch"
15
+ - "version-update:semver-minor"
16
+ schedule:
17
+ # Check for updates to GitHub Actions every weekday
18
+ interval: "weekly"
@@ -22,14 +22,12 @@ jobs:
22
22
  strategy:
23
23
  fail-fast: false
24
24
  matrix:
25
- ruby: ["3.1", "3.2", "3.3", "3.4"]
26
- gemfile: ["7.1", "7.2", "8.0", "main"]
25
+ ruby: ["3.3", "3.4", "4.0"]
26
+ gemfile: ["8.0", "8.1", "main"]
27
27
  exclude:
28
- - ruby: "3.1"
29
- gemfile: "8.0"
30
- - ruby: "3.1"
28
+ - ruby: "3.3"
31
29
  gemfile: "main"
32
- - ruby: "3.2"
30
+ - ruby: "3.4"
33
31
  gemfile: "main"
34
32
  steps:
35
33
  - name: Install packages
@@ -37,7 +35,7 @@ jobs:
37
35
  sudo apt update -y
38
36
  sudo apt install -y libsqlite3-dev
39
37
 
40
- - uses: actions/checkout@v2
38
+ - uses: actions/checkout@v6
41
39
 
42
40
  - name: Set up Ruby
43
41
  uses: ruby/setup-ruby@v1
data/.rubocop.yml CHANGED
@@ -1,2 +1,7 @@
1
1
  inherit_gem:
2
2
  sgcop: ruby/rubocop.yml
3
+
4
+ # .ruby-version が RuboCop 未対応の新しい Ruby を指すと解析が落ちるため、
5
+ # サポート最低バージョンを明示する
6
+ AllCops:
7
+ TargetRubyVersion: 3.3
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.4.5
1
+ 4.0.5
@@ -2,11 +2,11 @@ $LOAD_PATH.push File.expand_path('lib', __dir__)
2
2
  require 'copy_tuner_client/version'
3
3
 
4
4
  Gem::Specification.new do |s|
5
- s.required_ruby_version = '>= 3.1.0'
5
+ s.required_ruby_version = '>= 3.3.0'
6
6
  s.add_dependency 'i18n', '>= 0.5.0'
7
7
  s.add_dependency 'json'
8
8
  s.add_dependency 'nokogiri'
9
- s.add_development_dependency 'rails', '~> 7.1'
9
+ s.add_development_dependency 'rails', '~> 8.0'
10
10
  s.add_development_dependency 'rake'
11
11
  s.add_development_dependency 'rspec'
12
12
  s.add_development_dependency 'sham_rack'
@@ -1,5 +1,5 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem "rails", "~> 7.1"
3
+ gem "rails", "~> 8.1"
4
4
 
5
5
  gemspec :path => "../"
@@ -3,9 +3,7 @@ module CopyTunerClient
3
3
  def to_h(dotted_hash)
4
4
  hash = {}
5
5
  dotted_hash.to_h.transform_keys(&:to_s).sort.each do |key, value|
6
- # Rails i18n標準との互換性のため、特定のキーを適切な型に変換
7
- converted_value = convert_value_type(key, value)
8
- _hash = key.split('.').reverse.inject(converted_value) { |memo, _key| { _key => memo } }
6
+ _hash = key.split('.').reverse.inject(value) { |memo, _key| { _key => memo } }
9
7
  hash.deep_merge!(_hash)
10
8
  end
11
9
  hash
@@ -29,22 +27,6 @@ module CopyTunerClient
29
27
  results
30
28
  end
31
29
 
32
- private
33
-
34
- def convert_value_type(key, value)
35
- return value unless value.is_a?(String)
36
-
37
- # Rails i18n標準で数値型として扱われるキー
38
- if key.end_with?('.precision')
39
- value.to_i
40
- # Rails i18n標準で真偽値として扱われるキー
41
- elsif key.end_with?('.significant', '.strip_insignificant_zeros')
42
- value == 'true'
43
- else
44
- value
45
- end
46
- end
47
-
48
- module_function :to_h, :conflict_keys, :convert_value_type # rubocop:disable Style/AccessModifierDeclarations
30
+ module_function :to_h, :conflict_keys # rubocop:disable Style/AccessModifierDeclarations
49
31
  end
50
32
  end
@@ -1,6 +1,6 @@
1
1
  module CopyTunerClient
2
2
  # Client version
3
- VERSION = '1.3.0'.freeze
3
+ VERSION = '1.4.0'.freeze
4
4
 
5
5
  # API version being used to communicate with the server
6
6
  API_VERSION = '2.0'.freeze
@@ -18,13 +18,19 @@ license: MIT
18
18
  | 判別 | 管理場所 | 操作 |
19
19
  |---|---|---|
20
20
  | マッチする | config/locales(copy_tuner と完全分離) | `config/locales/*.yml` を Read / Edit |
21
- | マッチしない・未設定 | copy_tuner | MCP ツール(下記) |
21
+ | マッチしない・未設定 | copy_tuner | **MCP ツール経由でのみ探す**(下記) |
22
+
23
+ **copy_tuner 管理のキーは必ず MCP ツール経由で探すこと。** ローカルの `.yml` を grep して見つけたつもりになってはならない。
22
24
 
23
25
  **例外(gem 組み込み・設定不要で常に config/locales 管理):** Rails 標準の `number.format` /
24
26
  `number.currency.format` / `number.percentage.format` / `number.human.format`(およびその配下)。
25
27
  `precision` 等の非文字列値を含み copy_tuner では正しく扱えないため、gem が常にバイパスする。
26
28
  これらは `config/locales/*.yml` を見る・編集すること(アプリ独自の `number.gift_amount` 等は対象外で通常どおり copy_tuner)。
27
29
 
30
+ **`config/locales` 以外の export 済み yml は参照禁止:**
31
+ 環境によっては copy_tuner から export したキャッシュ用の `.yml`(`config/locales` 配下以外、例: アプリ直下や `tmp/`、`db/` などに置かれた export ファイル)が存在することがある。
32
+ これらは古いスナップショットであり権威ある情報源ではない。**読んで判断材料にしてはならない。** copy_tuner 管理キーは常に MCP ツールで最新を確認する。
33
+
28
34
  **config/locales 管理キーの落とし穴:**
29
35
  - copy_tuner には存在しないので、MCP ツールで探しても見つからない。`config/locales` を見ること。
30
36
  - copy_tuner に登録しても lookup でバイパスされ無効。必ず `.yml` 側に書く。
@@ -38,7 +44,8 @@ license: MIT
38
44
  | キー名(一部)から翻訳を調べる | `search_key`(引数は英語キーワード) |
39
45
  | 画面テキストからキーを逆引き | `search_translations` |
40
46
  | 新しいキーを登録する | `create_i18n_key` |
41
- | 既存キーの翻訳を更新する | `get_edit_url`(ブラウザ編集) |
47
+ | 既存キーのドラフト訳を更新する | `update_i18n_key` |
48
+ | 既存キーの翻訳を更新する(ブラウザ) | `get_edit_url` |
42
49
  | 使用中ロケールを確認 | `get_locales` |
43
50
 
44
51
  ## 新規キー登録
@@ -46,6 +53,19 @@ license: MIT
46
53
  1. `search_key` で関連キーを検索し、既存の命名パターンに合わせる(例: `search_key("move_out")`)。
47
54
  2. ja は必須。他は `get_locales` で確認し、存在するロケール分を登録する。
48
55
 
56
+ ## 既存キーの訳を更新する
57
+
58
+ `update_i18n_key` を使う。`key` と `translations`(ロケール・値のペア配列)は両方必須。
59
+
60
+ **制約**: ドラフト状態または未発行のキーのみ更新可能。発行済み(published)かどうかを事前に知る手段はなく、API にリクエストしてエラーが返るかどうかで初めてわかる。
61
+
62
+ **published キーへの対応方針**: 値を直接書き換えるのはリスクが高いため、原則として以下の手順を推奨する:
63
+ 1. 新しいキーにバージョン番号を付けて登録する(例: `views.foo_v2`)→ **新規キー登録の手順に従う**
64
+ 2. コード側の参照を新キーに差し替える
65
+ 3. 古いキーを `config/initializers/copy_tuner.rb` の `ignored_keys` に追加する
66
+
67
+ どうしても既存キーを書き換えたい場合は `get_edit_url` でブラウザから編集する。
68
+
49
69
  ## 不要なキーの処理
50
70
 
51
71
  削除せず `config/initializers/copy_tuner.rb` の `ignored_keys` に追加する。
@@ -59,75 +59,22 @@ describe CopyTunerClient::DottedHash do
59
59
  it { is_expected.to eq({ 'en' => { 'test' => { 'key' => 'en test value' } } }) }
60
60
  end
61
61
 
62
- context "Rails i18nの数値precisionキーの場合" do
62
+ # NOTE: number.*.format 配下のキー(precision 等)は I18nBackend の local_first_key? ガードで
63
+ # tree_cache をバイパスしローカル YAML 優先になるため、ここで型変換せず文字列のまま保持する。
64
+ # (number_to_currency が壊れないことは i18n_backend_spec の number ローカル優先テストで担保)
65
+ context "number.*.format 配下の値を含む場合" do
63
66
  let(:dotted_hash) do
64
67
  {
65
68
  'en.number.currency.format.precision' => '2',
66
- 'en.number.format.precision' => '3',
67
- }
68
- end
69
-
70
- it "precision値を整数に変換する" do
71
- is_expected.to eq({
72
- 'en' => {
73
- 'number' => {
74
- 'currency' => {
75
- 'format' => {
76
- 'precision' => 2,
77
- },
78
- },
79
- 'format' => {
80
- 'precision' => 3,
81
- },
82
- },
83
- },
84
- })
85
- end
86
- end
87
-
88
- context "Rails i18nのbooleanキーの場合" do
89
- let(:dotted_hash) do
90
- {
91
- 'en.number.currency.format.significant' => 'false',
92
- 'en.number.format.strip_insignificant_zeros' => 'true',
93
- }
94
- end
95
-
96
- it "boolean値を実際の真偽値に変換する" do
97
- is_expected.to eq({
98
- 'en' => {
99
- 'number' => {
100
- 'currency' => {
101
- 'format' => {
102
- 'significant' => false,
103
- },
104
- },
105
- 'format' => {
106
- 'strip_insignificant_zeros' => true,
107
- },
108
- },
109
- },
110
- })
111
- end
112
- end
113
-
114
- context "Rails i18n以外で似たパターンを含むキーの場合" do
115
- let(:dotted_hash) do
116
- {
117
69
  'en.custom.precision' => 'custom_value',
118
- 'en.other.significant_value' => 'true',
119
70
  }
120
71
  end
121
72
 
122
- it "Rails i18nパターンで終わるキーのみ変換する" do
73
+ it "型変換せず値を文字列のまま保持する" do
123
74
  is_expected.to eq({
124
75
  'en' => {
125
- 'custom' => {
126
- 'precision' => 0, # .precision suffix triggers conversion
127
- },
128
- 'other' => {
129
- 'significant_value' => 'true', # no conversion for non-exact match
130
- },
76
+ 'number' => { 'currency' => { 'format' => { 'precision' => '2' } } },
77
+ 'custom' => { 'precision' => 'custom_value' },
131
78
  },
132
79
  })
133
80
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: copy_tuner_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - SonicGarden
@@ -57,14 +57,14 @@ dependencies:
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '7.1'
60
+ version: '8.0'
61
61
  type: :development
62
62
  prerelease: false
63
63
  version_requirements: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '7.1'
67
+ version: '8.0'
68
68
  - !ruby/object:Gem::Dependency
69
69
  name: rake
70
70
  requirement: !ruby/object:Gem::Requirement
@@ -185,6 +185,7 @@ files:
185
185
  - ".babelrc"
186
186
  - ".eslintrc.js"
187
187
  - ".gitattributes"
188
+ - ".github/dependabot.yml"
188
189
  - ".github/workflows/rspec.yml"
189
190
  - ".gitignore"
190
191
  - ".rspec"
@@ -200,9 +201,8 @@ files:
200
201
  - app/assets/javascripts/copytuner.js
201
202
  - app/assets/stylesheets/copytuner.css
202
203
  - copy_tuner_client.gemspec
203
- - gemfiles/7.1.gemfile
204
- - gemfiles/7.2.gemfile
205
204
  - gemfiles/8.0.gemfile
205
+ - gemfiles/8.1.gemfile
206
206
  - gemfiles/main.gemfile
207
207
  - index.html
208
208
  - lib/copy_tuner_client.rb
@@ -288,14 +288,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
288
288
  requirements:
289
289
  - - ">="
290
290
  - !ruby/object:Gem::Version
291
- version: 3.1.0
291
+ version: 3.3.0
292
292
  required_rubygems_version: !ruby/object:Gem::Requirement
293
293
  requirements:
294
294
  - - ">="
295
295
  - !ruby/object:Gem::Version
296
296
  version: '0'
297
297
  requirements: []
298
- rubygems_version: 3.6.9
298
+ rubygems_version: 4.0.10
299
299
  specification_version: 4
300
300
  summary: Client for the CopyTuner copy management service
301
301
  test_files: []
data/gemfiles/7.2.gemfile DELETED
@@ -1,5 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- gem "rails", "~> 7.2"
4
-
5
- gemspec :path => "../"