2010-09-08 15:50:38 -04:00
|
|
|
module Fog
|
|
|
|
module Local
|
2010-10-13 04:42:11 -04:00
|
|
|
class Storage < Fog::Service
|
2010-09-08 15:50:38 -04:00
|
|
|
|
2010-12-16 18:31:24 -05:00
|
|
|
requires :local_root
|
2011-01-07 21:14:39 -05:00
|
|
|
recognizes :provider # remove post deprecation
|
2010-09-08 15:50:38 -04:00
|
|
|
|
2011-01-07 18:41:51 -05:00
|
|
|
model_path 'fog/storage/models/local'
|
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
|
|
|
|
|
|
|
|
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'
|
2011-01-07 21:14:39 -05:00
|
|
|
unless options.delete(:provider)
|
|
|
|
location = caller.first
|
|
|
|
warning = "[yellow][WARN] Fog::Local::Storage.new is deprecated, use Fog::Storage.new(:provider => 'Local') instead[/]"
|
|
|
|
warning << " [light_black](" << location << ")[/] "
|
|
|
|
Formatador.display_line(warning)
|
|
|
|
end
|
|
|
|
|
2010-09-08 15:50:38 -04:00
|
|
|
@local_root = ::File.expand_path(options[:local_root])
|
2011-03-10 14:16:55 -05:00
|
|
|
reset_data
|
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)
|
|
|
|
@data = self.class.data[@local_root]
|
|
|
|
end
|
|
|
|
|
2010-09-08 15:50:38 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
class Real
|
|
|
|
|
|
|
|
def initialize(options={})
|
2011-01-07 21:14:39 -05:00
|
|
|
unless options.delete(:provider)
|
|
|
|
location = caller.first
|
|
|
|
warning = "[yellow][WARN] Fog::Local::Storage.new is deprecated, use Fog::Storage.new(:provider => 'Local') instead[/]"
|
|
|
|
warning << " [light_black](" << location << ")[/] "
|
|
|
|
Formatador.display_line(warning)
|
|
|
|
end
|
|
|
|
|
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
|