rant 0.3.8 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/NEWS +19 -0
- data/README +51 -24
- data/Rantfile +7 -8
- data/doc/advanced.rdoc +3 -1
- data/doc/package.rdoc +280 -0
- data/doc/rantfile.rdoc +9 -19
- data/doc/rubyproject.rdoc +24 -16
- data/lib/rant/archive/minitar.rb +983 -0
- data/lib/rant/archive/rubyzip/ioextras.rb +122 -0
- data/lib/rant/archive/rubyzip/stdrubyext.rb +114 -0
- data/lib/rant/archive/rubyzip/tempfile_bugfixed.rb +195 -0
- data/lib/rant/archive/rubyzip.rb +1575 -0
- data/lib/rant/import/archive/tgz.rb +49 -0
- data/lib/rant/import/archive/zip.rb +67 -0
- data/lib/rant/import/archive.rb +312 -0
- data/lib/rant/import/autoclean.rb +2 -2
- data/lib/rant/import/c/dependencies.rb +3 -3
- data/lib/rant/import/clean.rb +1 -1
- data/lib/rant/import/directedrule.rb +1 -1
- data/lib/rant/import/package/tgz.rb +35 -0
- data/lib/rant/import/package/zip.rb +36 -0
- data/lib/rant/import/rubydoc.rb +1 -1
- data/lib/rant/import/rubypackage.rb +19 -77
- data/lib/rant/import/rubytest.rb +1 -1
- data/lib/rant/import/subfile.rb +28 -14
- data/lib/rant/import/win32/rubycmdwrapper.rb +1 -1
- data/lib/rant/import.rb +36 -16
- data/lib/rant/plugin/csharp.rb +1 -1
- data/lib/rant/rantenv.rb +2 -13
- data/lib/rant/rantfile.rb +11 -11
- data/lib/rant/rantlib.rb +7 -3
- data/lib/rant/rantsys.rb +53 -2
- data/lib/rant/rantvar.rb +62 -1
- data/misc/TODO +41 -0
- data/{devel-notes → misc/devel-notes} +6 -0
- data/misc/mt.rb +3 -0
- data/misc/t.rb +18 -0
- data/test/import/c/dependencies/test_c_dependencies.rb +18 -0
- data/test/import/package/MANIFEST +4 -0
- data/test/import/package/Rantfile +49 -0
- data/test/import/package/deep/sub/sub/f1 +1 -0
- data/test/import/package/sub/f1 +1 -0
- data/test/import/package/sub2/f1 +1 -0
- data/test/import/package/test_package.rb +425 -0
- data/test/import/subfile/Rantfile +8 -0
- data/test/import/subfile/test_subfile.rb +12 -0
- data/test/project_rb1/rantfile.rb +3 -4
- data/test/project_rb1/test_project_rb1.rb +16 -40
- data/test/rant-import/test_rant-import.rb +3 -3
- data/test/test_filelist.rb +39 -2
- data/test/tutil.rb +89 -3
- metadata +35 -6
- data/TODO +0 -21
- data/lib/rant/import/package.rb +0 -258
- /data/{rantmethods.rb → misc/rantmethods.rb} +0 -0
@@ -0,0 +1,122 @@
|
|
1
|
+
|
2
|
+
# Taken from the rubyzip package and slightly modified for Rant.
|
3
|
+
|
4
|
+
module Rant; end
|
5
|
+
|
6
|
+
module Rant::IOExtras #:nodoc:
|
7
|
+
|
8
|
+
# Implements kind_of? in order to pretend to be an IO object
|
9
|
+
module FakeIO
|
10
|
+
def kind_of?(object)
|
11
|
+
object == IO || super
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# Implements many of the convenience methods of IO
|
16
|
+
# such as gets, getc, readline and readlines
|
17
|
+
# depends on: input_finished?, produce_input and read
|
18
|
+
module AbstractInputStream
|
19
|
+
include Enumerable
|
20
|
+
include FakeIO
|
21
|
+
|
22
|
+
def initialize
|
23
|
+
super
|
24
|
+
@lineno = 0
|
25
|
+
@outputBuffer = ""
|
26
|
+
end
|
27
|
+
|
28
|
+
attr_accessor :lineno
|
29
|
+
|
30
|
+
def readlines(aSepString = $/)
|
31
|
+
retVal = []
|
32
|
+
each_line(aSepString) { |line| retVal << line }
|
33
|
+
return retVal
|
34
|
+
end
|
35
|
+
|
36
|
+
def gets(aSepString=$/)
|
37
|
+
@lineno = @lineno.next
|
38
|
+
return read if aSepString == nil
|
39
|
+
aSepString="#{$/}#{$/}" if aSepString == ""
|
40
|
+
|
41
|
+
bufferIndex=0
|
42
|
+
while ((matchIndex = @outputBuffer.index(aSepString, bufferIndex)) == nil)
|
43
|
+
bufferIndex=@outputBuffer.length
|
44
|
+
if input_finished?
|
45
|
+
return @outputBuffer.empty? ? nil : flush
|
46
|
+
end
|
47
|
+
@outputBuffer << produce_input
|
48
|
+
end
|
49
|
+
sepIndex=matchIndex + aSepString.length
|
50
|
+
return @outputBuffer.slice!(0...sepIndex)
|
51
|
+
end
|
52
|
+
|
53
|
+
def flush
|
54
|
+
retVal=@outputBuffer
|
55
|
+
@outputBuffer=""
|
56
|
+
return retVal
|
57
|
+
end
|
58
|
+
|
59
|
+
def readline(aSepString = $/)
|
60
|
+
retVal = gets(aSepString)
|
61
|
+
raise EOFError if retVal == nil
|
62
|
+
return retVal
|
63
|
+
end
|
64
|
+
|
65
|
+
def each_line(aSepString = $/)
|
66
|
+
while true
|
67
|
+
yield readline(aSepString)
|
68
|
+
end
|
69
|
+
rescue EOFError
|
70
|
+
end
|
71
|
+
|
72
|
+
alias_method :each, :each_line
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
# Implements many of the output convenience methods of IO.
|
77
|
+
# relies on <<
|
78
|
+
module AbstractOutputStream
|
79
|
+
include FakeIO
|
80
|
+
|
81
|
+
def write(data)
|
82
|
+
self << data
|
83
|
+
data.to_s.length
|
84
|
+
end
|
85
|
+
|
86
|
+
|
87
|
+
def print(*params)
|
88
|
+
self << params.to_s << $\.to_s
|
89
|
+
end
|
90
|
+
|
91
|
+
def printf(aFormatString, *params)
|
92
|
+
self << sprintf(aFormatString, *params)
|
93
|
+
end
|
94
|
+
|
95
|
+
def putc(anObject)
|
96
|
+
self << case anObject
|
97
|
+
when Fixnum then anObject.chr
|
98
|
+
when String then anObject
|
99
|
+
else raise TypeError, "putc: Only Fixnum and String supported"
|
100
|
+
end
|
101
|
+
anObject
|
102
|
+
end
|
103
|
+
|
104
|
+
def puts(*params)
|
105
|
+
params << "\n" if params.empty?
|
106
|
+
params.flatten.each {
|
107
|
+
|element|
|
108
|
+
val = element.to_s
|
109
|
+
self << val
|
110
|
+
self << "\n" unless val[-1,1] == "\n"
|
111
|
+
}
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
115
|
+
|
116
|
+
end # Rant::IOExtras namespace module
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
# Copyright (C) 2002-2004 Thomas Sondergaard
|
121
|
+
# rubyzip is free software; you can redistribute it and/or
|
122
|
+
# modify it under the terms of the ruby license.
|
@@ -0,0 +1,114 @@
|
|
1
|
+
|
2
|
+
# Taken from the rubyzip package and integrated into Rant.
|
3
|
+
|
4
|
+
unless Enumerable.method_defined?(:inject)
|
5
|
+
module Enumerable #:nodoc:all
|
6
|
+
def inject(n = 0)
|
7
|
+
each { |value| n = yield(n, value) }
|
8
|
+
n
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
module Enumerable #:nodoc:all
|
14
|
+
# returns a new array of all the return values not equal to nil
|
15
|
+
# This implementation could be faster
|
16
|
+
def select_map(&aProc)
|
17
|
+
map(&aProc).reject { |e| e.nil? }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
unless Object.method_defined?(:object_id)
|
22
|
+
class Object #:nodoc:all
|
23
|
+
# Using object_id which is the new thing, so we need
|
24
|
+
# to make that work in versions prior to 1.8.0
|
25
|
+
alias object_id id
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
unless File.respond_to?(:read)
|
30
|
+
class File # :nodoc:all
|
31
|
+
# singleton method read does not exist in 1.6.x
|
32
|
+
def self.read(fileName)
|
33
|
+
open(fileName) { |f| f.read }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class String #:nodoc:all
|
39
|
+
def starts_with(aString)
|
40
|
+
rindex(aString, 0) == 0
|
41
|
+
end
|
42
|
+
|
43
|
+
def ends_with(aString)
|
44
|
+
index(aString, -aString.size)
|
45
|
+
end
|
46
|
+
|
47
|
+
def ensure_end(aString)
|
48
|
+
ends_with(aString) ? self : self + aString
|
49
|
+
end
|
50
|
+
|
51
|
+
def lchop
|
52
|
+
slice(1, length)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
class Time #:nodoc:all
|
57
|
+
|
58
|
+
#MS-DOS File Date and Time format as used in Interrupt 21H Function 57H:
|
59
|
+
#
|
60
|
+
# Register CX, the Time:
|
61
|
+
# Bits 0-4 2 second increments (0-29)
|
62
|
+
# Bits 5-10 minutes (0-59)
|
63
|
+
# bits 11-15 hours (0-24)
|
64
|
+
#
|
65
|
+
# Register DX, the Date:
|
66
|
+
# Bits 0-4 day (1-31)
|
67
|
+
# bits 5-8 month (1-12)
|
68
|
+
# bits 9-15 year (four digit year minus 1980)
|
69
|
+
|
70
|
+
|
71
|
+
def to_binary_dos_time
|
72
|
+
(sec/2) +
|
73
|
+
(min << 5) +
|
74
|
+
(hour << 11)
|
75
|
+
end
|
76
|
+
|
77
|
+
def to_binary_dos_date
|
78
|
+
(day) +
|
79
|
+
(month << 5) +
|
80
|
+
((year - 1980) << 9)
|
81
|
+
end
|
82
|
+
|
83
|
+
# Dos time is only stored with two seconds accuracy
|
84
|
+
def dos_equals(other)
|
85
|
+
to_i/2 == other.to_i/2
|
86
|
+
end
|
87
|
+
|
88
|
+
def self.parse_binary_dos_format(binaryDosDate, binaryDosTime)
|
89
|
+
second = 2 * ( 0b11111 & binaryDosTime)
|
90
|
+
minute = ( 0b11111100000 & binaryDosTime) >> 5
|
91
|
+
hour = (0b1111100000000000 & binaryDosTime) >> 11
|
92
|
+
day = ( 0b11111 & binaryDosDate)
|
93
|
+
month = ( 0b111100000 & binaryDosDate) >> 5
|
94
|
+
year = ((0b1111111000000000 & binaryDosDate) >> 9) + 1980
|
95
|
+
begin
|
96
|
+
return Time.local(year, month, day, hour, minute, second)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
class Module #:nodoc:all
|
102
|
+
def forward_message(forwarder, *messagesToForward)
|
103
|
+
methodDefs = messagesToForward.map {
|
104
|
+
|msg|
|
105
|
+
"def #{msg}; #{forwarder}(:#{msg}); end"
|
106
|
+
}
|
107
|
+
module_eval(methodDefs.join("\n"))
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
|
112
|
+
# Copyright (C) 2002, 2003 Thomas Sondergaard
|
113
|
+
# rubyzip is free software; you can redistribute it and/or
|
114
|
+
# modify it under the terms of the ruby license.
|
@@ -0,0 +1,195 @@
|
|
1
|
+
#
|
2
|
+
# tempfile - manipulates temporary files
|
3
|
+
#
|
4
|
+
# $Id: tempfile_bugfixed.rb,v 1.2 2005/02/19 20:30:33 thomas Exp $
|
5
|
+
#
|
6
|
+
|
7
|
+
require 'delegate'
|
8
|
+
require 'tmpdir'
|
9
|
+
|
10
|
+
module BugFix #:nodoc:all
|
11
|
+
|
12
|
+
# A class for managing temporary files. This library is written to be
|
13
|
+
# thread safe.
|
14
|
+
class Tempfile < DelegateClass(File)
|
15
|
+
MAX_TRY = 10
|
16
|
+
@@cleanlist = []
|
17
|
+
|
18
|
+
# Creates a temporary file of mode 0600 in the temporary directory
|
19
|
+
# whose name is basename.pid.n and opens with mode "w+". A Tempfile
|
20
|
+
# object works just like a File object.
|
21
|
+
#
|
22
|
+
# If tmpdir is omitted, the temporary directory is determined by
|
23
|
+
# Dir::tmpdir provided by 'tmpdir.rb'.
|
24
|
+
# When $SAFE > 0 and the given tmpdir is tainted, it uses
|
25
|
+
# /tmp. (Note that ENV values are tainted by default)
|
26
|
+
def initialize(basename, tmpdir=Dir::tmpdir)
|
27
|
+
if $SAFE > 0 and tmpdir.tainted?
|
28
|
+
tmpdir = '/tmp'
|
29
|
+
end
|
30
|
+
|
31
|
+
lock = nil
|
32
|
+
n = failure = 0
|
33
|
+
|
34
|
+
begin
|
35
|
+
Thread.critical = true
|
36
|
+
|
37
|
+
begin
|
38
|
+
tmpname = sprintf('%s/%s%d.%d', tmpdir, basename, $$, n)
|
39
|
+
lock = tmpname + '.lock'
|
40
|
+
n += 1
|
41
|
+
end while @@cleanlist.include?(tmpname) or
|
42
|
+
File.exist?(lock) or File.exist?(tmpname)
|
43
|
+
|
44
|
+
Dir.mkdir(lock)
|
45
|
+
rescue
|
46
|
+
failure += 1
|
47
|
+
retry if failure < MAX_TRY
|
48
|
+
raise "cannot generate tempfile `%s'" % tmpname
|
49
|
+
ensure
|
50
|
+
Thread.critical = false
|
51
|
+
end
|
52
|
+
|
53
|
+
@data = [tmpname]
|
54
|
+
@clean_proc = Tempfile.callback(@data)
|
55
|
+
ObjectSpace.define_finalizer(self, @clean_proc)
|
56
|
+
|
57
|
+
@tmpfile = File.open(tmpname, File::RDWR|File::CREAT|File::EXCL, 0600)
|
58
|
+
@tmpname = tmpname
|
59
|
+
@@cleanlist << @tmpname
|
60
|
+
@data[1] = @tmpfile
|
61
|
+
@data[2] = @@cleanlist
|
62
|
+
|
63
|
+
super(@tmpfile)
|
64
|
+
|
65
|
+
# Now we have all the File/IO methods defined, you must not
|
66
|
+
# carelessly put bare puts(), etc. after this.
|
67
|
+
|
68
|
+
Dir.rmdir(lock)
|
69
|
+
end
|
70
|
+
|
71
|
+
# Opens or reopens the file with mode "r+".
|
72
|
+
def open
|
73
|
+
@tmpfile.close if @tmpfile
|
74
|
+
@tmpfile = File.open(@tmpname, 'r+')
|
75
|
+
@data[1] = @tmpfile
|
76
|
+
__setobj__(@tmpfile)
|
77
|
+
end
|
78
|
+
|
79
|
+
def _close # :nodoc:
|
80
|
+
@tmpfile.close if @tmpfile
|
81
|
+
@data[1] = @tmpfile = nil
|
82
|
+
end
|
83
|
+
protected :_close
|
84
|
+
|
85
|
+
# Closes the file. If the optional flag is true, unlinks the file
|
86
|
+
# after closing.
|
87
|
+
#
|
88
|
+
# If you don't explicitly unlink the temporary file, the removal
|
89
|
+
# will be delayed until the object is finalized.
|
90
|
+
def close(unlink_now=false)
|
91
|
+
if unlink_now
|
92
|
+
close!
|
93
|
+
else
|
94
|
+
_close
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
# Closes and unlinks the file.
|
99
|
+
def close!
|
100
|
+
_close
|
101
|
+
@clean_proc.call
|
102
|
+
ObjectSpace.undefine_finalizer(self)
|
103
|
+
end
|
104
|
+
|
105
|
+
# Unlinks the file. On UNIX-like systems, it is often a good idea
|
106
|
+
# to unlink a temporary file immediately after creating and opening
|
107
|
+
# it, because it leaves other programs zero chance to access the
|
108
|
+
# file.
|
109
|
+
def unlink
|
110
|
+
# keep this order for thread safeness
|
111
|
+
File.unlink(@tmpname) if File.exist?(@tmpname)
|
112
|
+
@@cleanlist.delete(@tmpname) if @@cleanlist
|
113
|
+
end
|
114
|
+
alias delete unlink
|
115
|
+
|
116
|
+
if RUBY_VERSION > '1.8.0'
|
117
|
+
def __setobj__(obj)
|
118
|
+
@_dc_obj = obj
|
119
|
+
end
|
120
|
+
else
|
121
|
+
def __setobj__(obj)
|
122
|
+
@obj = obj
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
# Returns the full path name of the temporary file.
|
127
|
+
def path
|
128
|
+
@tmpname
|
129
|
+
end
|
130
|
+
|
131
|
+
# Returns the size of the temporary file. As a side effect, the IO
|
132
|
+
# buffer is flushed before determining the size.
|
133
|
+
def size
|
134
|
+
if @tmpfile
|
135
|
+
@tmpfile.flush
|
136
|
+
@tmpfile.stat.size
|
137
|
+
else
|
138
|
+
0
|
139
|
+
end
|
140
|
+
end
|
141
|
+
alias length size
|
142
|
+
|
143
|
+
class << self
|
144
|
+
def callback(data) # :nodoc:
|
145
|
+
pid = $$
|
146
|
+
lambda{
|
147
|
+
if pid == $$
|
148
|
+
path, tmpfile, cleanlist = *data
|
149
|
+
|
150
|
+
print "removing ", path, "..." if $DEBUG
|
151
|
+
|
152
|
+
tmpfile.close if tmpfile
|
153
|
+
|
154
|
+
# keep this order for thread safeness
|
155
|
+
File.unlink(path) if File.exist?(path)
|
156
|
+
cleanlist.delete(path) if cleanlist
|
157
|
+
|
158
|
+
print "done\n" if $DEBUG
|
159
|
+
end
|
160
|
+
}
|
161
|
+
end
|
162
|
+
|
163
|
+
# If no block is given, this is a synonym for new().
|
164
|
+
#
|
165
|
+
# If a block is given, it will be passed tempfile as an argument,
|
166
|
+
# and the tempfile will automatically be closed when the block
|
167
|
+
# terminates. In this case, open() returns nil.
|
168
|
+
def open(*args)
|
169
|
+
tempfile = new(*args)
|
170
|
+
|
171
|
+
if block_given?
|
172
|
+
begin
|
173
|
+
yield(tempfile)
|
174
|
+
ensure
|
175
|
+
tempfile.close
|
176
|
+
end
|
177
|
+
|
178
|
+
nil
|
179
|
+
else
|
180
|
+
tempfile
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
end # module BugFix
|
187
|
+
if __FILE__ == $0
|
188
|
+
# $DEBUG = true
|
189
|
+
f = Tempfile.new("foo")
|
190
|
+
f.print("foo\n")
|
191
|
+
f.close
|
192
|
+
f.open
|
193
|
+
p f.gets # => "foo\n"
|
194
|
+
f.close!
|
195
|
+
end
|