net-ftp-list 3.2.3 → 3.2.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  ---
2
+ :build:
2
3
  :major: 3
3
4
  :minor: 2
4
- :patch: 3
5
- :build:
5
+ :patch: 4
@@ -5,11 +5,10 @@ require 'date'
5
5
  #
6
6
  # == MATCHES
7
7
  #
8
- # 06-25-07 01:08PM <DIR> etc
9
- # 11-27-07 08:45PM 23437 README.TXT
8
+ # 06-25-2007 01:08PM <DIR> etc
9
+ # 06-25-07 01:08PM <DIR> etc
10
+ # 11-27-07 08:45PM 23437 README.TXT
10
11
  class Net::FTP::List::Microsoft < Net::FTP::List::Parser
11
- # Stolen straight from the ASF's commons Java FTP LIST parser library.
12
- # http://svn.apache.org/repos/asf/commons/proper/net/trunk/src/java/org/apache/commons/net/ftp/
13
12
  REGEXP = %r!
14
13
  ^\s*
15
14
  ([0-9\-:\/]{5,})\s+([0-9\-:]{3,}(?:[aApP][mM])?)\s+
@@ -22,7 +21,16 @@ class Net::FTP::List::Microsoft < Net::FTP::List::Parser
22
21
  def self.parse(raw)
23
22
  match = REGEXP.match(raw.strip) or return false
24
23
 
25
- mtime = DateTime.strptime("#{match[1]} #{match[2]}", "%m-%d-%y %H:%M%p")
24
+ date_match = %r!(\d\d).(\d\d).(\d\d(?:\d\d)?)!.match(match[1])
25
+ date_format = date_match[1].to_i > 12 ? '%d-%m-%y' : '%m-%d-%y'
26
+ date_format.sub!(%r{%y}, '%Y') if date_match[3].length > 2
27
+
28
+ if match[1] !~ /\-/
29
+ date_format.gsub!(/\-/, '/') if match[1] =~ %r{/}
30
+ date_format.gsub!(/\-/, ':') if match[1] =~ %r{:}
31
+ end
32
+
33
+ mtime = DateTime.strptime("#{match[1]} #{match[2]}", "#{date_format} %H:%M%p")
26
34
  is_dir = match[3] == '<DIR>'
27
35
  filesize = is_dir ? 0 : match[4].to_i
28
36
 
@@ -4,13 +4,13 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{net-ftp-list}
8
- s.version = "3.2.3"
7
+ s.name = "net-ftp-list"
8
+ s.version = "3.2.4"
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 = %q{2012-05-16}
13
- s.email = %q{enquiries@statelesssystems.com}
12
+ s.date = "2012-09-14"
13
+ s.email = "enquiries@statelesssystems.com"
14
14
  s.extra_rdoc_files = [
15
15
  "README.txt"
16
16
  ]
@@ -34,13 +34,12 @@ Gem::Specification.new do |s|
34
34
  "test/test_net_ftp_list_rumpus.rb",
35
35
  "test/test_net_ftp_list_unix.rb"
36
36
  ]
