net-ftp-list 3.2.5 → 3.2.6
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/.ruby-version +1 -0
- data/Rakefile +1 -1
- data/VERSION.yml +3 -3
- data/lib/net/ftp/list/entry.rb +1 -1
- data/lib/net/ftp/list/unix.rb +15 -8
- data/net-ftp-list.gemspec +8 -7
- data/test/test_net_ftp_list_unix.rb +19 -10
- metadata +41 -19
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.8.7-p371
|
data/Rakefile
CHANGED
data/VERSION.yml
CHANGED
data/lib/net/ftp/list/entry.rb
CHANGED
@@ -8,7 +8,7 @@ class Net::FTP::List::Entry
|
|
8
8
|
# that can be used on the object. By default just takes and set the raw list entry.
|
9
9
|
# Net::FTP::List.parse(raw_list_string) # => Net::FTP::List::Parser instance.
|
10
10
|
def initialize(raw_ls_line, optional_attributes = {}) #:nodoc:
|
11
|
-
@raw = raw_ls_line.force_encoding('utf-8')
|
11
|
+
@raw = raw_ls_line.respond_to?(:force_encoding) ? raw_ls_line.force_encoding('utf-8') : raw_ls_line
|
12
12
|
optional_attributes.each_pair do |key, value|
|
13
13
|
raise ArgumentError, "#{key} is not supported" unless ALLOWED_ATTRIBUTES.include?(key)
|
14
14
|
instance_variable_set("@#{key}", value.respond_to?(:force_encoding) ? value.force_encoding('utf-8') : value)
|
data/lib/net/ftp/list/unix.rb
CHANGED
@@ -44,19 +44,26 @@ class Net::FTP::List::Unix < Net::FTP::List::Parser
|
|
44
44
|
|
45
45
|
# TODO: Permissions, users, groups, date/time.
|
46
46
|
filesize = match[18].to_i
|
47
|
-
|
48
|
-
|
47
|
+
|
48
|
+
mtime_month_and_day = match[19]
|
49
|
+
mtime_time_or_year = match[20]
|
49
50
|
|
50
51
|
# Unix mtimes specify a 4 digit year unless the data is within the past 180
|
51
52
|
# days or so. Future dates always specify a 4 digit year.
|
52
|
-
#
|
53
|
-
#
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
53
|
+
# If the parsed date, with today's year, could be in the future, then
|
54
|
+
# the date must be for the previous year
|
55
|
+
mtime_string = if mtime_time_or_year.match(/^[0-9][0-9]:[0-9][0-9]$/)
|
56
|
+
if Time.parse("#{mtime_month_and_day} #{Time.now.year}") > Time.now
|
57
|
+
"#{mtime_month_and_day} #{mtime_time_or_year} #{Time.now.year - 1}"
|
58
|
+
else
|
59
|
+
"#{mtime_month_and_day} #{mtime_time_or_year} #{Time.now.year}"
|
60
|
+
end
|
61
|
+
elsif mtime_time_or_year.match(/^[0-9][0-9][0-9][0-9]$/)
|
62
|
+
"#{mtime_month_and_day} #{mtime_time_or_year}"
|
58
63
|
end
|
59
64
|
|
65
|
+
mtime = Time.parse(mtime_string)
|
66
|
+
|
60
67
|
basename = match[21].strip
|
61
68
|
|
62
69
|
# filenames with spaces will end up in the last match
|
data/net-ftp-list.gemspec
CHANGED
@@ -4,17 +4,18 @@
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "3.2.
|
7
|
+
s.name = %q{net-ftp-list}
|
8
|
+
s.version = "3.2.6"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Stateless Systems"]
|
12
|
-
s.date =
|
13
|
-
s.email =
|
12
|
+
s.date = %q{2013-08-27}
|
13
|
+
s.email = %q{enquiries@statelesssystems.com}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"README.txt"
|
16
16
|
]
|
17
17
|
s.files = [
|
18
|
+
".ruby-version",
|
18
19
|
"README.txt",
|
19
20
|
"Rakefile",
|
20
21
|
"VERSION.yml",
|
@@ -34,10 +35,10 @@ Gem::Specification.new do |s|
|
|
34
35
|
"test/test_net_ftp_list_rumpus.rb",
|
35
36
|
"test/test_net_ftp_list_unix.rb"
|
36
37
|
]
|
37
|
-
s.homepage =
|
38
|
+
s.homepage = %q{http://github.com/stateless-systems/net-ftp-list}
|
38
39
|
s.require_paths = ["lib"]
|
39
|
-
s.rubygems_version =
|
40
|
-
s.summary =
|
40
|
+
s.rubygems_version = %q{1.6.2}
|
41
|
+
s.summary = %q{Parse FTP LIST command output.}
|
41
42
|
|
42
43
|
if s.respond_to? :specification_version then
|
43
44
|
s.specification_version = 3
|
@@ -14,6 +14,7 @@ class TestNetFTPListUnix < Test::Unit::TestCase
|
|
14
14
|
@socket_dev = Net::FTP::List.parse 'srw-rw-rw- 1 root root 0 Aug 20 14:15 log' rescue nil
|
15
15
|
@pipe_dev = Net::FTP::List.parse 'prw-r----- 1 root adm 0 Nov 22 10:30 xconsole' rescue nil
|
16
16
|
@file_no_inodes = Net::FTP::List.parse '-rw-r--r-- foo@localhost foo@localhost 6034 May 14 23:13 index.html' rescue nil
|
17
|
+
@file_today = Net::FTP::List.parse 'crw-rw-rw- 1 root root 1, 3 Aug 16 14:28 today.txt' rescue nil
|
17
18
|
end
|
18
19
|
|
19
20
|
def test_parse_new
|
@@ -50,32 +51,40 @@ class TestNetFTPListUnix < Test::Unit::TestCase
|
|
50
51
|
|
51
52
|
# mtimes in the past, same year.
|
52
53
|
def test_ruby_unix_like_date_past_same_year
|
53
|
-
|
54
|
-
|
54
|
+
|
55
|
+
Time.time_travel(Time.local(2009, 1, 1)) do
|
56
|
+
assert_equal Time.local(2009, 1, 1), Net::FTP::List.parse(@dir.raw).mtime
|
55
57
|
end
|
56
|
-
Time.time_travel(Time.
|
57
|
-
assert_equal Time.
|
58
|
+
Time.time_travel(Time.local(2008, 4, 1)) do
|
59
|
+
assert_equal Time.local(2008, 3, 11, 7, 57), Net::FTP::List.parse(@other_dir.raw).mtime
|
58
60
|
end
|
59
61
|
end
|
60
62
|
|
61
63
|
# mtimes in the past, previous year
|
62
64
|
def test_ruby_unix_like_date_past_previous_year
|
63
|
-
Time.time_travel(Time.
|
64
|
-
assert_equal Time.
|
65
|
+
Time.time_travel(Time.local(2008, 2, 4)) do
|
66
|
+
assert_equal Time.local(2007, 10, 30, 15, 26), Net::FTP::List.parse(@symlink.raw).mtime
|
65
67
|
end
|
66
68
|
end
|
67
69
|
|
68
70
|
# mtime in the future.
|
69
71
|
def test_ruby_unix_like_date_future
|
70
|
-
Time.time_travel(Time.
|
71
|
-
assert_equal Time.
|
72
|
+
Time.time_travel(Time.local(2006, 3, 1)) do
|
73
|
+
assert_equal Time.local(2006, 4, 13), Net::FTP::List.parse(@char_dev.raw).mtime
|
72
74
|
end
|
73
75
|
end
|
74
76
|
|
75
77
|
# Parsed during a leap year.
|
76
78
|
def test_ruby_unix_like_date_leap_year
|
77
|
-
Time.time_travel(Time.
|
78
|
-
assert_equal Time.
|
79
|
+
Time.time_travel(Time.local(2012, 1, 2)) do
|
80
|
+
assert_equal Time.local(2011, 10, 30, 15, 26), Net::FTP::List.parse(@symlink.raw).mtime
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
# mtimes today, same year.
|
85
|
+
def test_ruby_unix_like_date_today_same_year
|
86
|
+
Time.time_travel(Time.local(2013, 8, 16)) do
|
87
|
+
assert_equal Time.local(2013, 8, 16, 14, 28), Net::FTP::List.parse(@file_today.raw).mtime
|
79
88
|
end
|
80
89
|
end
|
81
90
|
|
metadata
CHANGED
@@ -1,23 +1,34 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: net-ftp-list
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 3
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 3
|
8
|
+
- 2
|
9
|
+
- 6
|
10
|
+
version: 3.2.6
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Stateless Systems
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
17
|
+
|
18
|
+
date: 2013-08-27 00:00:00 +10:00
|
19
|
+
default_executable:
|
13
20
|
dependencies: []
|
21
|
+
|
14
22
|
description:
|
15
23
|
email: enquiries@statelesssystems.com
|
16
24
|
executables: []
|
25
|
+
|
17
26
|
extensions: []
|
18
|
-
|
27
|
+
|
28
|
+
extra_rdoc_files:
|
19
29
|
- README.txt
|
20
|
-
files:
|
30
|
+
files:
|
31
|
+
- .ruby-version
|
21
32
|
- README.txt
|
22
33
|
- Rakefile
|
23
34
|
- VERSION.yml
|
@@ -36,28 +47,39 @@ files:
|
|
36
47
|
- test/test_net_ftp_list_netware.rb
|
37
48
|
- test/test_net_ftp_list_rumpus.rb
|
38
49
|
- test/test_net_ftp_list_unix.rb
|
50
|
+
has_rdoc: true
|
39
51
|
homepage: http://github.com/stateless-systems/net-ftp-list
|
40
52
|
licenses: []
|
53
|
+
|
41
54
|
post_install_message:
|
42
55
|
rdoc_options: []
|
43
|
-
|
56
|
+
|
57
|
+
require_paths:
|
44
58
|
- lib
|
45
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
60
|
none: false
|
47
|
-
requirements:
|
48
|
-
- -
|
49
|
-
- !ruby/object:Gem::Version
|
50
|
-
|
51
|
-
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
hash: 3
|
65
|
+
segments:
|
66
|
+
- 0
|
67
|
+
version: "0"
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
69
|
none: false
|
53
|
-
requirements:
|
54
|
-
- -
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
hash: 3
|
74
|
+
segments:
|
75
|
+
- 0
|
76
|
+
version: "0"
|
57
77
|
requirements: []
|
78
|
+
|
58
79
|
rubyforge_project:
|
59
|
-
rubygems_version: 1.
|
80
|
+
rubygems_version: 1.6.2
|
60
81
|
signing_key:
|
61
82
|
specification_version: 3
|
62
83
|
summary: Parse FTP LIST command output.
|
63
84
|
test_files: []
|
85
|
+
|