Module: Noty::Services

Defined in:
lib/noty/services/search.rb

Class Method Summary collapse

Class Method Details

.search(keyword) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/noty/services/search.rb', line 5

def search(keyword)
  files = `ag -l "#{keyword}" #{STORAGE_PATH}`.lines
  top_matches = files[0...9].map(&:chomp)
  top_matches.map do |file|
    case File.extname(file)
    when '.bookmark'
      Bookmark.new(file)
    when '.snippet'
      Snippet.new(file)
    end
  end
end