Sha256: 33d96a36a121850b21ea245ded76db0b517928f70a7100c1419eb5f05cd8cee7

Contents?: true

Size: 785 Bytes

Versions: 12

Compression:

Stored size: 785 Bytes

Contents

require 'net/ftp/list/parser'

# Parse Rumpus FTP LIST entries.
#
# == MATCHES
# drwxr-xr-x               folder        0 Nov 30 10:03 houdini
# -rw-r--r--        0      101426   101426 Jun  7  2008 imap with spaces.rb
class Net::FTP::List::Rumpus < Net::FTP::List::Parser

  REGEXP = %r!^
    ([drwxr-]{10})\s+
    (folder|0\s+\d+)\s+
    (\d+)\s+
    (\w+)\s+
    (\d{1,2})\s+
    (\d{2}:\d{2}|\d{4})\s+
    (.+)
  $!x

  # Parse a Rumpus FTP LIST entry.
  def self.parse(raw)
    match = REGEXP.match(raw.strip) or return false

    emit_entry(
      raw,
      :basename => match[7],
      :mtime => Time.parse([match[4], match[5], match[6]].join(" ")),
      :file => !(match[2] == "folder"),
      :dir => (match[2] == "folder"),
      :filesize => match[3].to_i
    )
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
net-ftp-list-3.2.11 lib/net/ftp/list/rumpus.rb
net-ftp-list-3.2.10 lib/net/ftp/list/rumpus.rb
net-ftp-list-3.2.9 lib/net/ftp/list/rumpus.rb
net-ftp-list-3.2.8 lib/net/ftp/list/rumpus.rb
net-ftp-list-3.2.7 lib/net/ftp/list/rumpus.rb
net-ftp-list-3.2.6 lib/net/ftp/list/rumpus.rb
net-ftp-list-3.2.5 lib/net/ftp/list/rumpus.rb
net-ftp-list-3.2.4 lib/net/ftp/list/rumpus.rb
net-ftp-list-3.2.3 lib/net/ftp/list/rumpus.rb
net-ftp-list-3.2.2 lib/net/ftp/list/rumpus.rb
net-ftp-list-3.2.1 lib/net/ftp/list/rumpus.rb
net-ftp-list-3.2.0 lib/net/ftp/list/rumpus.rb