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:
parent
3197c257b5
commit
4a5faf5a79
7 changed files with 20 additions and 15 deletions
|
@ -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'
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue