ptools 1.3.3

The ptools (power tools) library provides several handy methods to Ruby's core File class, such as File.which for finding executables, File.null to return the null device on your platform, and so on.


Platform: Rubygems

Language: Ruby

License: Artistic-2.0


View on registry:


Direct download link:

Install: gem install ptools -v 1.3.3

== Description
  The ptools (power tools) library is an additional set of commands for the
  File class based on Unix command line tools.
== Prerequisites
  On MS Windows you will need the win32-file gem.

== Installation
  gem install ptools

== Synopsis
  require "ptools"

  File.which("ruby")         # '/usr/local/bin/ruby'
  File.whereis("ruby")       # ['/usr/local/bin/ruby','/opt/bin/ruby']

  File.head("myfile")        # Returns first 10 lines of 'myfile'
  File.tail("myfile",3)      # Returns last 3 lines of 'myfile'
  File.wc("myfile",'words')  # Returns the number of words in 'myfile'

  File.touch("newfile")      # "newfile" now exists
  File.null                  # '/dev/null' on Unix, 'NUL' on Windows
  File.binary?('some_file')  # true or false
  File.sparse?('some_file')  # true or false

  # Creates a copy of 'myfile' called 'newfile', in DOS format
  File.nl_convert("myfile", "newfile", "dos")
== Known Bugs
  The File.which and File.whereis methods may fail when using JRuby on Windows.
  See for details.

  Please report any other issues on the github project page.

== Acknowledgements
  The File.which method was originally adopted from the FileWhich code posted
  by Michael Granger on the now defunct website. That code was
  later replaced by a version based on the ruby-which library.

  The File.nl_convert method is based on the nlcvt program found at, written by Tom Christiansen.
  The binary?() method was based almost entirely on a blog post by Ryan
  Davis (who, in turn, based his code on Perl's -B switch).

  Thanks go to Matt Hoyle for help with the File.tail method.

== Future Plans
  Add whatever other tools people think might be useful.
== License
  Artistic 2.0
== Copyright
  (C) 2003-2014 Daniel J. Berger
  All Rights Reserved.
== Warranty
  This package is provided "as is" and without any express or
  implied warranties, including, without limitation, the implied
  warranties of merchantability and fitness for a particular purpose.

== Author
  Daniel J. Berger


1.3.3 September 25, 2015
1.3.2 December 11, 2014
1.3.1 December 09, 2014
1.3.0 December 08, 2014
1.2.7 December 06, 2014
1.2.6 July 14, 2014
1.2.5 July 11, 2014
1.2.4 February 25, 2014
1.2.3 February 19, 2014
1.2.2 April 06, 2012
See all 21 releases

Project Statistics

SourceRank 18
Dependencies 0
Dependent projects 57
Dependent repositories 1.69K
Total releases 21
Latest release
First release
Stars 21
Forks 3
Watchers 3
Contributors 4
Repo Size: 530 KB

Top Contributors See all

Daniel Berger Matt Hoyle Al Snow Dennis Günnewig

Something wrong with this page? Make a suggestion

Export .ABOUT file for this library

Last synced: 2017-04-21 14:18:57 UTC

Login to resync this project