net-ftp-list 3.2.11 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +21 -0
- data/.gitignore +9 -0
- data/.rubocop.yml +17 -0
- data/Gemfile +1 -5
- data/Gemfile.lock +47 -51
- data/Rakefile +10 -42
- data/lib/net/ftp/list.rb +3 -4
- data/lib/net/ftp/list/entry.rb +33 -53
- data/lib/net/ftp/list/microsoft.rb +14 -16
- data/lib/net/ftp/list/netware.rb +8 -10
- data/lib/net/ftp/list/parser.rb +35 -18
- data/lib/net/ftp/list/rumpus.rb +9 -10
- data/lib/net/ftp/list/unix.rb +31 -38
- data/lib/net/ftp/list/unknown.rb +3 -6
- data/net-ftp-list.gemspec +15 -57
- data/test/test_net_ftp_list.rb +2 -3
- data/test/test_net_ftp_list_entry.rb +20 -21
- data/test/test_net_ftp_list_microsoft.rb +6 -7
- data/test/test_net_ftp_list_netware.rb +6 -8
- data/test/test_net_ftp_list_rumpus.rb +5 -6
- data/test/test_net_ftp_list_unix.rb +49 -62
- metadata +46 -12
- data/.ruby-version +0 -1
- data/VERSION.yml +0 -5
@@ -2,15 +2,14 @@ require 'test/unit'
|
|
2
2
|
require 'net/ftp/list'
|
3
3
|
|
4
4
|
class TestNetFTPListMicrosoft < Test::Unit::TestCase
|
5
|
-
|
6
5
|
def setup
|
7
6
|
@dir = Net::FTP::List.parse('06-25-07 01:08PM <DIR> etc')
|
8
7
|
@file = Net::FTP::List.parse('11-27-07 08:45PM 23437 README.TXT')
|
9
8
|
end
|
10
9
|
|
11
10
|
def test_parse_new
|
12
|
-
assert_equal
|
13
|
-
assert_equal
|
11
|
+
assert_equal 'Microsoft', @dir.server_type, 'LIST M$ directory'
|
12
|
+
assert_equal 'Microsoft', @file.server_type, 'LIST M$ directory'
|
14
13
|
end
|
15
14
|
|
16
15
|
def test_parse_dd_mm_yyyy
|
@@ -62,12 +61,12 @@ class TestNetFTPListMicrosoft < Test::Unit::TestCase
|
|
62
61
|
end
|
63
62
|
|
64
63
|
def test_rubbish_lines
|
65
|
-
assert_instance_of Net::FTP::List::Entry, Net::FTP::List.parse(
|
64
|
+
assert_instance_of Net::FTP::List::Entry, Net::FTP::List.parse('++ bah! ++')
|
66
65
|
end
|
67
66
|
|
68
67
|
def test_ruby_microsoft_mtime
|
69
|
-
assert_equal
|
70
|
-
assert_equal
|
68
|
+
assert_equal Time.utc(2007, 6, 25, 13, 8), @dir.mtime
|
69
|
+
assert_equal Time.utc(2007, 11, 27, 20, 45), @file.mtime
|
71
70
|
end
|
72
71
|
|
73
72
|
def test_ruby_microsoft_like_dir
|
@@ -89,6 +88,6 @@ class TestNetFTPListMicrosoft < Test::Unit::TestCase
|
|
89
88
|
|
90
89
|
def test_zero_hour
|
91
90
|
file = Net::FTP::List.parse('10-15-09 00:34AM <DIR> aspnet_client')
|
92
|
-
assert_equal
|
91
|
+
assert_equal Time.utc(2009, 10, 15, 0, 34), file.mtime
|
93
92
|
end
|
94
93
|
end
|
@@ -2,20 +2,19 @@ require 'test/unit'
|
|
2
2
|
require 'net/ftp/list'
|
3
3
|
|
4
4
|
class TestNetFTPListNetware < Test::Unit::TestCase
|
5
|
-
|
6
5
|
def setup
|
7
|
-
@dir
|
8
|
-
@file
|
6
|
+
@dir = Net::FTP::List.parse('d [RWCEAFMS] dpearce 512 Jun 27 23:46 public.www')
|
7
|
+
@file = Net::FTP::List.parse('- [RWCEAFMS] dpearce 2767 Jun 22 06:22 about.html', timezone: :local)
|
9
8
|
end
|
10
9
|
|
11
10
|
def test_parse_new
|
12
|
-
assert_equal
|
13
|
-
assert_equal
|
11
|
+
assert_equal 'Netware', @dir.server_type, 'LIST Netware directory'
|
12
|
+
assert_equal 'Netware', @file.server_type, 'LIST Netware file'
|
14
13
|
end
|
15
14
|
|
16
15
|
def test_ruby_netware_mtime
|
17
|
-
assert_equal
|
18
|
-
assert_equal
|
16
|
+
assert_equal Time.utc(Time.now.year, 6, 27, 23, 46), @dir.mtime
|
17
|
+
assert_equal Time.local(Time.now.year, 6, 22, 6, 22), @file.mtime
|
19
18
|
end
|
20
19
|
|
21
20
|
def test_ruby_netware_like_dir
|
@@ -34,5 +33,4 @@ class TestNetFTPListNetware < Test::Unit::TestCase
|
|
34
33
|
assert_equal 512, @dir.filesize
|
35
34
|
assert_equal 2767, @file.filesize
|
36
35
|
end
|
37
|
-
|
38
36
|
end
|
@@ -2,20 +2,19 @@ require 'test/unit'
|
|
2
2
|
require 'net/ftp/list'
|
3
3
|
|
4
4
|
class TestNetFTPListRumpus < Test::Unit::TestCase
|
5
|
-
|
6
5
|
def setup
|
7
6
|
@dir = Net::FTP::List.parse 'drwxrwxrwx folder 0 Nov 16 22:12 Alias'
|
8
|
-
@file = Net::FTP::List.parse '-rw-r--r-- 0 101426 101426 Jun 7 2008 imap with spaces.rb'
|
7
|
+
@file = Net::FTP::List.parse '-rw-r--r-- 0 101426 101426 Jun 7 2008 imap with spaces.rb', timezone: :local
|
9
8
|
end
|
10
9
|
|
11
10
|
def test_parsed
|
12
|
-
assert_equal
|
13
|
-
assert_equal
|
11
|
+
assert_equal 'Rumpus', @dir.server_type, 'LIST Rumpus directory'
|
12
|
+
assert_equal 'Rumpus', @file.server_type, 'LIST Rumpus file with spaces'
|
14
13
|
end
|
15
14
|
|
16
15
|
def test_ruby_unix_like_date
|
17
|
-
assert_equal Time.
|
18
|
-
assert_equal Time.
|
16
|
+
assert_equal Time.utc(Time.now.year, 11, 16, 22, 12), @dir.mtime
|
17
|
+
assert_equal Time.local(2008, 6, 7), @file.mtime
|
19
18
|
end
|
20
19
|
|
21
20
|
def test_dir
|
@@ -1,97 +1,83 @@
|
|
1
1
|
require 'test/unit'
|
2
2
|
require 'net/ftp/list'
|
3
|
+
require 'timecop'
|
3
4
|
|
4
5
|
class TestNetFTPListUnix < Test::Unit::TestCase
|
5
6
|
def setup
|
6
|
-
@dir
|
7
|
-
@file = Net::FTP::List.parse
|
8
|
-
@other_dir = Net::FTP::List.parse
|
9
|
-
@spaces = Net::FTP::List.parse
|
10
|
-
@symlink = Net::FTP::List.parse
|
11
|
-
@empty_symlink = Net::FTP::List.parse
|
12
|
-
@older_date = Net::FTP::List.parse
|
13
|
-
@block_dev = Net::FTP::List.parse
|
14
|
-
@char_dev
|
15
|
-
@socket_dev = Net::FTP::List.parse
|
16
|
-
@pipe_dev = Net::FTP::List.parse
|
17
|
-
@file_no_inodes = Net::FTP::List.parse
|
18
|
-
@file_today = Net::FTP::List.parse
|
19
|
-
@no_user = Net::FTP::List.parse
|
7
|
+
@dir = Net::FTP::List.parse 'drwxr-xr-x 4 user group 4096 Jan 1 00:00 etc'
|
8
|
+
@file = Net::FTP::List.parse '-rw-r--r-- 1 root other 531 Dec 31 23:59 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 Oct 30 15:26 bar -> /etc'
|
12
|
+
@empty_symlink = Net::FTP::List.parse 'lrwxrwxrwx 1 danial danial 4 Oct 30 15:26 foo'
|
13
|
+
@older_date = Net::FTP::List.parse '-rwxrwxrwx 1 owner group 154112 Feb 15 2008 participando.xls'
|
14
|
+
@block_dev = Net::FTP::List.parse 'brw-r----- 1 root disk 1, 0 Apr 13 2006 ram0', timezone: :local
|
15
|
+
@char_dev = Net::FTP::List.parse 'crw-rw-rw- 1 root root 1, 3 Apr 13 2006 null'
|
16
|
+
@socket_dev = Net::FTP::List.parse 'srw-rw-rw- 1 root root 0 Aug 20 14:15 log'
|
17
|
+
@pipe_dev = Net::FTP::List.parse 'prw-r----- 1 root adm 0 Nov 22 10:30 xconsole'
|
18
|
+
@file_no_inodes = Net::FTP::List.parse '-rw-r--r-- foo@utchost foo@utchost 6034 May 14 23:13 index.html'
|
19
|
+
@file_today = Net::FTP::List.parse 'crw-rw-rw- 1 root root 1, 3 Aug 16 14:28 today.txt'
|
20
|
+
@no_user = Net::FTP::List.parse '-rw-rw---- 2786 Jul 7 01:57 README'
|
20
21
|
end
|
21
22
|
|
22
23
|
def test_parse_new
|
23
|
-
assert_equal
|
24
|
-
assert_equal
|
25
|
-
assert_equal
|
26
|
-
assert_equal
|
27
|
-
assert_equal
|
28
|
-
assert_equal
|
29
|
-
assert_equal
|
30
|
-
assert_equal
|
31
|
-
assert_equal
|
32
|
-
assert_equal
|
33
|
-
assert_equal
|
34
|
-
assert_equal
|
35
|
-
end
|
36
|
-
|
37
|
-
class ::Time
|
38
|
-
class << self
|
39
|
-
def time_travel(time)
|
40
|
-
@traveled_to_time = time
|
41
|
-
|
42
|
-
begin
|
43
|
-
yield
|
44
|
-
ensure
|
45
|
-
@traveled_to_time = nil
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
alias_method :original_now, :now
|
50
|
-
def now
|
51
|
-
@traveled_to_time || original_now
|
52
|
-
end
|
53
|
-
end
|
24
|
+
assert_equal 'Unix', @dir.server_type, 'LIST unixish directory'
|
25
|
+
assert_equal 'Unix', @file.server_type, 'LIST unixish file'
|
26
|
+
assert_equal 'Unix', @other_dir.server_type, 'LIST unixish directory'
|
27
|
+
assert_equal 'Unix', @spaces.server_type, 'LIST unixish directory with spaces'
|
28
|
+
assert_equal 'Unix', @symlink.server_type, 'LIST unixish symlink'
|
29
|
+
assert_equal 'Unix', @empty_symlink.server_type, 'LIST unixish symlink'
|
30
|
+
assert_equal 'Unix', @block_dev.server_type, 'LIST unix block device'
|
31
|
+
assert_equal 'Unix', @char_dev.server_type, 'LIST unix char device'
|
32
|
+
assert_equal 'Unix', @socket_dev.server_type, 'LIST unix socket device'
|
33
|
+
assert_equal 'Unix', @pipe_dev.server_type, 'LIST unix socket device'
|
34
|
+
assert_equal 'Unix', @file_no_inodes.server_type, 'LIST unixish file with no inodes'
|
35
|
+
assert_equal 'Unix', @no_user.server_type, 'LIST unixish file with no user/group'
|
54
36
|
end
|
55
37
|
|
56
38
|
# mtimes in the past, same year.
|
57
39
|
def test_ruby_unix_like_date_past_same_year
|
58
|
-
|
59
|
-
|
60
|
-
assert_equal Time.local(2009, 1, 1), Net::FTP::List.parse(@dir.raw).mtime
|
40
|
+
Timecop.freeze(Time.utc(2009, 1, 1)) do
|
41
|
+
assert_equal Time.utc(2009, 1, 1), Net::FTP::List.parse(@dir.raw).mtime
|
61
42
|
end
|
62
|
-
|
63
|
-
assert_equal Time.
|
43
|
+
Timecop.freeze(Time.utc(2008, 4, 1)) do
|
44
|
+
assert_equal Time.utc(2008, 3, 11, 7, 57), Net::FTP::List.parse(@other_dir.raw).mtime
|
64
45
|
end
|
65
46
|
end
|
66
47
|
|
67
48
|
# mtimes in the past, previous year
|
68
49
|
def test_ruby_unix_like_date_past_previous_year
|
69
|
-
|
70
|
-
assert_equal Time.
|
50
|
+
Timecop.freeze(Time.utc(2008, 2, 4)) do
|
51
|
+
assert_equal Time.utc(2007, 10, 30, 15, 26), Net::FTP::List.parse(@symlink.raw).mtime
|
71
52
|
end
|
72
53
|
end
|
73
54
|
|
74
55
|
# mtime in the future.
|
75
56
|
def test_ruby_unix_like_date_future
|
76
|
-
|
77
|
-
assert_equal Time.
|
57
|
+
Timecop.freeze(Time.utc(2006, 3, 1)) do
|
58
|
+
assert_equal Time.utc(2006, 4, 13), Net::FTP::List.parse(@char_dev.raw).mtime
|
78
59
|
end
|
79
60
|
end
|
80
61
|
|
81
62
|
# Parsed during a leap year.
|
82
63
|
def test_ruby_unix_like_date_leap_year
|
83
|
-
|
84
|
-
assert_equal Time.
|
64
|
+
Timecop.freeze(Time.utc(2012, 1, 2)) do
|
65
|
+
assert_equal Time.utc(2011, 10, 30, 15, 26), Net::FTP::List.parse(@symlink.raw).mtime
|
85
66
|
end
|
86
67
|
end
|
87
68
|
|
88
69
|
# mtimes today, same year.
|
89
70
|
def test_ruby_unix_like_date_today_same_year
|
90
|
-
|
91
|
-
assert_equal Time.
|
71
|
+
Timecop.freeze(Time.utc(2013, 8, 16)) do
|
72
|
+
assert_equal Time.utc(2013, 8, 16, 14, 28), Net::FTP::List.parse(@file_today.raw).mtime
|
92
73
|
end
|
93
74
|
end
|
94
75
|
|
76
|
+
def test_mtime
|
77
|
+
assert_equal Time.utc(2008, 2, 15), @older_date.mtime
|
78
|
+
assert_equal Time.local(2006, 4, 13), @block_dev.mtime
|
79
|
+
end
|
80
|
+
|
95
81
|
def test_ruby_unix_like_dir
|
96
82
|
assert_equal 'etc', @dir.basename
|
97
83
|
assert @dir.dir?
|
@@ -104,7 +90,7 @@ class TestNetFTPListUnix < Test::Unit::TestCase
|
|
104
90
|
|
105
91
|
def test_ruby_unix_like_symlink
|
106
92
|
assert_equal 'bar', @symlink.basename
|
107
|
-
assert_equal
|
93
|
+
assert_equal '/etc', @symlink.symlink_destination
|
108
94
|
assert @symlink.symlink?
|
109
95
|
assert !@symlink.dir?
|
110
96
|
assert !@symlink.file?
|
@@ -152,12 +138,13 @@ class TestNetFTPListUnix < Test::Unit::TestCase
|
|
152
138
|
end
|
153
139
|
|
154
140
|
def test_single_digit_hour
|
155
|
-
|
141
|
+
Timecop.freeze(Time.utc(2014, 8, 16)) do
|
142
|
+
single_digit_hour = nil
|
156
143
|
assert_nothing_raised do
|
157
|
-
|
144
|
+
single_digit_hour = Net::FTP::List.parse('-rw-r--r-- 1 root other 531 Dec 31 3:59 README')
|
158
145
|
end
|
159
146
|
|
160
|
-
assert_equal Time.
|
147
|
+
assert_equal Time.utc(2013, 12, 31, 3, 59), single_digit_hour.mtime
|
161
148
|
end
|
162
149
|
end
|
163
150
|
end
|
metadata
CHANGED
@@ -1,17 +1,31 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: net-ftp-list
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stateless Systems
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rubocop-bsm
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
31
|
- - ">="
|
@@ -38,19 +52,33 @@ dependencies:
|
|
38
52
|
- - ">="
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: timecop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
41
69
|
description:
|
42
70
|
email: enquiries@statelesssystems.com
|
43
71
|
executables: []
|
44
72
|
extensions: []
|
45
|
-
extra_rdoc_files:
|
46
|
-
- README.txt
|
73
|
+
extra_rdoc_files: []
|
47
74
|
files:
|
48
|
-
- ".
|
75
|
+
- ".github/workflows/test.yml"
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rubocop.yml"
|
49
78
|
- Gemfile
|
50
79
|
- Gemfile.lock
|
51
80
|
- README.txt
|
52
81
|
- Rakefile
|
53
|
-
- VERSION.yml
|
54
82
|
- lib/net/ftp/list.rb
|
55
83
|
- lib/net/ftp/list/entry.rb
|
56
84
|
- lib/net/ftp/list/microsoft.rb
|
@@ -67,7 +95,8 @@ files:
|
|
67
95
|
- test/test_net_ftp_list_rumpus.rb
|
68
96
|
- test/test_net_ftp_list_unix.rb
|
69
97
|
homepage: http://github.com/stateless-systems/net-ftp-list
|
70
|
-
licenses:
|
98
|
+
licenses:
|
99
|
+
- MIT
|
71
100
|
metadata: {}
|
72
101
|
post_install_message:
|
73
102
|
rdoc_options: []
|
@@ -77,16 +106,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
77
106
|
requirements:
|
78
107
|
- - ">="
|
79
108
|
- !ruby/object:Gem::Version
|
80
|
-
version: '
|
109
|
+
version: '2.5'
|
81
110
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
111
|
requirements:
|
83
112
|
- - ">="
|
84
113
|
- !ruby/object:Gem::Version
|
85
114
|
version: '0'
|
86
115
|
requirements: []
|
87
|
-
|
88
|
-
rubygems_version: 2.7.6
|
116
|
+
rubygems_version: 3.0.3
|
89
117
|
signing_key:
|
90
118
|
specification_version: 4
|
91
119
|
summary: Parse FTP LIST command output.
|
92
|
-
test_files:
|
120
|
+
test_files:
|
121
|
+
- test/test_net_ftp_list.rb
|
122
|
+
- test/test_net_ftp_list_entry.rb
|
123
|
+
- test/test_net_ftp_list_microsoft.rb
|
124
|
+
- test/test_net_ftp_list_netware.rb
|
125
|
+
- test/test_net_ftp_list_rumpus.rb
|
126
|
+
- test/test_net_ftp_list_unix.rb
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.0.0-p451
|