GithubHelp home page GithubHelp logo

Comments (5)

zenspider avatar zenspider commented on July 20, 2024

A further problem is that fakefs' FileUtils.mv seems to expect dest to be an inclusive path rather than either a renamed inclusive path or a directory to move the existing file to. The following method fixes both issues:

def mv(src, dest)
  Array(src).each do |path|
    if target = FileSystem.find(path)
      d_path = if File.directory? dest then
                 File.join dest, File.basename(path)
               else
                 dest
               end
      FileSystem.add(d_path, target.entry.clone)
      FileSystem.delete(path)
    else
      raise Errno::ENOENT, path
    end
  end
end

from fakefs.

smtlaissezfaire avatar smtlaissezfaire commented on July 20, 2024

I'd gladly accept a patch if some tests were included :)

from fakefs.

gcampbell avatar gcampbell commented on July 20, 2024

I've addressed these two issues (the array of files identified in the main issue #40, as well as directory destinations as mentioned in the comment above) as separate commits in http://github.com/gcampbell/fakefs/tree/40-mv-to-dir. The final result ends up looking pretty much like zenspider's code, except with a ternary instead of the if/else.

from fakefs.

wijet avatar wijet commented on July 20, 2024

Could please merge gcambell's commits into master?

They work just fine with the latest master https://github.com/wijet/fakefs/tree/40-mv-to-dir

from fakefs.

gcampbell avatar gcampbell commented on July 20, 2024

FileUtils.mv can now handle an array of sources

Closed by 4e9355d. Closed by 4e9355d

from fakefs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.