rubyworks/facets — pull request #118 by aguynamedryan (2014-11-18 23:26:23+00:00)
Title: Pathname additions

Here are a few little additions to Pathname that capture some tiny, but oft-repeated, patterns I use:

#mkdir? and #mkpath? will call #mkdir and #mkpath respectively, but only if the path doesn't already exist. I hate having to check if a path exists before trying to make it, just to avoid bombing out if the path already exists. Adding the ? to the methods is a technique used by [Sequel](https://github.com/jeremyevans/sequel) to make schema modifications only if the schema doesn't already have that modification. I like that idiom.

#readline captures the best practice from [Stack Overflow] (https://stackoverflow.com/questions/1490138/reading-the-first-line-of-a-file-in-ruby) for quickly reading just the first line out of a file.