2010-10-04 17:02:08 -04:00
|
|
|
require 'fog/core/collection'
|
2010-09-21 13:54:15 -04:00
|
|
|
require 'fog/local/models/storage/directory'
|
2010-09-08 15:50:38 -04:00
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Local
|
|
|
|
class Storage
|
|
|
|
|
|
|
|
class Directories < Fog::Collection
|
|
|
|
|
2010-09-21 13:54:15 -04:00
|
|
|
model Fog::Local::Storage::Directory
|
2010-09-08 15:50:38 -04:00
|
|
|
|
|
|
|
def all
|
|
|
|
data = Dir.entries(connection.local_root).select do |entry|
|
|
|
|
entry[0...1] != '.' && ::File.directory?(connection.path_to(entry))
|
|
|
|
end.map do |entry|
|
|
|
|
{:key => entry}
|
|
|
|
end
|
|
|
|
load(data)
|
|
|
|
end
|
|
|
|
|
|
|
|
def get(key)
|
|
|
|
if ::File.directory?(connection.path_to(key))
|
|
|
|
new(:key => key)
|
|
|
|
else
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|