Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Extra methods (power tools) for the File class for Ruby

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 .gemtest
Octocat-spinner-32 CHANGES
Octocat-spinner-32 Gemfile
Octocat-spinner-32 MANIFEST
Octocat-spinner-32 README
Octocat-spinner-32 Rakefile
Octocat-spinner-32 ptools.gemspec
README
== 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 win32-file 0.5.4 or later.

== 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.middle("myfile",8,12) # Returns lines 8-12 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
  None known. Please report any bugs on the github project page.

  http://www.github.com/djberg96/ptools

== Acknowledgements
  The File.which method was originally adopted from the FileWhich code posted
  by Michael Granger on the now defunct rubygarden.org 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
  http://www.perl.com/language/ppt/src/nlcvt/nlcvt, written by Tom Christiansen.
    
  The middle() method was provided by Shashank Date.

  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).

== 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
Something went wrong with that request. Please try again.