Skip to content

Commit

Permalink
Feat(Ruby): Ignore class/style string values
Browse files Browse the repository at this point in the history
  • Loading branch information
zealot128 committed Aug 27, 2024
1 parent d3b533a commit 00d066b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/extract_i18n.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require "zeitwerk"
loader = Zeitwerk::Loader.for_gem
loader.inflector.inflect(
"html_extractor" => "HTMLExtractor",
"html_extractor" => "HTMLExtractor",
)
loader.setup # ready!

Expand All @@ -17,14 +17,18 @@ 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 = [
'_',
'::',
'v-else',
'v-else-if',
'&nbsp;',
'https:',
'http:',
%r{^#[^ ]+$},
%r{^/},
%r{^(mdi|fa|fas|far|icon)-},
Expand Down
10 changes: 10 additions & 0 deletions spec/adapters/ruby_adapter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down

0 comments on commit 00d066b

Please sign in to comment.