lib/defog/handle.rb in defog-0.1.0 vs lib/defog/handle.rb in defog-0.1.1
- old
+ new
@@ -1,5 +1,7 @@
+require "fastandand"
+
module Defog
# Create a Defog::Handle proxy instance via Defog::Proxy#file, such as
#
# defog = Defog::Proxy.new(:provider => :AWS, :aws_access_key_id => access_key, ...)
#
@@ -12,32 +14,47 @@
# end
#
# The #proxy_path attribute method returns a <code>Pathname</code>
# giving the local proxy file location. Querying the attribute does
# <i>not</i> upload, download, synchronize, or otherwise interact with
- # the cloud or local proxy file in any way -- just returns a constructed
- # a Pathname.
+ # the cloud or local proxy file in any way -- it just returns a constructed
+ # Pathname. The <code>proxy_path</code> is a deterministic function of the
+ # cloud key and Defog::Proxy#proxy_root, so you can rely on it not
+ # changing between independent accesses to a cloud file.
#
class Handle
attr_reader :key
attr_reader :proxy #:nodoc:
+
+ # Pathname where proxy file is, was, or will be located.
attr_reader :proxy_path
def initialize(proxy, key) #:nodoc:
@proxy = proxy
@key = key
@proxy_path = Pathname.new("#{@proxy.proxy_root}/#{@key}").expand_path
end
# Returns true if the remote cloud file exists
def exist?
- !!@proxy.fog_wrapper.fog_head(@key)
+ !!fog_model
end
- # Deletes the remote cloud file
+ # Deletes the remote cloud file if it exists
def delete
- @proxy.fog_wrapper.fog_head(@key).destroy
+ fog_model.andand.destroy
+ end
+
+ # Returns the size of the remote cloud file, or nil if it doesn't exist
+ def size
+ fog_model.andand.content_length
+ end
+
+ # Returns the modification date of the remote cloud file, or nil if it
+ # doesn't exist
+ def last_modified
+ fog_model.andand.last_modified
end
# Returns a URL to access the remote cloud file.
#
# The option