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/storage/local.rb

78 lines
1.9 KiB
Ruby
Raw Normal View History

module Fog
module Local
class Storage < Fog::Service
requires :local_root
2011-01-07 21:14:39 -05:00
recognizes :provider # remove post deprecation
2011-01-07 18:41:51 -05:00
model_path 'fog/storage/models/local'
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={})
Fog::Mock.not_implemented
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
@local_root = ::File.expand_path(options[:local_root])
2011-03-21 13:54:07 -04:00
@data = self.class.data[@local_root]
end
def local_root
@local_root
end
def path_to(partial)
::File.join(@local_root, partial)
end
def reset_data
self.class.data.delete(@local_root)
@data = self.class.data[@local_root]
end
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
require 'mime/types'
@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