class Yamlook::File
Yaml file to perform search
Attributes
filename[R]
Public Class Methods
new(filename)
click to toggle source
# File lib/yamlook/file.rb, line 8 def initialize(filename) @filename = filename end
Public Instance Methods
search(keys)
click to toggle source
# File lib/yamlook/file.rb, line 12 def search(keys) file = ::File.read(filename) handler = Handler.new(keys: keys, locales: LOCALES) parser = ::Psych::Parser.new(handler) findings = parser.parse(file).handler.found.map do |value, line, column| "#{filename}:#{line}:#{column}\n#{value}" end findings if findings.any? rescue ::Psych::Exception nil end