2010-05-02 05:10:11 +00:00
|
|
|
module Fog
|
2010-09-03 08:11:45 +00:00
|
|
|
class Local < Fog::Service
|
2010-05-02 05:10:11 +00:00
|
|
|
|
2010-06-12 22:31:17 +00:00
|
|
|
requires :local_root
|
2010-05-02 05:10:11 +00:00
|
|
|
|
2010-06-12 22:31:17 +00:00
|
|
|
model_path 'fog/local/models'
|
2010-09-02 23:01:19 +00:00
|
|
|
collection :directories
|
|
|
|
model :directory
|
|
|
|
model :file
|
|
|
|
collection :files
|
2010-05-02 05:10:11 +00:00
|
|
|
|
|
|
|
class Mock
|
2010-06-12 22:31:17 +00:00
|
|
|
include Collections
|
2010-05-02 05:10:11 +00:00
|
|
|
|
|
|
|
def self.data
|
|
|
|
@data ||= Hash.new do |hash, key|
|
|
|
|
hash[key] = {}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.reset_data(keys=data.keys)
|
|
|
|
for key in [*keys]
|
|
|
|
data.delete(key)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def initialize(options={})
|
|
|
|
@local_root = ::File.expand_path(options[:local_root])
|
|
|
|
@data = self.class.data[@local_root]
|
|
|
|
end
|
|
|
|
|
|
|
|
def local_root
|
|
|
|
@local_root
|
|
|
|
end
|
|
|
|
|
|
|
|
def path(partial)
|
|
|
|
partial
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class Real
|
2010-06-12 22:31:17 +00:00
|
|
|
include Collections
|
2010-05-02 05:10:11 +00:00
|
|
|
|
|
|
|
def initialize(options={})
|
|
|
|
@local_root = ::File.expand_path(options[:local_root])
|
|
|
|
end
|
|
|
|
|
|
|
|
def local_root
|
|
|
|
@local_root
|
|
|
|
end
|
|
|
|
|
|
|
|
def path_to(partial)
|
|
|
|
::File.join(@local_root, partial)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|