Sha256: a102c631e474f609fbf31bea7c5a11f78d9a19cb7ffbb757c26c78d99eb4cf96

Contents?: true

Size: 1.28 KB

Versions: 29

Compression:

Stored size: 1.28 KB

Contents

require 'net/ftp/list/parser'
require 'time'

module Net
  class FTP
    module List

      # Parse Netware like FTP LIST entries.
      #
      # == MATCHES
      #
      #   d [RWCEAFMS] dpearce                          512 Jun 27 23:46 public.www
      #
      # == SYNOPSIS
      #
      #   entry = Net::FTP::List::Netware.new('d [RWCEAFMS] dpearce             512 Jun 27 23:46 public.www')
      #   entry.dir?     # => true
      #   entry.basename # => 'public.www'
      class Netware < Parser

        # Stolen straight from the ASF's commons Java FTP LIST parser library.
        # http://svn.apache.org/repos/asf/commons/proper/net/trunk/src/java/org/apache/commons/net/ftp/

        REGEXP = %r!^
          (d|-){1}\s+
          \[(.*?)\]\s+
          (\S+)\s+(\d+)\s+
          (\S+\s+\S+\s+((\d+:\d+)|(\d{4})))
          \s+(.*)
        $!x

        # Parse a Netware like FTP LIST entries.
        def initialize(raw)
          super(raw)
          match = REGEXP.match(raw.strip) or raise ParserError
          
          @mtime = Time.parse(match[5])

          if match[1] == 'd'
            @dir = true
          else
            @file = true
          end

          # TODO: Permissions, users, groups, date/time.

          @basename = match[9]
        end
      end

    end
  end
end

Version data entries

29 entries across 29 versions & 2 rubygems

Version Path
redcar-dev-0.12.1dev-java plugins/project/vendor/net-ftp-list/lib/net/ftp/list/netware.rb
redcar-dev-0.12.0dev-java plugins/project/vendor/net-ftp-list/lib/net/ftp/list/netware.rb
redcar-0.11 plugins/project/vendor/net-ftp-list/lib/net/ftp/list/netware.rb
redcar-0.11.0dev plugins/project/vendor/net-ftp-list/lib/net/ftp/list/netware.rb
redcar-0.10 plugins/project/vendor/net-ftp-list/lib/net/ftp/list/netware.rb
redcar-0.9.2 plugins/project/vendor/net-ftp-list/lib/net/ftp/list/netware.rb
redcar-0.9.1 plugins/project/vendor/net-ftp-list/lib/net/ftp/list/netware.rb
redcar-0.9.0 plugins/project/vendor/net-ftp-list/lib/net/ftp/list/netware.rb
redcar-0.8.1 plugins/project/vendor/net-ftp-list/lib/net/ftp/list/netware.rb
redcar-0.8 plugins/project/vendor/net-ftp-list/lib/net/ftp/list/netware.rb
redcar-0.7 plugins/project/vendor/net-ftp-list/lib/net/ftp/list/netware.rb
redcar-0.6.1 plugins/project/vendor/net-ftp-list/lib/net/ftp/list/netware.rb
redcar-0.6 plugins/project/vendor/net-ftp-list/lib/net/ftp/list/netware.rb
redcar-0.6.1dev plugins/project/vendor/net-ftp-list/lib/net/ftp/list/netware.rb
redcar-0.5.1 plugins/project/vendor/net-ftp-list/lib/net/ftp/list/netware.rb
redcar-0.5 plugins/project/vendor/net-ftp-list/lib/net/ftp/list/netware.rb
redcar-0.5.6dev plugins/project/vendor/net-ftp-list/lib/net/ftp/list/netware.rb
redcar-0.5.5dev plugins/project/vendor/net-ftp-list/lib/net/ftp/list/netware.rb
redcar-0.5.4dev plugins/project/vendor/net-ftp-list/lib/net/ftp/list/netware.rb
redcar-0.5.3dev plugins/project/vendor/net-ftp-list/lib/net/ftp/list/netware.rb