lib/fakefs/fileutils.rb in fakefs-0.18.1 vs lib/fakefs/fileutils.rb in fakefs-0.19.0

- old
+ new

@@ -32,36 +32,36 @@ alias makedirs mkdir_p def mkdir(list, _ignored_options = {}) list = [list] unless list.is_a?(Array) list.each do |path| - parent = path.split('/') + parent = path.to_s.split('/') parent.pop unless parent.join == '' || parent.join == '.' || FileSystem.find(parent.join('/')) - raise Errno::ENOENT, path + raise Errno::ENOENT, path.to_s end - raise Errno::EEXIST, path if FileSystem.find(path) + raise Errno::EEXIST, path.to_s if FileSystem.find(path) FileSystem.add(path, FakeDir.new) end end def rmdir(list, _options = {}) list = [list] unless list.is_a?(Array) list.each do |l| - parent = l.split('/') + parent = l.to_s.split('/') parent.pop - raise Errno::ENOENT, l unless parent.join == '' || FileSystem.find(parent.join('/')) - raise Errno::ENOENT, l unless FileSystem.find(l) - raise Errno::ENOTEMPTY, l unless FileSystem.find(l).empty? + raise Errno::ENOENT, l.to_s unless parent.join == '' || FileSystem.find(parent.join('/')) + raise Errno::ENOENT, l.to_s unless FileSystem.find(l) + raise Errno::ENOTEMPTY, l.to_s unless FileSystem.find(l).empty? rm(l) end end def rm(list, options = {}) Array(list).each do |path| FileSystem.delete(path) || - (!options[:force] && raise(Errno::ENOENT, path)) + (!options[:force] && raise(Errno::ENOENT, path.to_s)) end end alias rm_r rm alias remove rm @@ -79,15 +79,15 @@ rm_rf(path, force: force) end def ln_s(target, path, options = {}) options = { force: false }.merge(options) - raise(Errno::EEXIST, path) if FileSystem.find(path) && !options[:force] + raise(Errno::EEXIST, path.to_s) if FileSystem.find(path) && !options[:force] FileSystem.delete(path) if !options[:force] && !Dir.exist?(File.dirname(path)) - raise Errno::ENOENT, path + raise Errno::ENOENT, path.to_s end FileSystem.add(path, FakeSymlink.new(target)) end @@ -96,11 +96,11 @@ end alias symlink ln_s def cp(src, dest, options = {}) - raise Errno::ENOTDIR, dest if src.is_a?(Array) && !File.directory?(dest) + raise Errno::ENOTDIR, dest.to_s if src.is_a?(Array) && !File.directory?(dest) # handle `verbose' flag RealFileUtils.cp src, dest, options.merge(noop: true) # handle `noop' flag @@ -108,11 +108,11 @@ Array(src).each do |source| dst_file = FileSystem.find(dest) src_file = FileSystem.find(source) - raise Errno::ENOENT, source unless src_file + raise Errno::ENOENT, source.to_s unless src_file if dst_file && File.directory?(dst_file) FileSystem.add( File.join(dest, File.basename(source)), src_file.entry.clone(dst_file) ) @@ -148,20 +148,20 @@ # handle `noop' flag return if options[:noop] Array(src).each do |source| dir = FileSystem.find(source) - raise Errno::ENOENT, source unless dir + raise Errno::ENOENT, source.to_s unless dir new_dir = FileSystem.find(dest) - raise Errno::EEXIST, dest if new_dir && !File.directory?(dest) - raise Errno::ENOENT, dest if !new_dir && !FileSystem.find(dest + '/../') + raise Errno::EEXIST, dest.to_s if new_dir && !File.directory?(dest) + raise Errno::ENOENT, dest.to_s if !new_dir && !FileSystem.find(dest.to_s + '/../') # This last bit is a total abuse and should be thought hard # about and cleaned up. if new_dir - if src[-2..-1] == '/.' + if src.to_s[-2..-1] == '/.' dir.entries.each { |f| new_dir[f.name] = f.clone(new_dir) } else new_dir[dir.name] = dir.entry.clone(new_dir) end else @@ -186,20 +186,20 @@ File.join(dest, File.basename(path)) else dest end if File.directory?(dest_path) - raise Errno::EEXIST, dest_path unless options[:force] + raise Errno::EEXIST, dest_path.to_s unless options[:force] elsif File.directory?(File.dirname(dest_path)) FileSystem.delete(dest_path) FileSystem.delete(path) FileSystem.add(dest_path, target.entry.clone) else - raise Errno::ENOENT, dest_path unless options[:force] + raise Errno::ENOENT, dest_path.to_s unless options[:force] end else - raise Errno::ENOENT, path + raise Errno::ENOENT, path.to_s end end nil end @@ -218,11 +218,11 @@ if group group.to_s =~ /\d+/ ? group.to_i : Etc.getgrnam(group).gid end File.chown(uid, gid, f) else - raise Errno::ENOENT, f + raise Errno::ENOENT, f.to_s end end list end @@ -241,10 +241,10 @@ list = Array(list) list.each do |f| if File.exist?(f) File.chmod(mode, f) else - raise Errno::ENOENT, f + raise Errno::ENOENT, f.to_s end end list end