lib/stashify/directory/google/cloud/storage.rb in stashify-google-cloud-storage-3.0.0 vs lib/stashify/directory/google/cloud/storage.rb in stashify-google-cloud-storage-3.1.0

- old
+ new

@@ -14,36 +14,41 @@ def initialize(bucket:, path:) @bucket = bucket super(path: path) end + def parent + Stashify::Directory::Google::Cloud::Storage.new( + bucket: @bucket, + path: ::File.dirname(path), + ) + end + def files @bucket.files.map do |gcloud_file| find(::Regexp.last_match(1)) if gcloud_file.name =~ %r{^#{Regexp.escape(path)}/([^/]*)(/.*)?$} end.compact end - def ==(other) - self.class == other.class && @bucket == other.bucket && path == other.path - end - - private - def directory?(name) path = path_of(name) !@bucket.file(path) && !@bucket.files(prefix: path).empty? end def directory(name) Stashify::Directory::Google::Cloud::Storage.new(bucket: @bucket, path: path_of(name)) end - def file?(name) + def exists?(name) @bucket.file(path_of(name)) end def file(name) Stashify::File::Google::Cloud::Storage.new(bucket: @bucket, path: path_of(name)) + end + + def ==(other) + self.class == other.class && @bucket == other.bucket && path == other.path end end end end end