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