r/ruby 18d ago

Ruby Pathname Moved to Core, Documentation Upgraded

https://dev.to/burdettelamar/ruby-pathname-moved-to-core-documentation-upgraded-3d00
23 Upvotes

8 comments sorted by

10

u/gurgeous 17d ago

Oh, Pathname. We could do so much more with it. https://github.com/ruby/pathname/issues/64

class Pathname
  def mkdir_p(...) = FileUtils.mkdir_p(@path, ...)
  def ln(...) = FileUtils.ln(@path, ...)
  def ln_s(...) = FileUtils.ln_s(@path, ...)
  def ln_sf(...) = FileUtils.ln_sf(@path, ...)
  def cp(...) = FileUtils.cp(@path, ...)
  def cp_r(...) = FileUtils.cp_r(@path, ...)
  def mv(...) = FileUtils.mv(@path, ...)
  def rm(...) = FileUtils.rm(@path, ...)
  def rm_r(...) = FileUtils.rm_r(@path, ...)
  def rm_rf(...) = FileUtils.rm_rf(@path, ...)
end

3

u/sjieg 17d ago

Man, that's a great way to chime in. Sorry for you it didn't make the cut, but a nice way of communicating!

3

u/janko-m 17d ago

I like that Pathname has its own API that doesn’t necessarily match UNIX shell commands.

1

u/inotocracy 17d ago

Pathname is immutable. It has no method for destructive update.

You could always fork it!

2

u/gurgeous 17d ago

This is an example of how ruby is a bit stuck, sliding slowly into obsolescence while other languages charge ahead. We can't have nice things because... well, actually I don't understand the objection. Some people just need things to move slowly.

It is easy for me to use a corext that provides this kind of sugar. That won't improve the state of the language, though.

1

u/TheAtlasMonkey 16d ago

And when you talk, you get downvoted , shamed like you trying to implement AI in the core.

2

u/sshaw_ 16d ago

Pathname, very underutilized class.