net-ftp-list 1.0 → 2.0.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 +42 -41
- data/VERSION.yml +4 -0
- data/lib/net/ftp/list.rb +1 -0
- data/lib/net/ftp/list/netware.rb +50 -0
- data/test/test_net_ftp_list_netware.rb +32 -0
- metadata +52 -38
data/Rakefile
CHANGED
@@ -1,51 +1,52 @@
|
|
1
|
-
|
1
|
+
require 'rubygems'
|
2
2
|
require 'rake'
|
3
|
-
require 'rake/clean'
|
4
|
-
require 'rake/gempackagetask'
|
5
|
-
require 'rake/testtask'
|
6
|
-
|
7
|
-
NAME = 'net-ftp-list'
|
8
|
-
VERS = '1.0'
|
9
|
-
|
10
|
-
CLEAN.include ['**/*.log', '*.gem']
|
11
|
-
CLOBBER.include ['**/*.log']
|
12
3
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
s.files = FileList['Rakefile', '**/*.{rb,txt}'].to_a
|
26
|
-
s.test_files = FileList['tests/*.rb'].to_a
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "net-ftp-list"
|
8
|
+
gem.summary = %Q{Parse FTP LIST command output.}
|
9
|
+
gem.email = "enquiries@statelesssystems.com"
|
10
|
+
gem.homepage = "http://github.com/stateless-systems/net-ftp-list"
|
11
|
+
gem.authors = ["Stateless Systems"]
|
12
|
+
end
|
13
|
+
rescue LoadError
|
14
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
27
15
|
end
|
28
16
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
p.gem_spec = spec
|
17
|
+
require 'rake/testtask'
|
18
|
+
Rake::TestTask.new(:test) do |test|
|
19
|
+
test.libs << 'lib' << 'test'
|
20
|
+
test.pattern = 'test/**/*_test.rb'
|
21
|
+
test.verbose = true
|
35
22
|
end
|
36
23
|
|
37
|
-
|
38
|
-
|
39
|
-
|
24
|
+
begin
|
25
|
+
require 'rcov/rcovtask'
|
26
|
+
Rcov::RcovTask.new do |test|
|
27
|
+
test.libs << 'test'
|
28
|
+
test.pattern = 'test/**/*_test.rb'
|
29
|
+
test.verbose = true
|
30
|
+
end
|
31
|
+
rescue LoadError
|
32
|
+
task :rcov do
|
33
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
34
|
+
end
|
40
35
|
end
|
41
36
|
|
42
|
-
|
43
|
-
task :install do
|
44
|
-
sh %{rake package}
|
45
|
-
sh %{sudo gem install pkg/#{NAME}-#{VERS}}
|
46
|
-
end
|
37
|
+
task :default => :test
|
47
38
|
|
48
|
-
|
49
|
-
|
50
|
-
|
39
|
+
require 'rake/rdoctask'
|
40
|
+
Rake::RDocTask.new do |rdoc|
|
41
|
+
if File.exist?('VERSION.yml')
|
42
|
+
config = YAML.load(File.read('VERSION.yml'))
|
43
|
+
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
44
|
+
else
|
45
|
+
version = ""
|
46
|
+
end
|
47
|
+
|
48
|
+
rdoc.rdoc_dir = 'rdoc'
|
49
|
+
rdoc.title = "net-ftp-list #{version}"
|
50
|
+
rdoc.rdoc_files.include('README*')
|
51
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
51
52
|
end
|
data/VERSION.yml
ADDED
data/lib/net/ftp/list.rb
CHANGED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'net/ftp/list/parser'
|
2
|
+
|
3
|
+
module Net
|
4
|
+
class FTP
|
5
|
+
module List
|
6
|
+
|
7
|
+
# Parse Netware like FTP LIST entries.
|
8
|
+
#
|
9
|
+
# == MATCHES
|
10
|
+
#
|
11
|
+
# d [RWCEAFMS] dpearce 512 Jun 27 23:46 public.www
|
12
|
+
#
|
13
|
+
# == SYNOPSIS
|
14
|
+
#
|
15
|
+
# entry = Net::FTP::List::Netware.new('d [RWCEAFMS] dpearce 512 Jun 27 23:46 public.www')
|
16
|
+
# entry.dir? # => true
|
17
|
+
# entry.basename # => 'public.www'
|
18
|
+
class Netware < Parser
|
19
|
+
|
20
|
+
# Stolen straight from the ASF's commons Java FTP LIST parser library.
|
21
|
+
# http://svn.apache.org/repos/asf/commons/proper/net/trunk/src/java/org/apache/commons/net/ftp/
|
22
|
+
|
23
|
+
REGEXP = %r!^
|
24
|
+
(d|-){1}\s+
|
25
|
+
\[(.*?)\]\s+
|
26
|
+
(\S+)\s+(\d+)\s+
|
27
|
+
(\S+\s+\S+\s+((\d+:\d+)|(\d{4})))
|
28
|
+
\s+(.*)
|
29
|
+
$!x
|
30
|
+
|
31
|
+
# Parse a Netware like FTP LIST entries.
|
32
|
+
def initialize(raw)
|
33
|
+
super(raw)
|
34
|
+
match = REGEXP.match(raw.strip) or raise ParserError
|
35
|
+
|
36
|
+
if match[1] == 'd'
|
37
|
+
@dir = true
|
38
|
+
else
|
39
|
+
@file = true
|
40
|
+
end
|
41
|
+
|
42
|
+
# TODO: Permissions, users, groups, date/time.
|
43
|
+
|
44
|
+
@basename = match[9]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'net/ftp/list'
|
3
|
+
|
4
|
+
class TestNetFTPListNetware < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@dir = Net::FTP::List.parse('d [RWCEAFMS] dpearce 512 Jun 27 23:46 public.www')
|
8
|
+
@file = Net::FTP::List.parse('- [RWCEAFMS] dpearce 2767 Jun 22 06:22 about.html')
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_parse_new
|
12
|
+
assert_instance_of Net::FTP::List::Netware, @dir, 'LIST Netware directory'
|
13
|
+
assert_instance_of Net::FTP::List::Netware, @file, 'LIST Netware file'
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_rubbish_lines
|
17
|
+
assert_instance_of Net::FTP::List::Unknown, Net::FTP::List.parse("++ bah! ++")
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_ruby_netware_like_dir
|
21
|
+
assert_equal 'public.www', @dir.basename
|
22
|
+
assert @dir.dir?
|
23
|
+
assert !@dir.file?
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_ruby_netware_like_file
|
27
|
+
assert_equal 'about.html', @file.basename
|
28
|
+
assert @file.file?
|
29
|
+
assert !@file.dir?
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
metadata
CHANGED
@@ -1,53 +1,67 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.4
|
3
|
-
specification_version: 1
|
4
2
|
name: net-ftp-list
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version:
|
7
|
-
date: 2008-05-23 00:00:00 +10:00
|
8
|
-
summary: Parse FTP LIST command output.
|
9
|
-
require_paths:
|
10
|
-
- lib
|
11
|
-
email: shane@statelesssystems.com
|
12
|
-
homepage: http://statelesssystems.com
|
13
|
-
rubyforge_project:
|
14
|
-
description: Parse FTP LIST command output.
|
15
|
-
autorequire:
|
16
|
-
default_executable:
|
17
|
-
bindir: bin
|
18
|
-
has_rdoc: true
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">"
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.0.0
|
24
|
-
version:
|
4
|
+
version: 2.0.0
|
25
5
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
|
-
post_install_message:
|
29
6
|
authors:
|
30
|
-
-
|
7
|
+
- Stateless Systems
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-05-05 00:00:00 +10:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description:
|
17
|
+
email: enquiries@statelesssystems.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README.txt
|
31
24
|
files:
|
25
|
+
- README.txt
|
32
26
|
- Rakefile
|
27
|
+
- VERSION.yml
|
28
|
+
- lib/net/ftp/list.rb
|
33
29
|
- lib/net/ftp/list/microsoft.rb
|
30
|
+
- lib/net/ftp/list/netware.rb
|
34
31
|
- lib/net/ftp/list/parser.rb
|
35
32
|
- lib/net/ftp/list/unix.rb
|
36
|
-
- lib/net/ftp/list.rb
|
37
33
|
- test/test_net_ftp_list_microsoft.rb
|
34
|
+
- test/test_net_ftp_list_netware.rb
|
38
35
|
- test/test_net_ftp_list_unix.rb
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
rdoc_options: []
|
43
|
-
|
44
|
-
extra_rdoc_files:
|
45
|
-
- README.txt
|
46
|
-
executables: []
|
47
|
-
|
48
|
-
extensions: []
|
36
|
+
has_rdoc: true
|
37
|
+
homepage: http://github.com/stateless-systems/net-ftp-list
|
38
|
+
licenses: []
|
49
39
|
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options:
|
42
|
+
- --charset=UTF-8
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: "0"
|
50
|
+
version:
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: "0"
|
56
|
+
version:
|
50
57
|
requirements: []
|
51
58
|
|
52
|
-
|
53
|
-
|
59
|
+
rubyforge_project:
|
60
|
+
rubygems_version: 1.3.5
|
61
|
+
signing_key:
|
62
|
+
specification_version: 2
|
63
|
+
summary: Parse FTP LIST command output.
|
64
|
+
test_files:
|
65
|
+
- test/test_net_ftp_list_unix.rb
|
66
|
+
- test/test_net_ftp_list_netware.rb
|
67
|
+
- test/test_net_ftp_list_microsoft.rb
|