redcar 0.3.8.2 → 0.3.8.3
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/CHANGES +5 -0
- data/Rakefile +1 -1
- data/lib/redcar.rb +1 -1
- data/lib/redcar/installer.rb +29 -22
- data/plugins/repl/spec/spec_helper.rb +0 -1
- metadata +2 -15
- data/plugins/project/vendor/net-ftp-list/README.txt +0 -72
- data/plugins/project/vendor/net-ftp-list/Rakefile +0 -52
- data/plugins/project/vendor/net-ftp-list/VERSION.yml +0 -4
- data/plugins/project/vendor/net-ftp-list/lib/net/ftp/list.rb +0 -43
- data/plugins/project/vendor/net-ftp-list/lib/net/ftp/list/microsoft.rb +0 -53
- data/plugins/project/vendor/net-ftp-list/lib/net/ftp/list/netware.rb +0 -53
- data/plugins/project/vendor/net-ftp-list/lib/net/ftp/list/parser.rb +0 -97
- data/plugins/project/vendor/net-ftp-list/lib/net/ftp/list/unix.rb +0 -64
- data/plugins/project/vendor/net-ftp-list/net-ftp-list.gemspec +0 -48
- data/plugins/project/vendor/net-ftp-list/test/test_net_ftp_list_microsoft.rb +0 -38
- data/plugins/project/vendor/net-ftp-list/test/test_net_ftp_list_netware.rb +0 -37
- data/plugins/project/vendor/net-ftp-list/test/test_net_ftp_list_unix.rb +0 -62
- data/plugins/repl/vendor/clojure.jar +0 -0
data/CHANGES
CHANGED
data/Rakefile
CHANGED
data/lib/redcar.rb
CHANGED
data/lib/redcar/installer.rb
CHANGED
|
@@ -93,9 +93,9 @@ module Redcar
|
|
|
93
93
|
|
|
94
94
|
JOPENSSL_DIR = File.expand_path(File.join(File.dirname(__FILE__), "..", "openssl/lib/"))
|
|
95
95
|
JOPENSSL = {
|
|
96
|
-
"/jruby/bcmail-jdk14-139
|
|
97
|
-
"/jruby/bcprov-jdk14-139
|
|
98
|
-
"/jruby/jopenssl
|
|
96
|
+
"/jruby/bcmail-jdk14-139-redcar1.jar" => "bcmail-jdk14-139.jar",
|
|
97
|
+
"/jruby/bcprov-jdk14-139-redcar1.jar" => "bcprov-jdk14-139.jar",
|
|
98
|
+
"/jruby/jopenssl-redcar1.jar" => "jopenssl.jar",
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
REDCAR_JARS = {
|
|
@@ -158,57 +158,64 @@ module Redcar
|
|
|
158
158
|
if uri =~ /^\//
|
|
159
159
|
uri = ASSET_HOST + uri
|
|
160
160
|
end
|
|
161
|
+
print " downloading #{uri}... "; $stdout.flush
|
|
161
162
|
FileUtils.mkdir_p(File.dirname(path))
|
|
162
163
|
File.open(path, "wb") do |write_out|
|
|
163
164
|
write_out.print @connection.get(URI.parse(uri))
|
|
164
165
|
end
|
|
165
166
|
|
|
167
|
+
if File.open(path).read(200) =~ /Access Denied/
|
|
168
|
+
puts "\n\n*** Error downloading #{uri}, got Access Denied from S3."
|
|
169
|
+
exit
|
|
170
|
+
end
|
|
171
|
+
|
|
166
172
|
if path =~ /.*\.zip$/
|
|
167
|
-
|
|
173
|
+
print "done!\n unzipping #{path}..."; $stdout.flush
|
|
168
174
|
Installer.unzip_file(path)
|
|
169
175
|
end
|
|
170
|
-
|
|
171
|
-
# puts " downloaded #{uri}\n to #{path}\n"
|
|
176
|
+
puts "done!"
|
|
172
177
|
end
|
|
173
178
|
|
|
174
179
|
def setup(name, options)
|
|
175
|
-
resources
|
|
176
|
-
|
|
180
|
+
resources = options.delete(:resources)
|
|
181
|
+
target_dir = options.delete(:path)
|
|
177
182
|
|
|
178
183
|
if resources.is_a?(Array)
|
|
179
184
|
resources.each do |resource|
|
|
180
|
-
setup_resource
|
|
185
|
+
setup_resource(name, target_dir, resource, File.basename(resource))
|
|
181
186
|
end
|
|
182
187
|
else
|
|
183
|
-
resources.
|
|
184
|
-
setup_resource
|
|
188
|
+
resources.each do |url_path, target_path|
|
|
189
|
+
setup_resource(name, target_dir, url_path, target_path)
|
|
185
190
|
end
|
|
186
191
|
end
|
|
187
192
|
end
|
|
188
193
|
|
|
189
|
-
def setup_resource(name,
|
|
190
|
-
|
|
191
|
-
return if File.exist?(
|
|
194
|
+
def setup_resource(name, target_dir, url_path, target_path)
|
|
195
|
+
target_file = File.join(target_dir, target_path)
|
|
196
|
+
return if File.exist?(target_file)
|
|
192
197
|
|
|
193
|
-
cached = File.join(redcar_jars_dir,
|
|
198
|
+
cached = File.join(redcar_jars_dir, File.basename(url_path))
|
|
194
199
|
unless File.exists?(cached)
|
|
195
|
-
|
|
196
|
-
download(url, cached)
|
|
197
|
-
puts "done!"
|
|
200
|
+
download(url_path, cached)
|
|
198
201
|
end
|
|
199
202
|
|
|
200
|
-
FileUtils.mkdir_p File.dirname(
|
|
201
|
-
link(cached,
|
|
203
|
+
FileUtils.mkdir_p File.dirname(target_file)
|
|
204
|
+
link(cached, target_file)
|
|
202
205
|
end
|
|
203
206
|
|
|
204
207
|
def link(cached, target)
|
|
205
208
|
# Windoze doesn't support FileUtils.ln_sf, so we copy the files
|
|
206
209
|
if Config::CONFIG["host_os"] =~ /windows|mswin|mingw/i
|
|
207
|
-
|
|
210
|
+
print " copying #{File.basename(cached)}... "
|
|
211
|
+
$stdout.flush
|
|
208
212
|
FileUtils.cp_r cached, target
|
|
213
|
+
puts "done"
|
|
209
214
|
else
|
|
210
|
-
|
|
215
|
+
print " linking #{File.basename(cached)}... "
|
|
216
|
+
$stdout.flush
|
|
211
217
|
FileUtils.ln_sf cached, target
|
|
218
|
+
puts "done"
|
|
212
219
|
end
|
|
213
220
|
end
|
|
214
221
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: redcar
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.8.
|
|
4
|
+
version: 0.3.8.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniel Lucraft
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2010-07-
|
|
12
|
+
date: 2010-07-24 00:00:00 +01:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
@@ -855,18 +855,6 @@ files:
|
|
|
855
855
|
- plugins/project/spec/project/file_list_spec.rb
|
|
856
856
|
- plugins/project/spec/project/file_mirror_spec.rb
|
|
857
857
|
- plugins/project/spec/spec_helper.rb
|
|
858
|
-
- plugins/project/vendor/net-ftp-list/lib/net/ftp/list/microsoft.rb
|
|
859
|
-
- plugins/project/vendor/net-ftp-list/lib/net/ftp/list/netware.rb
|
|
860
|
-
- plugins/project/vendor/net-ftp-list/lib/net/ftp/list/parser.rb
|
|
861
|
-
- plugins/project/vendor/net-ftp-list/lib/net/ftp/list/unix.rb
|
|
862
|
-
- plugins/project/vendor/net-ftp-list/lib/net/ftp/list.rb
|
|
863
|
-
- plugins/project/vendor/net-ftp-list/net-ftp-list.gemspec
|
|
864
|
-
- plugins/project/vendor/net-ftp-list/Rakefile
|
|
865
|
-
- plugins/project/vendor/net-ftp-list/README.txt
|
|
866
|
-
- plugins/project/vendor/net-ftp-list/test/test_net_ftp_list_microsoft.rb
|
|
867
|
-
- plugins/project/vendor/net-ftp-list/test/test_net_ftp_list_netware.rb
|
|
868
|
-
- plugins/project/vendor/net-ftp-list/test/test_net_ftp_list_unix.rb
|
|
869
|
-
- plugins/project/vendor/net-ftp-list/VERSION.yml
|
|
870
858
|
- plugins/project/vendor/net-sftp/lib/net/sftp/constants.rb
|
|
871
859
|
- plugins/project/vendor/net-sftp/lib/net/sftp/errors.rb
|
|
872
860
|
- plugins/project/vendor/net-sftp/lib/net/sftp/operations/dir.rb
|
|
@@ -1071,7 +1059,6 @@ files:
|
|
|
1071
1059
|
- plugins/repl/plugin.rb
|
|
1072
1060
|
- plugins/repl/spec/repl/internal_mirror_spec.rb
|
|
1073
1061
|
- plugins/repl/spec/spec_helper.rb
|
|
1074
|
-
- plugins/repl/vendor/clojure.jar
|
|
1075
1062
|
- plugins/runnables/icons/cog.png
|
|
1076
1063
|
- plugins/runnables/lib/runnables/command_output_controller.rb
|
|
1077
1064
|
- plugins/runnables/lib/runnables/running_process_checker.rb
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
= Net::Ftp::List
|
|
2
|
-
|
|
3
|
-
== DESCRIPTION
|
|
4
|
-
|
|
5
|
-
Ruby lib to parse FTP LIST responses.
|
|
6
|
-
|
|
7
|
-
According to the FTP RFC the LIST command "information on a file may vary widely from system to system, this
|
|
8
|
-
information may be hard to use automatically in a program, but may be quite useful to a human user".
|
|
9
|
-
Unfortunately the NLST command "intended to return information that can be used by a program to further process
|
|
10
|
-
the files automatically" only returns the filename and no other information. If you want to know to know even
|
|
11
|
-
simple things like 'is the NLST entry a directory or file' you are left with the choice of attempting to CWD to
|
|
12
|
-
(and back from) each entry or parsing the LIST command. This extension is an attempt at parsing the LIST command
|
|
13
|
-
and as such is subject to all the variability that results from such an undertaking, take responses with a grain
|
|
14
|
-
of salt and expect failures.
|
|
15
|
-
|
|
16
|
-
See the RFC for more guff on LIST and NLST: http://www.ietf.org/rfc/rfc0959.txt
|
|
17
|
-
|
|
18
|
-
== TODO & PROBLEMS
|
|
19
|
-
|
|
20
|
-
* I'm new to Ruby, I'm sure some exist :)
|
|
21
|
-
* The factory and abstract base class for parsers are one and the same. OO geeks will cry.
|
|
22
|
-
* More OS's and server types. Only servers that return Unix like LIST responses will work at the moment.
|
|
23
|
-
* Calling <tt>if entry.file? or entry.dir?</tt> is hard work when you really mean <tt>unless entry.unknown?</tt>
|
|
24
|
-
|
|
25
|
-
== SYNOPSIS
|
|
26
|
-
|
|
27
|
-
require 'net/ftp' # Not really required but I like to list dependencies sometimes.
|
|
28
|
-
require 'net/ftp/list'
|
|
29
|
-
|
|
30
|
-
ftp = Net::FTP.open('somehost.com', 'user', 'pass')
|
|
31
|
-
ftp.list('/some/path') do |e|
|
|
32
|
-
entry = Net::FTP::List.parse(e)
|
|
33
|
-
|
|
34
|
-
# Ignore everything that's not a file (so symlinks, directories and devices etc.)
|
|
35
|
-
next unless entry.file?
|
|
36
|
-
|
|
37
|
-
# If entry isn't a kind_of Net::FTP::List::Unknown then there is a bug in Net::FTP::List if this isn't the
|
|
38
|
-
# same name as ftp.nlist('/some/path') would have returned.
|
|
39
|
-
puts entry.basename
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
== CREDITS
|
|
43
|
-
|
|
44
|
-
* ASF, Commons. http://commons.apache.org/
|
|
45
|
-
* The good people at Stateless Systems who let me write Ruby and give it away.
|
|
46
|
-
|
|
47
|
-
== LICENSE
|
|
48
|
-
|
|
49
|
-
(The MIT License, go nuts)
|
|
50
|
-
|
|
51
|
-
Copyright (c) 2007 Shane Hanna
|
|
52
|
-
Stateless Systems
|
|
53
|
-
http://statelesssystems.com
|
|
54
|
-
|
|
55
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
56
|
-
a copy of this software and associated documentation files (the
|
|
57
|
-
'Software'), to deal in the Software without restriction, including
|
|
58
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
59
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
60
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
61
|
-
the following conditions:
|
|
62
|
-
|
|
63
|
-
The above copyright notice and this permission notice shall be
|
|
64
|
-
included in all copies or substantial portions of the Software.
|
|
65
|
-
|
|
66
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
67
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
68
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
69
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
70
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
71
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
72
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
require 'rubygems'
|
|
2
|
-
require 'rake'
|
|
3
|
-
|
|
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"
|
|
15
|
-
end
|
|
16
|
-
|
|
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
|
|
22
|
-
end
|
|
23
|
-
|
|
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
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
task :default => :test
|
|
38
|
-
|
|
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')
|
|
52
|
-
end
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
require 'net/ftp'
|
|
2
|
-
require 'net/ftp/list/parser'
|
|
3
|
-
|
|
4
|
-
# The order here is important for the time being. Corse grained parsers should appear before specializations because
|
|
5
|
-
# the whole thing is searched in reverse order.
|
|
6
|
-
require 'net/ftp/list/unix'
|
|
7
|
-
require 'net/ftp/list/microsoft'
|
|
8
|
-
require 'net/ftp/list/netware'
|
|
9
|
-
|
|
10
|
-
module Net #:nodoc:
|
|
11
|
-
class FTP #:nodoc:
|
|
12
|
-
|
|
13
|
-
# Parse FTP LIST responses.
|
|
14
|
-
#
|
|
15
|
-
# == Creation
|
|
16
|
-
#
|
|
17
|
-
# require 'net/ftp' # Not really required but I like to list dependencies sometimes.
|
|
18
|
-
# require 'net/ftp/list'
|
|
19
|
-
#
|
|
20
|
-
# ftp = Net::FTP.open('somehost.com', 'user', 'pass')
|
|
21
|
-
# ftp.list('/some/path') do |e|
|
|
22
|
-
# entry = Net::FTP::List.parse(e)
|
|
23
|
-
#
|
|
24
|
-
# # Ignore everything that's not a file (so symlinks, directories and devices etc.)
|
|
25
|
-
# next unless entry.file?
|
|
26
|
-
#
|
|
27
|
-
# # If entry isn't a kind_of Net::FTP::List::Unknown then there is a bug in Net::FTP::List if this isn't the
|
|
28
|
-
# # same name as ftp.nlist('/some/path') would have returned.
|
|
29
|
-
# puts entry.basename
|
|
30
|
-
# end
|
|
31
|
-
#
|
|
32
|
-
# == Exceptions
|
|
33
|
-
#
|
|
34
|
-
# None at this time. At worst you'll end up with an Net::FTP::List::Unknown instance which won't have any extra
|
|
35
|
-
# useful information. Methods like <tt>dir?</tt>, <tt>file?</tt> and <tt>symlink?</tt> will all return +false+.
|
|
36
|
-
module List
|
|
37
|
-
def self.parse(*args)
|
|
38
|
-
Parser.parse(*args)
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
require 'net/ftp/list/parser'
|
|
2
|
-
require 'date'
|
|
3
|
-
|
|
4
|
-
module Net
|
|
5
|
-
class FTP
|
|
6
|
-
module List
|
|
7
|
-
|
|
8
|
-
# Parse Microsoft(NT) like FTP LIST entries.
|
|
9
|
-
#
|
|
10
|
-
# == MATCHES
|
|
11
|
-
#
|
|
12
|
-
# 06-25-07 01:08PM <DIR> etc
|
|
13
|
-
# 11-27-07 08:45PM 23437 README.TXT
|
|
14
|
-
#
|
|
15
|
-
# == SYNOPSIS
|
|
16
|
-
#
|
|
17
|
-
# entry = Net::FTP::List::Microsoft.new('06-25-07 01:08PM <DIR> etc')
|
|
18
|
-
# entry.dir? # => true
|
|
19
|
-
# entry.basename # => 'etc'
|
|
20
|
-
class Microsoft < Parser
|
|
21
|
-
|
|
22
|
-
# Stolen straight from the ASF's commons Java FTP LIST parser library.
|
|
23
|
-
# http://svn.apache.org/repos/asf/commons/proper/net/trunk/src/java/org/apache/commons/net/ftp/
|
|
24
|
-
REGEXP = %r!
|
|
25
|
-
^\s*
|
|
26
|
-
([0-9\-:\/]{5,})\s+([0-9\-:]{3,}(?:[aApP][mM])?)\s+
|
|
27
|
-
(?:(<DIR>)|([0-9]+))\s+
|
|
28
|
-
(\S.*)
|
|
29
|
-
\s*$
|
|
30
|
-
!x
|
|
31
|
-
|
|
32
|
-
# Parse a Microsoft(NT) like FTP LIST entries.
|
|
33
|
-
def initialize(raw)
|
|
34
|
-
super(raw)
|
|
35
|
-
match = REGEXP.match(raw.strip) or raise ParserError
|
|
36
|
-
|
|
37
|
-
@mtime = DateTime.strptime("#{match[1]} #{match[2]}", "%m-%d-%y %I:%M%p")
|
|
38
|
-
|
|
39
|
-
if match[3] == '<DIR>'
|
|
40
|
-
@dir = true
|
|
41
|
-
else
|
|
42
|
-
@file = true
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
# TODO: Permissions, users, groups, date/time.
|
|
46
|
-
|
|
47
|
-
@basename = match[5]
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
require 'net/ftp/list/parser'
|
|
2
|
-
require 'time'
|
|
3
|
-
|
|
4
|
-
module Net
|
|
5
|
-
class FTP
|
|
6
|
-
module List
|
|
7
|
-
|
|
8
|
-
# Parse Netware like FTP LIST entries.
|
|
9
|
-
#
|
|
10
|
-
# == MATCHES
|
|
11
|
-
#
|
|
12
|
-
# d [RWCEAFMS] dpearce 512 Jun 27 23:46 public.www
|
|
13
|
-
#
|
|
14
|
-
# == SYNOPSIS
|
|
15
|
-
#
|
|
16
|
-
# entry = Net::FTP::List::Netware.new('d [RWCEAFMS] dpearce 512 Jun 27 23:46 public.www')
|
|
17
|
-
# entry.dir? # => true
|
|
18
|
-
# entry.basename # => 'public.www'
|
|
19
|
-
class Netware < Parser
|
|
20
|
-
|
|
21
|
-
# Stolen straight from the ASF's commons Java FTP LIST parser library.
|
|
22
|
-
# http://svn.apache.org/repos/asf/commons/proper/net/trunk/src/java/org/apache/commons/net/ftp/
|
|
23
|
-
|
|
24
|
-
REGEXP = %r!^
|
|
25
|
-
(d|-){1}\s+
|
|
26
|
-
\[(.*?)\]\s+
|
|
27
|
-
(\S+)\s+(\d+)\s+
|
|
28
|
-
(\S+\s+\S+\s+((\d+:\d+)|(\d{4})))
|
|
29
|
-
\s+(.*)
|
|
30
|
-
$!x
|
|
31
|
-
|
|
32
|
-
# Parse a Netware like FTP LIST entries.
|
|
33
|
-
def initialize(raw)
|
|
34
|
-
super(raw)
|
|
35
|
-
match = REGEXP.match(raw.strip) or raise ParserError
|
|
36
|
-
|
|
37
|
-
@mtime = Time.parse(match[5])
|
|
38
|
-
|
|
39
|
-
if match[1] == 'd'
|
|
40
|
-
@dir = true
|
|
41
|
-
else
|
|
42
|
-
@file = true
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
# TODO: Permissions, users, groups, date/time.
|
|
46
|
-
|
|
47
|
-
@basename = match[9]
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
module Net
|
|
2
|
-
class FTP
|
|
3
|
-
module List
|
|
4
|
-
|
|
5
|
-
# ParserError
|
|
6
|
-
#
|
|
7
|
-
# Raw entry couldn't be parsed for some reason.
|
|
8
|
-
#
|
|
9
|
-
# == TODO
|
|
10
|
-
#
|
|
11
|
-
# Get more specific with error messages.
|
|
12
|
-
class ParserError < RuntimeError; end
|
|
13
|
-
|
|
14
|
-
# Abstract FTP LIST parser.
|
|
15
|
-
#
|
|
16
|
-
# It really just defines and documents the interface.
|
|
17
|
-
#
|
|
18
|
-
# == Exceptions
|
|
19
|
-
#
|
|
20
|
-
# +ParserError+ -- Raw entry could not be parsed.
|
|
21
|
-
class Parser
|
|
22
|
-
@@parsers = []
|
|
23
|
-
|
|
24
|
-
# Parse a raw FTP LIST line.
|
|
25
|
-
#
|
|
26
|
-
# By default just takes and set the raw list entry.
|
|
27
|
-
#
|
|
28
|
-
# Net::FTP::List.parse(raw_list_string) # => Net::FTP::List::Parser instance.
|
|
29
|
-
def initialize(raw)
|
|
30
|
-
@raw = raw
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
# The raw list entry string.
|
|
34
|
-
def raw
|
|
35
|
-
@raw ||= ''
|
|
36
|
-
end
|
|
37
|
-
alias_method :to_s, :raw
|
|
38
|
-
|
|
39
|
-
# The items basename (filename).
|
|
40
|
-
def basename
|
|
41
|
-
@basename ||= ''
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
# Looks like a directory, try CWD.
|
|
45
|
-
def dir?
|
|
46
|
-
!!@dir ||= false
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
# Looks like a file, try RETR.
|
|
50
|
-
def file?
|
|
51
|
-
!!@file ||= false
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
# Looks like a symbolic link.
|
|
55
|
-
def symlink?
|
|
56
|
-
!!@symlink ||= false
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def mtime
|
|
60
|
-
@mtime
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
class << self
|
|
64
|
-
# Acts as a factory.
|
|
65
|
-
#
|
|
66
|
-
# TODO: Having a class be both factory and abstract implementation seems a little nutty to me. If it ends up
|
|
67
|
-
# too confusing or gives anyone the shits I'll move it.
|
|
68
|
-
def inherited(klass) #:nodoc:
|
|
69
|
-
@@parsers << klass
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
# Factory method.
|
|
73
|
-
#
|
|
74
|
-
# Attempt to find a parser and parse a list item. At worst the item will return an Net::FTP::List::Unknown
|
|
75
|
-
# instance. This may change in the future so that only parsable entries are kept.
|
|
76
|
-
def parse(raw)
|
|
77
|
-
@@parsers.reverse.each do |parser|
|
|
78
|
-
begin
|
|
79
|
-
return parser.new(raw)
|
|
80
|
-
rescue ParserError
|
|
81
|
-
next
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
# Unknown parser.
|
|
90
|
-
#
|
|
91
|
-
# If all other attempts to parse the entry fail this class will be returned. Only the +raw+ and +to_s+
|
|
92
|
-
# methods will return anything useful.
|
|
93
|
-
class Unknown < Parser
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
end
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
require 'time'
|
|
2
|
-
require 'net/ftp/list/parser'
|
|
3
|
-
|
|
4
|
-
module Net
|
|
5
|
-
class FTP
|
|
6
|
-
module List
|
|
7
|
-
|
|
8
|
-
# Parse Unix like FTP LIST entries.
|
|
9
|
-
#
|
|
10
|
-
# == MATCHES
|
|
11
|
-
#
|
|
12
|
-
# drwxr-xr-x 4 steve group 4096 Dec 10 20:23 etc
|
|
13
|
-
# -rw-r--r-- 1 root other 531 Jan 29 03:26 README.txt
|
|
14
|
-
#
|
|
15
|
-
# == SYNOPSIS
|
|
16
|
-
#
|
|
17
|
-
# entry = Net::FTP::List::Unix.new('drwxr-xr-x 4 steve group 4096 Dec 10 20:23 etc')
|
|
18
|
-
# entry.dir? # => true
|
|
19
|
-
# entry.basename # => 'etc'
|
|
20
|
-
class Unix < Parser
|
|
21
|
-
|
|
22
|
-
# Stolen straight from the ASF's commons Java FTP LIST parser library.
|
|
23
|
-
# http://svn.apache.org/repos/asf/commons/proper/net/trunk/src/java/org/apache/commons/net/ftp/
|
|
24
|
-
REGEXP = %r{
|
|
25
|
-
([bcdlfmpSs-])
|
|
26
|
-
(((r|-)(w|-)([xsStTL-]))((r|-)(w|-)([xsStTL-]))((r|-)(w|-)([xsStTL-])))\+?\s+
|
|
27
|
-
(\d+)\s+
|
|
28
|
-
(\S+)\s+
|
|
29
|
-
(?:(\S+(?:\s\S+)*)\s+)?
|
|
30
|
-
(\d+)\s+
|
|
31
|
-
((?:\d+[-/]\d+[-/]\d+)|(?:\S+\s+\S+))\s+
|
|
32
|
-
(\d+(?::\d+)?)\s+
|
|
33
|
-
(\S*)(\s*.*)
|
|
34
|
-
}x
|
|
35
|
-
|
|
36
|
-
# Parse a Unix like FTP LIST entries.
|
|
37
|
-
def initialize(raw)
|
|
38
|
-
super(raw)
|
|
39
|
-
match = REGEXP.match(raw.strip) or raise ParserError
|
|
40
|
-
|
|
41
|
-
case match[1]
|
|
42
|
-
when /d/ then @dir = true
|
|
43
|
-
when /l/ then @symlink = true
|
|
44
|
-
when /[f-]/ then @file = true
|
|
45
|
-
when /[bc]/ then # Do nothing with devices for now.
|
|
46
|
-
else ParserError 'Unknown LIST entry type.'
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
# TODO: Permissions, users, groups, date/time.
|
|
50
|
-
@mtime = Time.parse("#{match[19]} #{match[20]}")
|
|
51
|
-
|
|
52
|
-
@basename = match[21].strip
|
|
53
|
-
|
|
54
|
-
# filenames with spaces will end up in the last match
|
|
55
|
-
@basename += match[22] unless match[22].nil?
|
|
56
|
-
|
|
57
|
-
# strip the symlink stuff we don't care about
|
|
58
|
-
@basename.sub!(/\s+\->.+$/, '') if @symlink
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
end
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
|
2
|
-
|
|
3
|
-
Gem::Specification.new do |s|
|
|
4
|
-
s.name = %q{net-ftp-list}
|
|
5
|
-
s.version = "2.0.0"
|
|
6
|
-
|
|
7
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
8
|
-
s.authors = ["Stateless Systems"]
|
|
9
|
-
s.date = %q{2009-05-05}
|
|
10
|
-
s.email = %q{enquiries@statelesssystems.com}
|
|
11
|
-
s.extra_rdoc_files = [
|
|
12
|
-
"README.txt"
|
|
13
|
-
]
|
|
14
|
-
s.files = [
|
|
15
|
-
"README.txt",
|
|
16
|
-
"Rakefile",
|
|
17
|
-
"VERSION.yml",
|
|
18
|
-
"lib/net/ftp/list.rb",
|
|
19
|
-
"lib/net/ftp/list/microsoft.rb",
|
|
20
|
-
"lib/net/ftp/list/netware.rb",
|
|
21
|
-
"lib/net/ftp/list/parser.rb",
|
|
22
|
-
"lib/net/ftp/list/unix.rb",
|
|
23
|
-
"test/test_net_ftp_list_microsoft.rb",
|
|
24
|
-
"test/test_net_ftp_list_netware.rb",
|
|
25
|
-
"test/test_net_ftp_list_unix.rb"
|
|
26
|
-
]
|
|
27
|
-
s.has_rdoc = true
|
|
28
|
-
s.homepage = %q{http://github.com/stateless-systems/net-ftp-list}
|
|
29
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
|
30
|
-
s.require_paths = ["lib"]
|
|
31
|
-
s.rubygems_version = %q{1.3.1}
|
|
32
|
-
s.summary = %q{Parse FTP LIST command output.}
|
|
33
|
-
s.test_files = [
|
|
34
|
-
"test/test_net_ftp_list_unix.rb",
|
|
35
|
-
"test/test_net_ftp_list_netware.rb",
|
|
36
|
-
"test/test_net_ftp_list_microsoft.rb"
|
|
37
|
-
]
|
|
38
|
-
|
|
39
|
-
if s.respond_to? :specification_version then
|
|
40
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
|
41
|
-
s.specification_version = 2
|
|
42
|
-
|
|
43
|
-
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
|
44
|
-
else
|
|
45
|
-
end
|
|
46
|
-
else
|
|
47
|
-
end
|
|
48
|
-
end
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
require 'test/unit'
|
|
2
|
-
require 'net/ftp/list'
|
|
3
|
-
|
|
4
|
-
class TestNetFTPListMicrosoft < Test::Unit::TestCase
|
|
5
|
-
|
|
6
|
-
def setup
|
|
7
|
-
# DATE TIME DIR SIZE NAME
|
|
8
|
-
@dir = Net::FTP::List.parse('06-25-07 01:08PM <DIR> etc')
|
|
9
|
-
@file = Net::FTP::List.parse('11-27-07 08:45PM 23437 README.TXT')
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def test_parse_new
|
|
13
|
-
assert_instance_of Net::FTP::List::Microsoft, @dir, 'LIST M$ directory'
|
|
14
|
-
assert_instance_of Net::FTP::List::Microsoft, @file, 'LIST M$ file'
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def test_rubbish_lines
|
|
18
|
-
assert_instance_of Net::FTP::List::Unknown, Net::FTP::List.parse("++ bah! ++")
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def test_ruby_micrsoft_mtime
|
|
22
|
-
assert_equal DateTime.strptime('06-25-07 01:08PM', "%m-%d-%y %I:%M%p"), @dir.mtime
|
|
23
|
-
assert_equal DateTime.strptime('11-27-07 08:45PM', "%m-%d-%y %I:%M%p"), @file.mtime
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def test_ruby_microsoft_like_dir
|
|
27
|
-
assert_equal 'etc', @dir.basename
|
|
28
|
-
assert @dir.dir?
|
|
29
|
-
assert !@dir.file?
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def test_ruby_microsoft_like_file
|
|
33
|
-
assert_equal 'README.TXT', @file.basename
|
|
34
|
-
assert @file.file?
|
|
35
|
-
assert !@file.dir?
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
end
|
|
@@ -1,37 +0,0 @@
|
|
|
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_mtime
|
|
21
|
-
assert_equal @dir.mtime, Time.parse('Jun 27 23:46')
|
|
22
|
-
assert_equal @file.mtime, Time.parse('Jun 22 06:22')
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def test_ruby_netware_like_dir
|
|
26
|
-
assert_equal 'public.www', @dir.basename
|
|
27
|
-
assert @dir.dir?
|
|
28
|
-
assert !@dir.file?
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def test_ruby_netware_like_file
|
|
32
|
-
assert_equal 'about.html', @file.basename
|
|
33
|
-
assert @file.file?
|
|
34
|
-
assert !@file.dir?
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
end
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
require 'test/unit'
|
|
2
|
-
require 'net/ftp/list'
|
|
3
|
-
|
|
4
|
-
class TestNetFTPListUnix < Test::Unit::TestCase
|
|
5
|
-
|
|
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'
|
|
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'
|
|
12
|
-
@older_date = Net::FTP::List.parse '-rwxrwxrwx 1 owner group 154112 Feb 15 2008 participando.xls'
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def test_parse_new
|
|
16
|
-
assert_instance_of Net::FTP::List::Unix, @dir, 'LIST unixish directory'
|
|
17
|
-
assert_instance_of Net::FTP::List::Unix, @file, 'LIST unixish file'
|
|
18
|
-
assert_instance_of Net::FTP::List::Unix, @other_dir, 'LIST unixish directory'
|
|
19
|
-
assert_instance_of Net::FTP::List::Unix, @spaces, 'LIST unixish directory with spaces'
|
|
20
|
-
assert_instance_of Net::FTP::List::Unix, @symlink, 'LIST unixish symlink'
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def test_rubbish_lines
|
|
24
|
-
assert_instance_of Net::FTP::List::Unknown, Net::FTP::List.parse("++ bah! ++")
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def test_ruby_unix_like_date
|
|
28
|
-
assert_equal Time.parse("Mar 11 07:57"), @other_dir.mtime
|
|
29
|
-
assert_equal Time.parse("Apr 30 15:26"), @symlink.mtime
|
|
30
|
-
assert_equal Time.parse("Feb 15 2008"), @older_date.mtime
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def test_ruby_unix_like_dir
|
|
34
|
-
assert_equal 'etc', @dir.basename
|
|
35
|
-
assert @dir.dir?
|
|
36
|
-
assert !@dir.file?
|
|
37
|
-
|
|
38
|
-
assert_equal 'forums', @other_dir.basename
|
|
39
|
-
assert @other_dir.dir?
|
|
40
|
-
assert !@other_dir.file?
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def test_ruby_unix_like_symlink
|
|
44
|
-
assert_equal 'bar', @symlink.basename
|
|
45
|
-
assert @symlink.symlink?
|
|
46
|
-
assert !@symlink.dir?
|
|
47
|
-
assert !@symlink.file?
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def test_spaces_in_unix_dir
|
|
51
|
-
assert_equal 'spaces suck', @spaces.basename
|
|
52
|
-
assert @spaces.dir?
|
|
53
|
-
assert !@spaces.file?
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
def test_ruby_unix_like_file
|
|
57
|
-
assert_equal 'README', @file.basename
|
|
58
|
-
assert @file.file?
|
|
59
|
-
assert !@file.dir?
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
end
|
|
Binary file
|