net-ftp-list 0.9 → 1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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.9'
8
+ VERS = '1.0'
9
9
 
10
10
  CLEAN.include ['**/*.log', '*.gem']
11
11
  CLOBBER.include ['**/*.log']
@@ -47,7 +47,13 @@ module Net
47
47
 
48
48
  # TODO: Permissions, users, groups, date/time.
49
49
 
50
- @basename = match[21].match(/^(.+)(?:\s+\->.+)?$/)[0].strip
50
+ @basename = match[21].strip
51
+
52
+ # filenames with spaces will end up in the last match
53
+ @basename += match[22] unless match[22].nil?
54
+
55
+ # strip the symlink stuff we don't care about
56
+ @basename.sub!(/\s+\->.+$/, '') if @symlink
51
57
  end
52
58
  end
53
59
 
@@ -4,15 +4,19 @@ require 'net/ftp/list'
4
4
  class TestNetFTPListUnix < Test::Unit::TestCase
5
5
 
6
6
  def setup
7
- @dir = Net::FTP::List.parse('drwxr-xr-x 4 user group 4096 Dec 10 20:23 etc')
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')
7
+ @dir = Net::FTP::List.parse 'drwxr-xr-x 4 user group 4096 Dec 10 20:23 etc'
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'
10
+ @spaces = Net::FTP::List.parse 'drwxrwxr-x 2 danial danial 72 May 23 12:52 spaces suck'
11
+ @symlink = Net::FTP::List.parse 'lrwxrwxrwx 1 danial danial 4 Apr 30 15:26 bar -> /etc'
10
12
  end
11
13
 
12
14
  def test_parse_new
13
15
  assert_instance_of Net::FTP::List::Unix, @dir, 'LIST unixish directory'
14
16
  assert_instance_of Net::FTP::List::Unix, @file, 'LIST unixish file'
15
17
  assert_instance_of Net::FTP::List::Unix, @other_dir, 'LIST unixish directory'
18
+ assert_instance_of Net::FTP::List::Unix, @spaces, 'LIST unixish directory with spaces'
19
+ assert_instance_of Net::FTP::List::Unix, @symlink, 'LIST unixish symlink'
16
20
  end
17
21
 
18
22
  def test_rubbish_lines
@@ -29,6 +33,19 @@ class TestNetFTPListUnix < Test::Unit::TestCase
29
33
  assert !@other_dir.file?
30
34
  end
31
35
 
36
+ def test_ruby_unix_like_symlink
37
+ assert_equal 'bar', @symlink.basename
38
+ assert @symlink.symlink?
39
+ assert !@symlink.dir?
40
+ assert !@symlink.file?
41
+ end
42
+
43
+ def test_spaces_in_unix_dir
44
+ assert_equal 'spaces suck', @spaces.basename
45
+ assert @spaces.dir?
46
+ assert !@spaces.file?
47
+ end
48
+
32
49
  def test_ruby_unix_like_file
33
50
  assert_equal 'README', @file.basename
34
51
  assert @file.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.9"
7
- date: 2008-04-18 00:00:00 +10:00
6
+ version: "1.0"
7
+ date: 2008-05-23 00:00:00 +10:00
8
8
  summary: Parse FTP LIST command output.
9
9
  require_paths:
10
10
  - lib