# Feedback on new Path Library

**URL:** <https://www.ruby-forum.com/t/feedback-on-new-path-library/116964>\
**Category:** Ruby\
**Created:** [October 11, 2007, 6:31pm UTC](https://www.ruby-forum.com/t/feedback-on-new-path-library/116964 "2007-10-11T18:31:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![pSCorey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ecccb3/32.png) [@pSCorey](https://www.ruby-forum.com/u/pSCorey)\
**Post date:** [October 11, 2007, 6:31pm UTC](https://www.ruby-forum.com/t/feedback-on-new-path-library/116964/1 "2007-10-11T18:31:57Z")

</div>

I created a new Path library ([http://pow.rubyforge.org](http://pow.rubyforge.org)) that combines  
a lot of the functionality of Dir, FileUtils, File and Pathname into  
one with a object centered approach. I’m looking for some feedback to  
see if people would find this useful, or if I am the only one that get  
frustrated when trying to deal with paths in ruby.

Here are some quick example of how it makes things easier…  
File.read(File.join(DIR\_CONSTANT, “some\_text.txt”))  
you be written as  
Pow[DIR\_CONSTANT, "some\_text.txt].read

Or if you wanted to to find the number of files in each sub directory  
Pathname.new(“/usr/lib/ruby/1.8”).children(true).select {|p|  
p.directory?}.collect {|d| d.children.length}  
you would do  
Pow[“/usr/lib/ruby/1.8”].directories.collect {|d| d.files.length}

Also if you want to create a nested directory structure you can easily  
do that.  
Pow[“./moar”].create do  
Pow[“empty\_dir”].create

```
Pow["sub_dir"].create do
  Pow["info.txt"].create {|file| file.puts "Here is the info you

```

desired!"}  
end  
end

would create…  
/moar  
/empty\_dir  
/sub\_dir  
info.txt

It is still a work in progress so any feedback would be great! I  
realize this is all just syntactic sugar, but i find it much easier  
than using bits of File, Dir, FileUtils and Pathname all over the  
place.

Corey

P.S. Why did I call it Pow? Because it was quick to type and all other  
path-type names were taken!

---

<div class="post-metadata">

**Author:** ![pSCorey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ecccb3/32.png) [@pSCorey](https://www.ruby-forum.com/u/pSCorey)\
**Post date:** [October 11, 2007, 10:27pm UTC](https://www.ruby-forum.com/t/feedback-on-new-path-library/116964/2 "2007-10-11T22:27:55Z")

</div>

On Oct 11, 6:30 pm, “p. Corey” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I created a new Path library ([http://pow.rubyforge.org](http://pow.rubyforge.org)) that combines  
> a lot of the functionality of Dir, FileUtils, File and Pathname into  
> one with a object centered approach. I’m looking for some feedback to  
> see if people would find this useful, or if I am the only one that get  
> frustrated when trying to deal with paths in ruby.

Congrats. This looks very nice!

Sharon

---

<div class="post-metadata">

**Author:** ![pSCorey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ecccb3/32.png) [@pSCorey](https://www.ruby-forum.com/u/pSCorey)\
**Post date:** [October 11, 2007, 10:51pm UTC](https://www.ruby-forum.com/t/feedback-on-new-path-library/116964/3 "2007-10-11T22:51:55Z")

</div>

On Oct 11, 10:30 am, “p. Corey” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I created a new Path library ([http://pow.rubyforge.org](http://pow.rubyforge.org)) that combines  
> a lot of the functionality of Dir, FileUtils, File and Pathname into  
> one with a object centered approach. I’m looking for some feedback to  
> see if people would find this useful, or if I am the only one that get  
> frustrated when trying to deal with paths in ruby.

What does this do that pathname2 doesn’t do?

[http://raa.ruby-lang.org/project/pathname2](http://raa.ruby-lang.org/project/pathname2)

Regards,

Dan

---

<div class="post-metadata">

**Author:** ![pSCorey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ecccb3/32.png) [@pSCorey](https://www.ruby-forum.com/u/pSCorey)\
**Post date:** [October 12, 2007, 2:26am UTC](https://www.ruby-forum.com/t/feedback-on-new-path-library/116964/4 "2007-10-12T02:26:48Z")

</div>

I believe these two competing products (hehe ;\> ) demonstrate that the  
current solutions for the various Pathname.new File FileUtils Dir and so  
on are a little bit cumbersome (to use)  
I think you can get the basename with File too or, with less typing than  
with the Pathname representation?

---

<div class="post-metadata">

**Author:** ![pSCorey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ecccb3/32.png) [@pSCorey](https://www.ruby-forum.com/u/pSCorey)\
**Post date:** [October 12, 2007, 2:34am UTC](https://www.ruby-forum.com/t/feedback-on-new-path-library/116964/5 "2007-10-12T02:34:08Z")

</div>

On Oct 11, 2007, at 17:26 , Marc H. wrote:

> I believe these two competing products (hehe ;\> ) demonstrate that the  
> current solutions for the various Pathname.new File FileUtils Dir  
> and so  
> on are a little bit cumbersome (to use)  
> I think you can get the basename with File too or, with less typing  
> than  
> with the Pathname representation?

How is FileUtils cumbersome?

I find it easier than using sh due to FileUtils::Verbose and  
FileUtils::DryRun. Replacing RubyGems’ setup.rb with a tiny,  
debuggable installer was incredibly easy using FileUtils and Dir.

---

<div class="post-metadata">

**Author:** ![pSCorey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ecccb3/32.png) [@pSCorey](https://www.ruby-forum.com/u/pSCorey)\
**Post date:** [October 12, 2007, 2:20am UTC](https://www.ruby-forum.com/t/feedback-on-new-path-library/116964/6 "2007-10-12T02:20:42Z")

</div>

> What does this do that pathname2 doesn’t do?

Well, Pow does have the nested directory structure creation, but other  
than that they both seem to have similar abilities but with a  
different style. To be honest, i didn’t know pathname2 existed when I  
started, so I wasn’t trying to rain on anyones parade.

Corey

---

<div class="post-metadata">

**Author:** ![pSCorey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ecccb3/32.png) [@pSCorey](https://www.ruby-forum.com/u/pSCorey)\
**Post date:** [October 12, 2007, 2:11pm UTC](https://www.ruby-forum.com/t/feedback-on-new-path-library/116964/7 "2007-10-12T14:11:50Z")

</div>

> I find it easier than using sh due to FileUtils::Verbose and  
> FileUtils::DryRun. Replacing RubyGems’ setup.rb with a tiny,  
> debuggable installer was incredibly easy using FileUtils and Dir.  
> First off I totally agree with you here, the FileUtils::DryRun and  
> FileUtils::Verbose are very helpful over sh to do such things. And Pow  
> does nothing to emulate that great functionality.

> How is FileUtils cumbersome?  
> Individual FileUtil commands are not cumbersome, but the combination  
> of them with other methods is. Rarely do I just need mv a predefined  
> path to a new predefined. First I have to build the src\_path using a  
> combination of File.dirname and File.join, then I have to do the same  
> with the dest\_path as well as mkdir\_p’ing it to make sure path  
> hierarchy exists. When I find myself using FileUtils it usually  
> involves doing this with multiples files and multiple commands, that’s  
> where it becomes cumbersome. FileUtils just emulates shell commands,  
> which are great on the command line but archaic compared to the rest  
> of ruby’s syntax and style.
