2011-08-31 16:52:53 -04:00
|
|
|
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'storage'))
|
|
|
|
require 'fog/storage'
|
|
|
|
|
2010-09-08 15:50:38 -04:00
|
|
|
module Fog
|
2011-06-15 17:26:43 -04:00
|
|
|
module Storage
|
|
|
|
class Local < Fog::Service
|
2010-09-08 15:50:38 -04:00
|
|
|
|
2010-12-16 18:31:24 -05:00
|
|
|
requires :local_root
|
2010-09-08 15:50:38 -04:00
|
|
|
|
2011-08-24 15:07:16 -04:00
|
|
|
model_path 'fog/local/models/storage'
|
2010-09-08 15:50:38 -04:00
|
|
|
collection :directories
|
|
|
|
model :directory
|
|
|
|
model :file
|
|
|
|
collection :files
|
|
|
|
|
|
|
|
class Mock
|
|
|
|
|
|
|
|
def self.data
|
|
|
|
@data ||= Hash.new do |hash, key|
|
|
|
|
hash[key] = {}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-05-19 10:05:33 -04:00
|
|
|
def self.reset
|
|
|
|
@data = nil
|
|
|
|
end
|
|
|
|
|
2010-09-08 15:50:38 -04:00
|
|
|
def initialize(options={})
|
2011-01-17 21:04:00 -05:00
|
|
|
Fog::Mock.not_implemented
|
|
|
|
|
2011-01-26 18:56:39 -05:00
|
|
|
require 'mime/types'
|
2010-09-08 15:50:38 -04:00
|
|
|
@local_root = ::File.expand_path(options[:local_root])
|
2011-05-19 18:35:33 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def data
|
|
|
|
self.class.data[@local_root]
|
2010-09-08 15:50:38 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def local_root
|
|
|
|
@local_root
|
|
|
|
end
|
|
|
|
|
2010-12-14 14:43:59 -05:00
|
|
|
def path_to(partial)
|
|
|
|
::File.join(@local_root, partial)
|
2010-09-08 15:50:38 -04:00
|
|
|
end
|
2011-03-10 14:16:55 -05:00
|
|
|
|
|
|
|
def reset_data
|
|
|
|
self.class.data.delete(@local_root)
|
|
|
|
end
|
|
|
|
|
2010-09-08 15:50:38 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
class Real
|
|
|
|
|
|
|
|
def initialize(options={})
|
2011-01-26 18:56:39 -05:00
|
|
|
require 'mime/types'
|
2010-09-08 15:50:38 -04:00
|
|
|
@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
|
|
|
|
end
|