module Flunkey::PathnameExtensions

Constants

BUNDLE_TEST
EXCLUDE_PATTERNS

Public Instance Methods

browsable?() click to toggle source
# File lib/flunkey/pathname_extensions.rb, line 13
def browsable?
  return false unless exist? && readable?
  return false if bundle?
  return true if directory?
  false
end
bundle?() click to toggle source
# File lib/flunkey/pathname_extensions.rb, line 31
def bundle?
  return false unless directory?
  return true if `/usr/bin/mdls -name kMDItemContentTypeTree #{to_s}` =~ BUNDLE_TEST
  false
end
compressable?() click to toggle source
# File lib/flunkey/pathname_extensions.rb, line 26
def compressable?
  return false unless exist? && readable?
  true
end
downloadable?() click to toggle source
# File lib/flunkey/pathname_extensions.rb, line 20
def downloadable?
  return false unless exist? && readable?
  return false if directory?
  true
end
exclude_patterns() click to toggle source
# File lib/flunkey/pathname_extensions.rb, line 9
def exclude_patterns
  @exclude_patterns || EXCLUDE_PATTERNS
end
excluded?() click to toggle source
# File lib/flunkey/pathname_extensions.rb, line 37
def excluded?
  return true if exclude_patterns.any?{|pat| pat.match self.basename.to_s}
end
filtered_children() click to toggle source
# File lib/flunkey/pathname_extensions.rb, line 56
def filtered_children
  children.delete_if(&:excluded?)
end
is_parent_of?(path) click to toggle source
# File lib/flunkey/pathname_extensions.rb, line 45
def is_parent_of?(path)
  return false if path.nil?
  return false unless self.absolute? && path.absolute?
  return false if self == path
  p = path.to_s.split('/')
  self.to_s.split('/').each_with_index { |elem, idx|
    return false unless elem == p[idx]
  }
  true
end
metadata(*keys) click to toggle source
# File lib/flunkey/pathname_extensions.rb, line 41
def metadata(*keys)
  @metadata ||= Flunkey::Metadata.parse `/usr/bin/mdls #{to_s}`
end