1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/local/models/storage/directories.rb
Andy Lindeman ce98e3f970 Local storage's File quacks like other Directories
Even though it doesn't accept any options, it'd be nice if it accepted
them anyway in the name of duck typing and allowing backends to be more
swappable.
2013-09-26 13:27:05 -04:00

33 lines
679 B
Ruby

require 'fog/core/collection'
require 'fog/local/models/storage/directory'
module Fog
module Storage
class Local
class Directories < Fog::Collection
model Fog::Storage::Local::Directory
def all
data = Dir.entries(service.local_root).select do |entry|
entry[0...1] != '.' && ::File.directory?(service.path_to(entry))
end.map do |entry|
{:key => entry}
end
load(data)
end
def get(key, options = {})
if ::File.directory?(service.path_to(key))
new(:key => key)
else
nil
end
end
end
end
end
end