1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

make deprecation a bit more flexible and deprecate setters

This commit is contained in:
geemus 2010-05-04 14:31:42 -07:00
parent 3197c257b5
commit 4a5faf5a79
7 changed files with 20 additions and 15 deletions

View file

@ -8,8 +8,9 @@ module Fog
class Directory < Fog::Model
extend Fog::Deprecation
deprecate(:name, :key)
deprecate(:name=, :key=)
identity :key, ['Name', 'name', :name]
identity :key, ['Name', 'name']
attribute :creation_date, 'CreationDate'

View file

@ -8,7 +8,7 @@ module Fog
warning = "[yellow][WARN] #{self} => ##{older} is deprecated, use ##{newer} instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
#{newer}(*args)
send(:#{newer}, *args)
end
EOS
end

View file

@ -24,14 +24,14 @@ module Fog
data = Dir.entries(connection.local_root).select do |entry|
entry[0...1] != '.' && ::File.directory?(connection.path_to(entry))
end.map do |entry|
{:name => entry}
{:key => entry}
end
load(data)
end
def get(name)
if ::File.directory?(connection.path_to(name))
new(:name => name)
def get(key)
if ::File.directory?(connection.path_to(key))
new(:key => key)
else
nil
end

View file

@ -5,11 +5,14 @@ module Fog
module Local
class Directory < Fog::Model
extend Fog::Deprecation
deprecate(:name, :key)
deprecate(:name=, :key=)
identity :name
identity :key
def destroy
requires :name
requires :key
if ::File.directory?(path)
Dir.rmdir(path)
@ -29,7 +32,7 @@ module Fog
end
def save
requires :name
requires :key
Dir.mkdir(path)
true
@ -38,7 +41,7 @@ module Fog
private
def path
connection.path_to(name)
connection.path_to(key)
end
end

View file

@ -49,7 +49,7 @@ module Fog
end
def path
connection.path_to(::File.join(directory.name, key))
connection.path_to(::File.join(directory.key, key))
end
end

View file

@ -9,8 +9,8 @@ module Fog
model Fog::Local::File
def all
if directory.collection.get(directory.name)
data = Dir.entries(connection.path_to(directory.name)).select do |key|
if directory.collection.get(directory.key)
data = Dir.entries(connection.path_to(directory.key)).select do |key|
key[0...1] != '.' && !::File.directory?(connection.path_to(key))
end.map do |key|
path = file_path(key)
@ -66,7 +66,7 @@ module Fog
end
def file_path(key)
connection.path_to(::File.join(directory.name, key))
connection.path_to(::File.join(directory.key, key))
end
end

View file

@ -8,8 +8,9 @@ module Fog
class Directory < Fog::Model
extend Fog::Deprecation
deprecate(:name, :key)
deprecate(:name=, :key=)
identity :key, ['name', :name]
identity :key, ['name']
attribute :bytes
attribute :count