Git Product home page Git Product logo

net-ftp-list's Introduction

= Net::Ftp::List

== DESCRIPTION

Ruby lib to parse FTP LIST responses.

According to the FTP RFC the LIST command "information on a file may vary widely from system to system, this
information may be hard to use automatically in a program, but may be quite useful to a human user".
Unfortunately the NLST command "intended to return information that can be used by a program to further process
the files automatically" only returns the filename and no other information. If you want to know to know even
simple things like 'is the NLST entry a directory or file' you are left with the choice of attempting to CWD to
(and back from) each entry or parsing the LIST command. This extension is an attempt at parsing the LIST command
and as such is subject to all the variability that results from such an undertaking, take responses with a grain
of salt and expect failures.

See the RFC for more guff on LIST and NLST: http://www.ietf.org/rfc/rfc0959.txt

== TODO & PROBLEMS

* The factory and abstract base class for parsers are one and the same. OO geeks will cry.
* More OS's and server types. Only servers that return Unix like LIST responses will work at the moment.
* Calling <tt>if entry.file? or entry.dir?</tt> is hard work when you really mean <tt>unless entry.unknown?</tt>

== SYNOPSIS

  require 'net/ftp' # Not really required but I like to list dependencies sometimes.
  require 'net/ftp/list'

  ftp = Net::FTP.open('somehost.com', 'user', 'pass')
  ftp.list('/some/path') do |e|
    entry = Net::FTP::List.parse(e)

    # Ignore everything that's not a file (so symlinks, directories and devices etc.)
    next unless entry.file?

    # If entry isn't entry.unknown? then there is a bug in Net::FTP::List if this isn't the
    # same name as ftp.nlist('/some/path') would have returned.
    # Format the entry showing its file size and modification time
    puts "#{entry.basename}, #{entry.filesize}, #{entry.mtime}"

  end

== CREDITS

  * ASF, Commons. http://commons.apache.org/
  * The good people at Stateless Systems who let me write Ruby and give it away.

== LICENSE

(The MIT License, go nuts)

Copyright (c) 2007 Shane Hanna
Stateless Systems
http://statelesssystems.com

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

net-ftp-list's People

Contributors

ericparshall avatar fcoury avatar julik avatar mschulkind avatar norbertwinklareth avatar shanna avatar steenzout avatar toy avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.