class FindT::Scanner
Public Class Methods
new(root_path:, rails: false)
click to toggle source
# File lib/find_t/scanner.rb, line 8 def initialize(root_path:, rails: false) @root_path, @rails = Pathname.new(root_path), rails end
Public Instance Methods
files()
click to toggle source
# File lib/find_t/scanner.rb, line 12 def files return @files if @files if @rails rails_env_file = File.expand_path @root_path.join('config', 'environment') if File.exists? rails_env_file require rails_env_file else raise RailsNotFoundError.new('Cannot find rails environment file') end @files = I18n.load_path else @files = Dir.glob @root_path.join('config', 'locales', '**', '*.{yaml,yml}') end @files end
scan(key)
click to toggle source
# File lib/find_t/scanner.rb, line 32 def scan(key) return if !key || '' == key scopes = key.split('.').unshift nil founds = [] files.reverse.each do |file| founds += FileScanner.new(file).find scopes end founds end