module Yamlook::Search
Searches for occurrences of dot-notated keys in all yaml files of current directory
Constants
- EXTENSIONS
- NoArgumentsError
- PATTERN
Public Instance Methods
perform(keys)
click to toggle source
# File lib/yamlook/search.rb, line 14 def perform(keys) raise NoArgumentsError, "Nothing to search for.\n" if keys.empty? findings = Dir.glob(PATTERN).flat_map do |filename| result = File.new(filename).search(keys) print_progress(result) result end print_result(findings.compact) rescue NoArgumentsError => e puts e.message end
print_failure()
click to toggle source
# File lib/yamlook/search.rb, line 38 def print_failure puts 'Nothing found.' end
print_progress(result)
click to toggle source
# File lib/yamlook/search.rb, line 28 def print_progress(result) print result ? "\033[32m*\033[0m" : "\033[33m.\033[0m" end
print_result(findings)
click to toggle source
# File lib/yamlook/search.rb, line 32 def print_result(findings) puts puts '-' * 10 findings.any? ? print_success(findings) : print_failure end
print_success(findings)
click to toggle source
# File lib/yamlook/search.rb, line 42 def print_success(findings) print "Found #{findings.count} occurrences:" findings.each do |finding| puts puts finding end end