Skip to content

Commit

Permalink
Merge pull request #93 from SonicGarden/fix-ignored-keys
Browse files Browse the repository at this point in the history
[review] ignored_keys設定されたキーがアップロードされる場合はエラーが発生するように修正
  • Loading branch information
aki77 authored Aug 27, 2024
2 parents 0ff3939 + 5b22791 commit db6c901
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions lib/copy_tuner_client/cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ def initialize(client, options)
@mutex = Mutex.new
@exclude_key_regexp = options[:exclude_key_regexp]
@upload_disabled = options[:upload_disabled]
@ignored_keys = options.fetch(:ignored_keys, [])
@ignored_key_handler = options.fetch(:ignored_key_handler, -> (e) { raise e })
@locales = Array(options[:locales]).map(&:to_s)
# mutable states
@blurbs = {}
Expand All @@ -44,6 +46,12 @@ def []=(key, value)
return if @locales.present? && !@locales.member?(key.split('.').first)
return if @upload_disabled

# NOTE: config/locales以下のファイルに除外キーが残っていた場合の対応
key_without_locale = key.split('.')[1..].join('.')
if @ignored_keys.include?(key_without_locale)
@ignored_key_handler.call(IgnoredKey.new("Ignored key: #{key_without_locale}"))
end

lock do
return if @blank_keys.member?(key) || @blurbs.key?(key)

Expand Down
2 changes: 1 addition & 1 deletion lib/copy_tuner_client/version.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module CopyTunerClient
# Client version
VERSION = '0.17.1'.freeze
VERSION = '0.18.0'.freeze

# API version being used to communicate with the server
API_VERSION = '2.0'.freeze
Expand Down

0 comments on commit db6c901

Please sign in to comment.