From 00d066bdff8edd5ba78999dfafeb576476301974 Mon Sep 17 00:00:00 2001 From: Stefan Wienert Date: Tue, 27 Aug 2024 12:47:40 +0000 Subject: [PATCH] Feat(Ruby): Ignore class/style string values --- lib/extract_i18n.rb | 8 ++++++-- spec/adapters/ruby_adapter_spec.rb | 10 ++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/extract_i18n.rb b/lib/extract_i18n.rb index 5326924..c8fb055 100644 --- a/lib/extract_i18n.rb +++ b/lib/extract_i18n.rb @@ -5,7 +5,7 @@ require "zeitwerk" loader = Zeitwerk::Loader.for_gem loader.inflector.inflect( - "html_extractor" => "HTMLExtractor", + "html_extractor" => "HTMLExtractor", ) loader.setup # ready! @@ -17,7 +17,9 @@ class << self self.strip_path = %r{^app/(javascript|controllers|views)|^lib|^src|^app} # ignore for .rb files: ignore those file types - self.ignore_hash_keys = %w[class_name foreign_key join_table association_foreign_key key] + self.ignore_hash_keys = %w[class_name foreign_key join_table + association_foreign_key key class style type disabled format username + password layout] self.ignore_functions = %w[where order group select sql] self.ignorelist = [ '_', @@ -25,6 +27,8 @@ class << self 'v-else', 'v-else-if', ' ', + 'https:', + 'http:', %r{^#[^ ]+$}, %r{^/}, %r{^(mdi|fa|fas|far|icon)-}, diff --git a/spec/adapters/ruby_adapter_spec.rb b/spec/adapters/ruby_adapter_spec.rb index abb491c..bc11e2f 100644 --- a/spec/adapters/ruby_adapter_spec.rb +++ b/spec/adapters/ruby_adapter_spec.rb @@ -40,6 +40,16 @@ ] end + specify 'Ignore class and style attributes' do + file = <<~DOC + div(class: "foo", style: "bar") { + } + DOC + expect(run(file)).to be == [ + file, {} + ] + end + specify 'Ignore active record functions' do file = <<~DOC sql = User.where("some SQL Condition is true").order(Arel.sql("Foobar"))