37
- s.homepage = %q{http://github.com/stateless-systems/net-ftp-list}
37
+ s.homepage = "http://github.com/stateless-systems/net-ftp-list"
38
38
  s.require_paths = ["lib"]
39
- s.rubygems_version = %q{1.3.7}
40
- s.summary = %q{Parse FTP LIST command output.}
39
+ s.rubygems_version = "1.8.15"
40
+ s.summary = "Parse FTP LIST command output."
41
41
 
42
42
  if s.respond_to? :specification_version then
43
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
44
43
  s.specification_version = 3
45
44
 
46
45
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
@@ -13,6 +13,54 @@ class TestNetFTPListMicrosoft < Test::Unit::TestCase
13
13
  assert_equal "Microsoft", @file.server_type, 'LIST M$ directory'
14
14
  end
15
15
 
16
+ def test_parse_dd_mm_yyyy
17
+ dd_mm_yyyy = nil
18
+ assert_nothing_raised do
19
+ dd_mm_yyyy = Net::FTP::List.parse('25-06-2007 01:08PM <DIR> etc')
20
+ end
21
+ assert_equal dd_mm_yyyy.mtime.strftime('%Y-%m-%d'), '2007-06-25'
22
+ end
23
+
24
+ def test_parse_dd_mm_yy
25
+ dd_mm_yy = nil
26
+ assert_nothing_raised do
27
+ dd_mm_yy = Net::FTP::List.parse('25-06-07 01:08PM <DIR> etc')
28
+ end
29
+ assert_equal dd_mm_yy.mtime.strftime('%Y-%m-%d'), '2007-06-25'
30
+ end
31
+
32
+ def test_parse_mm_dd_yy
33
+ mm_dd_yy = nil
34
+ assert_nothing_raised do
35
+ mm_dd_yy = Net::FTP::List.parse('06-25-07 01:08PM <DIR> etc')
36
+ end
37
+ assert_equal mm_dd_yy.mtime.strftime('%Y-%m-%d'), '2007-06-25'
38
+ end
39
+
40
+ def test_default_date_mm_dd_yy
41
+ mm_dd_yy = nil
42
+ assert_nothing_raised do
43
+ mm_dd_yy = Net::FTP::List.parse('01-02-03 01:08PM <DIR> etc')
44
+ end
45
+ assert_equal mm_dd_yy.mtime.strftime('%Y-%m-%d'), '2003-01-02'
46
+ end
47
+
48
+ def test_parse_slash_delimited_date
49
+ slash_delimited = nil
50
+ assert_nothing_raised do
51
+ slash_delimited = Net::FTP::List.parse('06/25/07 01:08PM <DIR> etc')
52
+ end
53
+ assert_equal slash_delimited.mtime.strftime('%Y-%m-%d'), '2007-06-25'
54
+ end
55
+
56
+ def test_parse_colon_delimited_date
57
+ colon_delimited = nil
58
+ assert_nothing_raised do
59
+ colon_delimited = Net::FTP::List.parse('06:25:07 01:08PM <DIR> etc')
60
+ end
61
+ assert_equal colon_delimited.mtime.strftime('%Y-%m-%d'), '2007-06-25'
62
+ end
63
+
16
64
  def test_rubbish_lines
17
65
  assert_instance_of Net::FTP::List::Entry, Net::FTP::List.parse("++ bah! ++")
18
66
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-ftp-list
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 7
5
+ prerelease:
5
6
  segments:
6
7
  - 3
7
8
  - 2
8
- - 3
9
- version: 3.2.3
9
+ - 4
10
+ version: 3.2.4
10
11
  platform: ruby
11
12
  authors:
12
13
  - Stateless Systems
@@ -14,8 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2012-05-16 00:00:00 +10:00
18
- default_executable:
18
+ date: 2012-09-14 00:00:00 Z
19
19
  dependencies: []
20
20
 
21
21
  description:
@@ -45,7 +45,6 @@ files:
45
45
  - test/test_net_ftp_list_netware.rb
46
46
  - test/test_net_ftp_list_rumpus.rb
47
47
  - test/test_net_ftp_list_unix.rb
48
- has_rdoc: true
49
48
  homepage: http://github.com/stateless-systems/net-ftp-list
50
49
  licenses: []
51
50
 
@@ -59,6 +58,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
59
58
  requirements:
60
59
  - - ">="
61
60
  - !ruby/object:Gem::Version
61
+ hash: 3
62
62
  segments:
63
63
  - 0
64
64
  version: "0"
@@ -67,13 +67,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
67
  requirements:
68
68
  - - ">="
69
69
  - !ruby/object:Gem::Version
70
+ hash: 3
70
71
  segments:
71
72
  - 0
72
73
  version: "0"
73
74
  requirements: []
74
75
 
75
76
  rubyforge_project:
76
- rubygems_version: 1.3.7
77
+ rubygems_version: 1.8.15
77
78
  signing_key:
78
79
  specification_version: 3
79
80
  summary: Parse FTP LIST command output.