class I18nChecker::Unused::Detector
Public Class Methods
new(locale_files)
click to toggle source
# File lib/i18n_checker/unused/detector.rb, line 7 def initialize(locale_files) @locale_files = locale_files end
Public Instance Methods
detect(locale_texts)
click to toggle source
# File lib/i18n_checker/unused/detector.rb, line 11 def detect(locale_texts) unused_texts = cleaned_locale_files(locale_texts).map do |locale_file| locale_file.locale_texts.map do |key, _v| I18nChecker::Unused::Text.new( text: key, file: locale_file, ) end end I18nChecker::Unused::Result.new(unused_texts.compact.flatten) end
Private Instance Methods
cleaned_locale_files(locale_texts)
click to toggle source
# File lib/i18n_checker/unused/detector.rb, line 25 def cleaned_locale_files(locale_texts) remove_locale_texts = used_locale_texts(locale_texts) @locale_files.map { |locale_file| locale_file.remove_texts(remove_locale_texts) } end
used_locale_texts(locale_texts)
click to toggle source
# File lib/i18n_checker/unused/detector.rb, line 30 def used_locale_texts(locale_texts) used_locale_texts = locale_texts.dup.select do |locale_text| @locale_files.any? { |locale_file| locale_file.include?(locale_text) } end used_locale_texts.map(&:text) end