module Flunkey::Functions
Public Instance Methods
recognize(path)
click to toggle source
# File lib/flunkey/functions.rb, line 3 def recognize(path) return if path.nil? path = Pathname.new(path) unless path === Pathname if path.relative? first_dir = path.to_s.split('/').first root = settings.paths.find{|p| p.basename.to_s == first_dir } return [root, (root.root? ? Pathname.new('/') : root.parent) + path] end root = settings.paths.find{|p| p.is_parent_of?(path) } [root, path] end
search(query)
click to toggle source
# File lib/flunkey/functions.rb, line 15 def search(query) cmd = %w{/usr/bin/mdfind} settings.paths.each { |p| cmd << "-onlyin #{p}" } cmd << "\"#{query}\"" `#{cmd.join(' ')}`.lines.map{|l| recognize(l.strip) } end