From 9e0dd9085cba846808e6cd8d697958e6049a0f2c Mon Sep 17 00:00:00 2001 From: aki Date: Mon, 22 Apr 2024 21:26:09 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20html=5Fescape=E8=A8=AD=E5=AE=9A?= =?UTF-8?q?=E3=82=92=E5=BF=85=E9=A0=88=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 2 +- lib/copy_tuner_client/configuration.rb | 9 ++++++++- lib/copy_tuner_client/version.rb | 2 +- spec/copy_tuner_client/i18n_backend_spec.rb | 4 ++-- spec/support/client_spec_helpers.rb | 1 + 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 2e70ced..bce6ffe 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,6 @@ { "editor.codeActionsOnSave": { - "source.fixAll.eslint": true, + "source.fixAll.eslint": "explicit" }, "typescript.tsdk": "node_modules/typescript/lib", "typescript.preferences.importModuleSpecifier": "non-relative", diff --git a/lib/copy_tuner_client/configuration.rb b/lib/copy_tuner_client/configuration.rb index d5a13be..f8430a3 100644 --- a/lib/copy_tuner_client/configuration.rb +++ b/lib/copy_tuner_client/configuration.rb @@ -157,13 +157,20 @@ def initialize self.upload_disabled_environments = %w[production staging] self.s3_host = 'copy-tuner-data-prod.s3.amazonaws.com' self.disable_copyray_comment_injection = false - self.html_escape = false + # TODO: 0.18.0以降のバージョンで初期値をtrueにしたい + self.html_escape = nil self.ignored_keys = [] self.ignored_key_handler = -> (e) { raise e } @applied = false end + def html_escape + raise 'CopyTunerClient.configuration.html_escape is required' if @html_escape.nil? + + @html_escape + end + # Allows config options to be read like a hash # # @param [Symbol] option Key for a given attribute diff --git a/lib/copy_tuner_client/version.rb b/lib/copy_tuner_client/version.rb index c9aed9a..2872753 100644 --- a/lib/copy_tuner_client/version.rb +++ b/lib/copy_tuner_client/version.rb @@ -1,6 +1,6 @@ module CopyTunerClient # Client version - VERSION = '0.16.3'.freeze + VERSION = '0.17.0'.freeze # API version being used to communicate with the server API_VERSION = '2.0'.freeze diff --git a/spec/copy_tuner_client/i18n_backend_spec.rb b/spec/copy_tuner_client/i18n_backend_spec.rb index aaa2e1c..06c86ff 100644 --- a/spec/copy_tuner_client/i18n_backend_spec.rb +++ b/spec/copy_tuner_client/i18n_backend_spec.rb @@ -111,10 +111,10 @@ def build_backend expect(cache['en.test.key']).to eq 'default %{interpolate}' end - it "marks strings as html safe" do + it "dose not mark strings as html safe" do cache['en.test.key'] = FakeHtmlSafeString.new("Hello") backend = build_backend - expect(backend.translate('en', 'test.key')).to be_html_safe + expect(backend.translate('en', 'test.key')).to_not be_html_safe end it "looks up an array of defaults" do diff --git a/spec/support/client_spec_helpers.rb b/spec/support/client_spec_helpers.rb index db6f63e..7794faa 100644 --- a/spec/support/client_spec_helpers.rb +++ b/spec/support/client_spec_helpers.rb @@ -4,6 +4,7 @@ def reset_config CopyTunerClient.configure(false) do |config| config.api_key = 'abc123' config.s3_host = 'copy-tuner.com' + config.html_escape = true end end end