net-ftp-list 0.7 → 0.9

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ require 'rake/gempackagetask'
5
5
  require 'rake/testtask'
6
6
 
7
7
  NAME = 'net-ftp-list'
8
- VERS = '0.7'
8
+ VERS = '0.9'
9
9
 
10
10
  CLEAN.include ['**/*.log', '*.gem']
11
11
  CLOBBER.include ['**/*.log']
@@ -42,7 +42,7 @@ end
42
42
  desc 'Package and install as gem.'
43
43
  task :install do
44
44
  sh %{rake package}
45
- sh %{sudo gem install pkg/net-ftp-list-#{VERS}}
45
+ sh %{sudo gem install pkg/#{NAME}-#{VERS}}
46
46
  end
47
47
 
48
48
  desc 'Uninstall the gem.'
@@ -4,7 +4,7 @@ module Net
4
4
  class FTP
5
5
  module List
6
6
 
7
- # Parse M$ like FTP LIST entries.
7
+ # Parse Microsoft(NT) like FTP LIST entries.
8
8
  #
9
9
  # == MATCHES
10
10
  #
@@ -20,15 +20,15 @@ module Net
20
20
 
21
21
  # Stolen straight from the ASF's commons Java FTP LIST parser library.
22
22
  # http://svn.apache.org/repos/asf/commons/proper/net/trunk/src/java/org/apache/commons/net/ftp/
23
- REGEXP = %r{
23
+ REGEXP = %r!
24
24
  ^\s*
25
- (\S+)\s+(\S+)\s+
25
+ ([0-9\-:\/]{5,})\s+([0-9\-:]{3,}(?:[aApP][mM])?)\s+
26
26
  (?:(<DIR>)|([0-9]+))\s+
27
27
  (\S.*)
28
28
  \s*$
29
- }x
29
+ !x
30
30
 
31
- # Parse a M$ like FTP LIST entries.
31
+ # Parse a Microsoft(NT) like FTP LIST entries.
32
32
  def initialize(raw)
33
33
  super(raw)
34
34
  match = REGEXP.match(raw.strip) or raise ParserError
@@ -32,28 +32,28 @@ module Net
32
32
 
33
33
  # The raw list entry string.
34
34
  def raw
35
- @raw
35
+ @raw ||= ''
36
36
  end
37
37
  alias_method :to_s, :raw
38
38
 
39
39
  # The items basename (filename).
40
40
  def basename
41
- @basename
41
+ @basename ||= ''
42
42
  end
43
43
 
44
44
  # Looks like a directory, try CWD.
45
45
  def dir?
46
- !!@dir
46
+ !!@dir ||= false
47
47
  end
48
48
 
49
49
  # Looks like a file, try RETR.
50
50
  def file?
51
- !!@file
51
+ !!@file ||= false
52
52
  end
53
53
 
54
54
  # Looks like a symbolic link.
55
55
  def symlink?
56
- !!@symlink
56
+ !!@symlink ||= false
57
57
  end
58
58
 
59
59
  class << self
@@ -6,11 +6,13 @@ class TestNetFTPListUnix < Test::Unit::TestCase
6
6
  def setup
7
7
  @dir = Net::FTP::List.parse('drwxr-xr-x 4 user group 4096 Dec 10 20:23 etc')
8
8
  @file = Net::FTP::List.parse('-rw-r--r-- 1 root other 531 Jan 29 03:26 README')
9
+ @other_dir = Net::FTP::List.parse('drwxr-xr-x 8 1791 600 4096 Mar 11 07:57 forums')
9
10
  end
10
11
 
11
12
  def test_parse_new
12
13
  assert_instance_of Net::FTP::List::Unix, @dir, 'LIST unixish directory'
13
14
  assert_instance_of Net::FTP::List::Unix, @file, 'LIST unixish file'
15
+ assert_instance_of Net::FTP::List::Unix, @other_dir, 'LIST unixish directory'
14
16
  end
15
17
 
16
18
  def test_rubbish_lines
@@ -21,6 +23,10 @@ class TestNetFTPListUnix < Test::Unit::TestCase
21
23
  assert_equal 'etc', @dir.basename
22
24
  assert @dir.dir?
23
25
  assert !@dir.file?
26
+
27
+ assert_equal 'forums', @other_dir.basename
28
+ assert @other_dir.dir?
29
+ assert !@other_dir.file?
24
30
  end
25
31
 
26
32
  def test_ruby_unix_like_file
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: net-ftp-list
5
5
  version: !ruby/object:Gem::Version
6
- version: "0.7"
7
- date: 2008-04-15 00:00:00 +10:00
6
+ version: "0.9"
7
+ date: 2008-04-18 00:00:00 +10:00
8
8
  summary: Parse FTP LIST command output.
9
9
  require_paths:
10
10
  - lib