lib/rush/entry.rb in rush-0.5 vs lib/rush/entry.rb in rush-0.5.1

- old
+ new

@@ -16,10 +16,12 @@ # The factory checks to see if the full path has a trailing slash for # creating a Rush::Dir rather than the default Rush::File. def self.factory(full_path, box=nil) if full_path.tail(1) == '/' Rush::Dir.new(full_path, box) + elsif File.directory?(full_path) + Rush::Dir.new(full_path, box) else Rush::File.new(full_path, box) end end @@ -46,10 +48,14 @@ def full_path "#{@path}/#{@name}" end + def quoted_path + Rush.quote(full_path) + end + # Return true if the entry currently exists on the filesystem of the box. def exists? stat true rescue Rush::DoesNotExist @@ -80,25 +86,26 @@ # Rename an entry to another name within the same dir. The object's name # will be updated to match the change on the filesystem. def rename(new_name) connection.rename(@path, @name, new_name) @name = new_name + self end # Rename an entry to another name within the same dir. The existing object # will not be affected, but a new object representing the newly-created # entry will be returned. def duplicate(new_name) - raise NameCannotContainSlash if new_name.match(/\//) + raise Rush::NameCannotContainSlash if new_name.match(/\//) new_full_path = "#{@path}/#{new_name}" connection.copy(full_path, new_full_path) self.class.new(new_full_path, box) end # Copy the entry to another dir. Returns an object representing the new # copy. def copy_to(dir) - raise NotADir unless dir.class == Rush::Dir + raise Rush::NotADir unless dir.class == Rush::Dir if box == dir.box connection.copy(full_path, dir.full_path) else archive = connection.read_archive(full_path)