Class: Hiiro::Fuzzyfind

Inherits:
Object
  • Object
show all
Defined in:
lib/hiiro/fuzzyfind.rb

Constant Summary collapse

TOOLS =
%w[sk fzf]

Class Method Summary collapse

Class Method Details

.map_select(mapping) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/hiiro/fuzzyfind.rb', line 24

def self.map_select(mapping)
  keys = mapping.keys

  key = select(keys)

  mapping[key.to_s.chomp]
end

.select(lines) ⇒ Object



20
21
22
# File 'lib/hiiro/fuzzyfind.rb', line 20

def self.select(lines)
  Shell.pipe_lines(lines, tool!)
end

.toolObject



7
8
9
# File 'lib/hiiro/fuzzyfind.rb', line 7

def self.tool
  TOOLS.find { |name| system("command -v #{name} &>/dev/null") }
end

.tool!Object



11
12
13
14
15
16
17
18
# File 'lib/hiiro/fuzzyfind.rb', line 11

def self.tool!
  match = tool

  return match if match

  puts "ERROR: No fuzzyfinder found!"
  exit 1
end