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
|
class Directory < Fog::Model
|
||||||
extend Fog::Deprecation
|
extend Fog::Deprecation
|
||||||
deprecate(:name, :key)
|
deprecate(:name, :key)
|
||||||
|
deprecate(:name=, :key=)
|
||||||
|
|
||||||
identity :key, ['Name', 'name', :name]
|
identity :key, ['Name', 'name']
|
||||||
|
|
||||||
attribute :creation_date, 'CreationDate'
|
attribute :creation_date, 'CreationDate'
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ module Fog
|
||||||
warning = "[yellow][WARN] #{self} => ##{older} is deprecated, use ##{newer} instead[/]"
|
warning = "[yellow][WARN] #{self} => ##{older} is deprecated, use ##{newer} instead[/]"
|
||||||
warning << " [light_black](" << location << ")[/] "
|
warning << " [light_black](" << location << ")[/] "
|
||||||
Formatador.display_line(warning)
|
Formatador.display_line(warning)
|
||||||
#{newer}(*args)
|
send(:#{newer}, *args)
|
||||||
end
|
end
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,14 +24,14 @@ module Fog
|
||||||
data = Dir.entries(connection.local_root).select do |entry|
|
data = Dir.entries(connection.local_root).select do |entry|
|
||||||
entry[0...1] != '.' && ::File.directory?(connection.path_to(entry))
|
entry[0...1] != '.' && ::File.directory?(connection.path_to(entry))
|
||||||
end.map do |entry|
|
end.map do |entry|
|
||||||
{:name => entry}
|
{:key => entry}
|
||||||
end
|
end
|
||||||
load(data)
|
load(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
def get(name)
|
def get(key)
|
||||||
if ::File.directory?(connection.path_to(name))
|
if ::File.directory?(connection.path_to(key))
|
||||||
new(:name => name)
|
new(:key => key)
|
||||||
else
|
else
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,11 +5,14 @@ module Fog
|
||||||
module Local
|
module Local
|
||||||
|
|
||||||
class Directory < Fog::Model
|
class Directory < Fog::Model
|
||||||
|
extend Fog::Deprecation
|
||||||
|
deprecate(:name, :key)
|
||||||
|
deprecate(:name=, :key=)
|
||||||
|
|
||||||
identity :name
|
identity :key
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
requires :name
|
requires :key
|
||||||
|
|
||||||
if ::File.directory?(path)
|
if ::File.directory?(path)
|
||||||
Dir.rmdir(path)
|
Dir.rmdir(path)
|
||||||
|
@ -29,7 +32,7 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
def save
|
def save
|
||||||
requires :name
|
requires :key
|
||||||
|
|
||||||
Dir.mkdir(path)
|
Dir.mkdir(path)
|
||||||
true
|
true
|
||||||
|
@ -38,7 +41,7 @@ module Fog
|
||||||
private
|
private
|
||||||
|
|
||||||
def path
|
def path
|
||||||
connection.path_to(name)
|
connection.path_to(key)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -49,7 +49,7 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
def path
|
def path
|
||||||
connection.path_to(::File.join(directory.name, key))
|
connection.path_to(::File.join(directory.key, key))
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,8 +9,8 @@ module Fog
|
||||||
model Fog::Local::File
|
model Fog::Local::File
|
||||||
|
|
||||||
def all
|
def all
|
||||||
if directory.collection.get(directory.name)
|
if directory.collection.get(directory.key)
|
||||||
data = Dir.entries(connection.path_to(directory.name)).select do |key|
|
data = Dir.entries(connection.path_to(directory.key)).select do |key|
|
||||||
key[0...1] != '.' && !::File.directory?(connection.path_to(key))
|
key[0...1] != '.' && !::File.directory?(connection.path_to(key))
|
||||||
end.map do |key|
|
end.map do |key|
|
||||||
path = file_path(key)
|
path = file_path(key)
|
||||||
|
@ -66,7 +66,7 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
def file_path(key)
|
def file_path(key)
|
||||||
connection.path_to(::File.join(directory.name, key))
|
connection.path_to(::File.join(directory.key, key))
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,8 +8,9 @@ module Fog
|
||||||
class Directory < Fog::Model
|
class Directory < Fog::Model
|
||||||
extend Fog::Deprecation
|
extend Fog::Deprecation
|
||||||
deprecate(:name, :key)
|
deprecate(:name, :key)
|
||||||
|
deprecate(:name=, :key=)
|
||||||
|
|
||||||
identity :key, ['name', :name]
|
identity :key, ['name']
|
||||||
|
|
||||||
attribute :bytes
|
attribute :bytes
|
||||||
attribute :count
|
attribute :count
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue