lib/scrapple/file_system_bag.rb
# Get the paths of the children of a path
Get the paths of the children of a path
Get the paths of the children of a path
def ls(path)
      path = rewrite(path)
      return [] unless has_children?(path)
      base = directory?(path) ? path : path.dirname
      paths = Pathname.glob((@root + base) + "/*")
      sh = paths.map do |pa|
        sortkey = ""
        sortkey << indexfile?(pa) ? "1/" : "2/"
        sortkey << directory?(pa) ? "1/" : "2/"
        sortkey << pa
        [sortkey, pa]
      end
      sh.sort{|a,b| a.first <=> b.first }.map { |a| a.last.relative_path_from(@root) }
    end
def ls ( path ) path = rewrite ( path ) return [ ] unless has_children? ( path ) base = directory? ( path ) ? path : path . dirname paths = Pathname . glob ( ( @root + base ) + "/*" ) sh = paths . map do | pa | sortkey = "" sortkey << indexfile? ( pa ) ? "1/" : "2/" sortkey << directory? ( pa ) ? "1/" : "2/" sortkey << pa [ sortkey , pa ] end sh . sort { | a , b | a . first <=> b . first } . map { | a | a . last . relative_path_from ( @root ) } end
Get the paths of the children of a path
Get the paths of the children of a path
# Sort indexfiles-first, directories-first, then by name. (A Shwartzian transform) # Got idea from http://bit.ly/d4UaMM
path
<not_specific>