class I18nDefScanner::Scanning

Constants

DEFAULT_LOAD_PATH
NOT_FOUND_MESSAGE

Attributes

load_path[RW]
query_path[RW]

Public Class Methods

new(load_path: DEFAULT_LOAD_PATH, query_path:) click to toggle source
# File lib/i18n_def_scanner/scanning.rb, line 10
def initialize(load_path: DEFAULT_LOAD_PATH, query_path:)
  self.load_path = load_path
  self.query_path = query_path
end

Public Instance Methods

result() click to toggle source
# File lib/i18n_def_scanner/scanning.rb, line 15
def result
  definition = nil

  files.each do |file_path|
    document_hash = I18nDefScanner::YAML.load_file(file_path)
    string_number = document_hash.dig(*query_keys)
    definition = "#{file_path}:#{string_number}" if string_number
  end

  definition || NOT_FOUND_MESSAGE
end

Private Instance Methods

files() click to toggle source
# File lib/i18n_def_scanner/scanning.rb, line 33
def files
  Dir[load_path]
end
query_keys() click to toggle source
# File lib/i18n_def_scanner/scanning.rb, line 29
def query_keys
  @query_keys ||= query_path.split('.')
end