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
data/lib/rant/import/package.rb
DELETED
@@ -1,258 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'rant/rantlib'
|
3
|
-
|
4
|
-
class Rant::Generators::Package
|
5
|
-
|
6
|
-
class << self
|
7
|
-
def rant_generate(app, ch, args, &block)
|
8
|
-
if !args || args.empty?
|
9
|
-
self.new(:app => app, :__caller__ => ch, &block)
|
10
|
-
elsif args.size == 1
|
11
|
-
pkg_name = case args.first
|
12
|
-
when String: args.first
|
13
|
-
when Symbol: args.first.to_s
|
14
|
-
else
|
15
|
-
app.abort("Package takes only one additional " +
|
16
|
-
"argument, which should be a string or symbol.")
|
17
|
-
end
|
18
|
-
self.new(:app => app, :__caller__ => ch,
|
19
|
-
:name => pkg_name, &block)
|
20
|
-
else
|
21
|
-
app.abort(app.pos_text(file, ln),
|
22
|
-
"Package takes only one additional argument, " +
|
23
|
-
"which should be a string or symbol.")
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
# A hash containing all package information.
|
29
|
-
attr_reader :data
|
30
|
-
# Directory where packages go to. Defaults to "pkg".
|
31
|
-
attr_accessor :pkg_dir
|
32
|
-
|
33
|
-
def initialize(opts = {})
|
34
|
-
@rac = opts[:app] || Rant.rantapp
|
35
|
-
@pkg_dir = "pkg"
|
36
|
-
@pkg_dir_task = nil
|
37
|
-
@dist_dir_task = nil
|
38
|
-
@tar_task = nil
|
39
|
-
@zip_task = nil
|
40
|
-
@package_task = nil
|
41
|
-
name = opts[:name]
|
42
|
-
@ch = opts[:__caller__] || Rant::Lib.parse_caller_elem(caller[0])
|
43
|
-
unless name
|
44
|
-
# TODO: pos_text
|
45
|
-
@rac.warn_msg(@rac.pos_text(@ch[:file], @ch[:ln]),
|
46
|
-
"No package name given, using directory name.")
|
47
|
-
# use directory name as project name
|
48
|
-
name = File.split(Dir.pwd)[1]
|
49
|
-
# reset name if it contains a slash or a backslash
|
50
|
-
name = nil if name =~ /\/|\\/
|
51
|
-
end
|
52
|
-
@data = { "name" => name }
|
53
|
-
|
54
|
-
yield self if block_given?
|
55
|
-
end
|
56
|
-
|
57
|
-
def name
|
58
|
-
@data["name"]
|
59
|
-
end
|
60
|
-
|
61
|
-
def version
|
62
|
-
@data["version"]
|
63
|
-
end
|
64
|
-
|
65
|
-
def version=(str)
|
66
|
-
unless String === str
|
67
|
-
@rac.abort_at(@ch, "version has to be a String")
|
68
|
-
end
|
69
|
-
@data["version"] = str
|
70
|
-
end
|
71
|
-
|
72
|
-
def files
|
73
|
-
@data["files"]
|
74
|
-
end
|
75
|
-
|
76
|
-
def files=(list)
|
77
|
-
unless Array === list || ::Rant::FileList === List
|
78
|
-
if list.respond_to? :to_ary
|
79
|
-
list = list.to_ary
|
80
|
-
else
|
81
|
-
@rac.abort_at(@ch,
|
82
|
-
"files must be an Array or FileList")
|
83
|
-
end
|
84
|
-
end
|
85
|
-
@data["files"] = list
|
86
|
-
end
|
87
|
-
|
88
|
-
def validate_attrs(pkg_type = :general)
|
89
|
-
%w(name files).each { |a|
|
90
|
-
pkg_requires_attr a
|
91
|
-
}
|
92
|
-
end
|
93
|
-
private :validate_attrs
|
94
|
-
|
95
|
-
def pkg_requires_attr(attr_name)
|
96
|
-
unless @data[attr_name]
|
97
|
-
@rac.abort("Packaged defined: " +
|
98
|
-
@rac.pos_text(@ch[:file], @ch[:ln]),
|
99
|
-
"`#{attr_name}' attribute required")
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
def pkg_dir_task
|
104
|
-
return if @pkg_dir_task
|
105
|
-
if @dist_dir_task
|
106
|
-
# not ideal but should work: If only the gem task will
|
107
|
-
# be run, dist dir creation wouldn't be necessary
|
108
|
-
return @pkg_dir_task = @dist_dir_task
|
109
|
-
end
|
110
|
-
@pkg_dir_task = @rac.gen(
|
111
|
-
::Rant::Generators::Directory, @pkg_dir)
|
112
|
-
end
|
113
|
-
|
114
|
-
def dist_dir_task
|
115
|
-
return if @dist_dir_task
|
116
|
-
pkg_name = pkg_dist_dir
|
117
|
-
dist_dir = pkg_dist_dir
|
118
|
-
@dist_dir_task = @rac.gen(Rant::Generators::Directory,
|
119
|
-
dist_dir => files) { |t|
|
120
|
-
# ensure to create new and empty destination directory
|
121
|
-
if Dir.entries(dist_dir).size > 2 # "." and ".."
|
122
|
-
@rac.sys.rm_rf(dist_dir)
|
123
|
-
@rac.sys.mkdir(dist_dir)
|
124
|
-
end
|
125
|
-
# evaluate directory structure first
|
126
|
-
dirs = []
|
127
|
-
fl = []
|
128
|
-
files.each { |e|
|
129
|
-
if test(?d, e)
|
130
|
-
dirs << e unless dirs.include? e
|
131
|
-
else # assuming e is a file
|
132
|
-
fl << e
|
133
|
-
dir = File.dirname(e)
|
134
|
-
dirs << dir unless dir == "." || dirs.include?(dir)
|
135
|
-
end
|
136
|
-
}
|
137
|
-
# create directory structure
|
138
|
-
dirs.each { |dir|
|
139
|
-
dest = File.join(dist_dir, dir)
|
140
|
-
@rac.sys.mkpath(dest) unless test(?d, dest)
|
141
|
-
}
|
142
|
-
# link or copy files
|
143
|
-
fl.each { |f|
|
144
|
-
dest = File.join(dist_dir, f)
|
145
|
-
@rac.sys.safe_ln(f, dest)
|
146
|
-
}
|
147
|
-
}
|
148
|
-
end
|
149
|
-
|
150
|
-
def tar_task(tname = :tar)
|
151
|
-
validate_attrs
|
152
|
-
# Create tar task first to ensure that a pending description
|
153
|
-
# is used for the tar task and not for the dist dir task.
|
154
|
-
pkg_name = tar_pkg_path
|
155
|
-
pkg_files = files
|
156
|
-
if tname
|
157
|
-
# shortcut task
|
158
|
-
@rac.task({:__caller__ => @ch, tname => pkg_name})
|
159
|
-
end
|
160
|
-
# actual tar-creating task
|
161
|
-
@tar_task = @rac.file(:__caller__ => @ch,
|
162
|
-
pkg_name => [pkg_dist_dir] + pkg_files) { |t|
|
163
|
-
@rac.sys.cd(@pkg_dir) {
|
164
|
-
@rac.sys %W(tar zcf #{tar_pkg_name} #{pkg_base_name})
|
165
|
-
}
|
166
|
-
}
|
167
|
-
dist_dir_task
|
168
|
-
end
|
169
|
-
|
170
|
-
def zip_task(tname = :zip)
|
171
|
-
validate_attrs
|
172
|
-
# Create zip task first to ensure that a pending description
|
173
|
-
# is used for the zip task and not for the dist dir task.
|
174
|
-
pkg_name = zip_pkg_path
|
175
|
-
pkg_files = files
|
176
|
-
if tname
|
177
|
-
# shortcut task
|
178
|
-
@rac.task({:__caller__ => @ch, tname => pkg_name})
|
179
|
-
end
|
180
|
-
# actual zip-creating task
|
181
|
-
@zip_task = @rac.file(:__caller__ => @ch,
|
182
|
-
pkg_name => [pkg_dist_dir] + pkg_files) { |t|
|
183
|
-
@rac.sys.cd(@pkg_dir) {
|
184
|
-
# zip options:
|
185
|
-
# y: store symlinks instead of referenced files
|
186
|
-
# r: recurse into directories
|
187
|
-
# q: quiet operation
|
188
|
-
@rac.sys %W(zip -yqr #{zip_pkg_name} #{pkg_base_name})
|
189
|
-
}
|
190
|
-
}
|
191
|
-
dist_dir_task
|
192
|
-
end
|
193
|
-
|
194
|
-
# Create a task which runs gem/zip/tar tasks.
|
195
|
-
def package_task(tname = :package)
|
196
|
-
def_tasks = [@tar_task, @zip_task].compact
|
197
|
-
if def_tasks.empty?
|
198
|
-
# take description for overall package task
|
199
|
-
pdesc = @rac.pop_desc
|
200
|
-
unless def_available_tasks
|
201
|
-
@rac.desc pdesc
|
202
|
-
@rac.warn_msg("No tools for packaging available (tar, zip):",
|
203
|
-
"Can't generate task `#{tname}'.")
|
204
|
-
return
|
205
|
-
end
|
206
|
-
@rac.desc pdesc
|
207
|
-
end
|
208
|
-
pre = []
|
209
|
-
pre << tar_pkg_path if @tar_task
|
210
|
-
pre << zip_pkg_path if @zip_task
|
211
|
-
pre << gem_pkg_path if @gem_task
|
212
|
-
@rac.task(:__caller__ => @ch, tname => pre)
|
213
|
-
end
|
214
|
-
|
215
|
-
# Returns true if at least one task was defined.
|
216
|
-
def def_available_tasks
|
217
|
-
defined = false
|
218
|
-
if Rant::Env.have_tar?
|
219
|
-
# we don't create shortcut tasks, hence nil as argument
|
220
|
-
self.tar_task(nil)
|
221
|
-
defined = true
|
222
|
-
end
|
223
|
-
if Rant::Env.have_zip?
|
224
|
-
self.zip_task(nil)
|
225
|
-
defined = true
|
226
|
-
end
|
227
|
-
defined
|
228
|
-
end
|
229
|
-
|
230
|
-
def pkg_base_name
|
231
|
-
unless name
|
232
|
-
@rac.abort(@rac.pos_text(@ch[:file], @ch[:ln]),
|
233
|
-
"`name' required for packaging")
|
234
|
-
end
|
235
|
-
version ? "#{name}-#{version}" : name
|
236
|
-
end
|
237
|
-
|
238
|
-
def tar_pkg_name
|
239
|
-
pkg_base_name + ".tar.gz"
|
240
|
-
end
|
241
|
-
|
242
|
-
def tar_pkg_path
|
243
|
-
pkg_dist_dir + ".tar.gz"
|
244
|
-
end
|
245
|
-
|
246
|
-
def zip_pkg_name
|
247
|
-
pkg_base_name + ".zip"
|
248
|
-
end
|
249
|
-
|
250
|
-
def zip_pkg_path
|
251
|
-
pkg_dist_dir + ".zip"
|
252
|
-
end
|
253
|
-
|
254
|
-
def pkg_dist_dir
|
255
|
-
@pkg_dir ? File.join(@pkg_dir, pkg_base_name) : pkg_base_name
|
256
|
-
end
|
257
|
-
|
258
|
-
end # class Rant::Generators::Package
|
File without changes
|