rant 0.3.8 → 0.4.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.
Files changed (55) hide show
  1. data/NEWS +19 -0
  2. data/README +51 -24
  3. data/Rantfile +7 -8
  4. data/doc/advanced.rdoc +3 -1
  5. data/doc/package.rdoc +280 -0
  6. data/doc/rantfile.rdoc +9 -19
  7. data/doc/rubyproject.rdoc +24 -16
  8. data/lib/rant/archive/minitar.rb +983 -0
  9. data/lib/rant/archive/rubyzip/ioextras.rb +122 -0
  10. data/lib/rant/archive/rubyzip/stdrubyext.rb +114 -0
  11. data/lib/rant/archive/rubyzip/tempfile_bugfixed.rb +195 -0
  12. data/lib/rant/archive/rubyzip.rb +1575 -0
  13. data/lib/rant/import/archive/tgz.rb +49 -0
  14. data/lib/rant/import/archive/zip.rb +67 -0
  15. data/lib/rant/import/archive.rb +312 -0
  16. data/lib/rant/import/autoclean.rb +2 -2
  17. data/lib/rant/import/c/dependencies.rb +3 -3
  18. data/lib/rant/import/clean.rb +1 -1
  19. data/lib/rant/import/directedrule.rb +1 -1
  20. data/lib/rant/import/package/tgz.rb +35 -0
  21. data/lib/rant/import/package/zip.rb +36 -0
  22. data/lib/rant/import/rubydoc.rb +1 -1
  23. data/lib/rant/import/rubypackage.rb +19 -77
  24. data/lib/rant/import/rubytest.rb +1 -1
  25. data/lib/rant/import/subfile.rb +28 -14
  26. data/lib/rant/import/win32/rubycmdwrapper.rb +1 -1
  27. data/lib/rant/import.rb +36 -16
  28. data/lib/rant/plugin/csharp.rb +1 -1
  29. data/lib/rant/rantenv.rb +2 -13
  30. data/lib/rant/rantfile.rb +11 -11
  31. data/lib/rant/rantlib.rb +7 -3
  32. data/lib/rant/rantsys.rb +53 -2
  33. data/lib/rant/rantvar.rb +62 -1
  34. data/misc/TODO +41 -0
  35. data/{devel-notes → misc/devel-notes} +6 -0
  36. data/misc/mt.rb +3 -0
  37. data/misc/t.rb +18 -0
  38. data/test/import/c/dependencies/test_c_dependencies.rb +18 -0
  39. data/test/import/package/MANIFEST +4 -0
  40. data/test/import/package/Rantfile +49 -0
  41. data/test/import/package/deep/sub/sub/f1 +1 -0
  42. data/test/import/package/sub/f1 +1 -0
  43. data/test/import/package/sub2/f1 +1 -0
  44. data/test/import/package/test_package.rb +425 -0
  45. data/test/import/subfile/Rantfile +8 -0
  46. data/test/import/subfile/test_subfile.rb +12 -0
  47. data/test/project_rb1/rantfile.rb +3 -4
  48. data/test/project_rb1/test_project_rb1.rb +16 -40
  49. data/test/rant-import/test_rant-import.rb +3 -3
  50. data/test/test_filelist.rb +39 -2
  51. data/test/tutil.rb +89 -3
  52. metadata +35 -6
  53. data/TODO +0 -21
  54. data/lib/rant/import/package.rb +0 -258
  55. /data/{rantmethods.rb → misc/rantmethods.rb} +0 -0
@@ -1,6 +1,5 @@
1
1
 
2
2
  require 'test/unit'
3
- require 'rant/rantlib'
4
3
  require 'tutil'
5
4
 
6
5
  $testProjectRb1Dir = File.expand_path(File.dirname(__FILE__))
@@ -11,12 +10,10 @@ class TestProjectRb1 < Test::Unit::TestCase
11
10
  test/text test/tc_wgrep.rb README test_project_rb1.rb
12
11
  rantfile.rb)
13
12
  # Ensure we run in test directory.
14
- Dir.chdir($testProjectRb1Dir) unless Dir.pwd == $testProjectRb1Dir
13
+ Dir.chdir($testProjectRb1Dir)
15
14
  end
16
15
  def teardown
17
- capture_std do
18
- assert_equal(Rant.run(%w(clean)), 0)
19
- end
16
+ assert_rant("clean")
20
17
  manifest = @manifest.dup
21
18
  check_manifest "after clean: "
22
19
  end
@@ -31,9 +28,7 @@ class TestProjectRb1 < Test::Unit::TestCase
31
28
  }
32
29
  end
33
30
  def test_doc
34
- capture_std do
35
- assert_equal(Rant.run(%w(doc)), 0)
36
- end
31
+ assert_rant("doc")
37
32
  assert(test(?d, "doc"),
38
33
  "RDoc task should generate dir `doc'")
39
34
  assert(test(?f, "doc/index.html"),
@@ -45,26 +40,12 @@ class TestProjectRb1 < Test::Unit::TestCase
45
40
  "README should be in html docs")
46
41
  end
47
42
  def test_test
48
- capture_std do
49
- assert_equal(0, Rant.run(%w(test)))
50
- end
43
+ assert_rant("test")
51
44
  end
52
45
  def test_package
53
- capture_std do
54
- assert_equal(0, Rant.run(%w(pkg)))
55
- end
46
+ assert_rant("pkg")
56
47
  assert(test(?d, "packages"),
57
48
  "task `pkg' should create dir `packages'")
58
- begin
59
- have_tar = !`tar --help`.empty?
60
- rescue
61
- have_tar = false
62
- end
63
- begin
64
- have_zip = !`zip -help`.empty?
65
- rescue
66
- have_zip = false
67
- end
68
49
  have_gem = false
69
50
  pkg_base = "packages/wgrep-1.0.0"
70
51
  begin
@@ -72,21 +53,13 @@ class TestProjectRb1 < Test::Unit::TestCase
72
53
  have_gem = true
73
54
  rescue LoadError
74
55
  end
75
- if have_tar
76
- tar_fn = pkg_base + ".tar.gz"
77
- assert(test(?f, tar_fn),
78
- "tar is available, so a tar.gz should have been built")
79
- verify_tar "packages", "wgrep-1.0.0", ".tar.gz"
80
- else
81
- puts "*** tar not available ***"
82
- end
83
- if have_zip
56
+ tar_fn = pkg_base + ".tar.gz"
57
+ assert(test(?f, tar_fn),
58
+ "tar is available, so a tar.gz should have been built")
59
+ verify_tar "packages", "wgrep-1.0.0", ".tar.gz"
84
60
  assert(test(?f, pkg_base + ".zip"),
85
61
  "zip is available, so a zip should have been built")
86
62
  verify_zip "packages", "wgrep-1.0.0", ".zip"
87
- else
88
- puts "*** zip not available ***"
89
- end
90
63
  if have_gem
91
64
  assert(test(?f, pkg_base + ".gem"),
92
65
  "gem is available, so a gem should have been built")
@@ -103,7 +76,8 @@ class TestProjectRb1 < Test::Unit::TestCase
103
76
  FileUtils.mkdir tmp_dir
104
77
  FileUtils.cp tar_fn, tmp_dir
105
78
  FileUtils.cd tmp_dir do
106
- `tar xzf #{tar_fn}`
79
+ #`tar xzf #{tar_fn}`
80
+ unpack_archive :tgz, tar_fn
107
81
  assert(test(?d, pkg_base),
108
82
  "`#{pkg_base}' should be root directory of all files in tar")
109
83
  FileUtils.cd pkg_base do
@@ -123,7 +97,8 @@ class TestProjectRb1 < Test::Unit::TestCase
123
97
  FileUtils.mkdir tmp_dir
124
98
  FileUtils.cp zip_fn, tmp_dir
125
99
  FileUtils.cd tmp_dir do
126
- `unzip -q #{zip_fn}`
100
+ #`unzip -q #{zip_fn}`
101
+ unpack_archive :zip, zip_fn
127
102
  assert(test(?d, pkg_base),
128
103
  "`#{pkg_base}' should be root directory of all files in zip")
129
104
  FileUtils.cd pkg_base do
@@ -142,12 +117,13 @@ class TestProjectRb1 < Test::Unit::TestCase
142
117
  # TODO: some out, err checking
143
118
 
144
119
  # run the monolithic rant script
145
- out = `#{Rant::Env::RUBY} make -T`
120
+ #out = `#{Rant::Env::RUBY} make -T`
121
+ out = run_ruby("make", "-T")
146
122
  assert_equal(0, $?,
147
123
  "imported `rant -T' should return 0")
148
124
  assert_match(/\bpkg\b/, out,
149
125
  "imported `rant -T' should list described task `pkg'")
150
126
  ensure
151
- File.delete "make" if File.exist? "make"
127
+ FileUtils.rm_f "make"
152
128
  end
153
129
  end
@@ -29,7 +29,7 @@ class TestRantImport < Test::Unit::TestCase
29
29
  open("mylib.t/rant/import/mygen.rb", "w") { |f|
30
30
  f << <<-EOF
31
31
  mygen = Object.new
32
- def mygen.rant_generate(rac, ch, args, &block)
32
+ def mygen.rant_gen(rac, ch, args, &block)
33
33
  tn = args.first || "mygen"
34
34
  rac.task(:__caller__ => ch, tn => []) do |t|
35
35
  puts "Greetings from `" + t.name + "', generated by MyGen."
@@ -73,7 +73,7 @@ class TestRantImport < Test::Unit::TestCase
73
73
  module Rant::Generators
74
74
  module Sub
75
75
  class T
76
- def self.rant_generate(rac, ch, args, &blk)
76
+ def self.rant_gen(rac, ch, args, &blk)
77
77
  raise "no ch" unless Hash === ch
78
78
  rac.cx.task args.first do |t|
79
79
  puts args
@@ -122,7 +122,7 @@ class TestRantImport < Test::Unit::TestCase
122
122
  module Rant::Generators
123
123
  module Sub2
124
124
  class T
125
- def self.rant_generate(rac, ch, args, &blk)
125
+ def self.rant_gen(rac, ch, args, &blk)
126
126
  rac.cx.task args.first do |t|
127
127
  misc_print(args)
128
128
  end
@@ -158,6 +158,15 @@ class TestFileList < Test::Unit::TestCase
158
158
  assert_equal(1, l2.size)
159
159
  end
160
160
  end
161
+ def test_add_array
162
+ touch_temp %w(1.t 2.t) do
163
+ l1 = fl "*.t"
164
+ l2 = l1 + %w(x)
165
+ assert_equal(2, l1.size)
166
+ assert_equal(3, l2.size)
167
+ assert(l2.include?("x"))
168
+ end
169
+ end
161
170
  def test_glob
162
171
  touch_temp %w(t.t1 t.t2) do
163
172
  l = fl "*.t1"
@@ -287,8 +296,36 @@ class TestFileList < Test::Unit::TestCase
287
296
  l2 = cx.sys["*.t"]
288
297
  assert_equal(4, l1.size)
289
298
  assert_equal(2, l2.size)
290
- %w(a.t .a.t b.t .b.t).each { |f| l1.include? f }
291
- %w(a.t b.t ).each { |f| l2.include? f }
299
+ %w(a.t .a.t b.t .b.t).each { |f|
300
+ assert(l1.include?(f))
301
+ }
302
+ %w(a.t b.t ).each { |f|
303
+ assert(l2.include?(f))
304
+ }
292
305
  end
293
306
  end
307
+ def test_add_no_dir
308
+ cx = Rant::RantApp.new.cx
309
+ FileUtils.mkdir "tfl.t"
310
+ FileUtils.mkdir "tfl.tt"
311
+ touch_temp %w(a.t a.tt) do
312
+ l1 = cx.sys["*.t"]
313
+ l1 += cx.sys["*.tt"].no_dir
314
+ assert_equal(3, l1.size)
315
+ %w(tfl.t a.t a.tt).each { |f|
316
+ assert(l1.include?(f))
317
+ }
318
+ end
319
+ ensure
320
+ FileUtils.rm_rf %w(tfl.t tfl.tt)
321
+ end
322
+ def test_exclude_arrows_op
323
+ cx = Rant::RantApp.new.cx
324
+ touch_temp %w(a.t b.t) do
325
+ fl = cx.sys["*.t"]
326
+ fl.exclude "*.t"
327
+ fl << "a.t"
328
+ assert(fl.include?("a.t"))
329
+ end
330
+ end
294
331
  end
data/test/tutil.rb CHANGED
@@ -10,6 +10,7 @@ module Test
10
10
  def assert_rant(*args)
11
11
  res = 0
12
12
  capture = true
13
+ newproc = false
13
14
  args.flatten!
14
15
  args.reject! { |arg|
15
16
  if Symbol === arg
@@ -17,6 +18,7 @@ module Test
17
18
  when :fail: res = 1
18
19
  when :v: capture = false
19
20
  when :verbose: capture = false
21
+ when :x: newproc = true
20
22
  else
21
23
  raise "No such option -- #{arg}"
22
24
  end
@@ -25,6 +27,17 @@ module Test
25
27
  false
26
28
  end
27
29
  }
30
+ if newproc
31
+ if capture
32
+ # TODO: stderr
33
+ `#{Rant::Sys.sp(Rant::Env::RUBY)} #{Rant::Sys.sp(RANT_BIN)} #{args.flatten.join(' ')}`
34
+ else
35
+ system("#{Rant::Sys.sp(Rant::Env::RUBY)} " +
36
+ #{Rant::Sys.sp(RANT_BIN)} " +
37
+ "#{args.flatten.join(' ')}")
38
+ end
39
+ assert_equal(res, $?.exitstatus)
40
+ end
28
41
  if capture
29
42
  capture_std do
30
43
  assert_equal(res, ::Rant::RantApp.new.run(*args))
@@ -33,6 +46,9 @@ module Test
33
46
  assert_equal(res, ::Rant::RantApp.new.run(*args))
34
47
  end
35
48
  end
49
+ def assert_exit(status = 0)
50
+ assert_equal(status, $?.exitstatus)
51
+ end
36
52
  end
37
53
  end
38
54
  end
@@ -145,13 +161,83 @@ When testing Rant: `#{Dir.pwd + "/" + errfn}' exists.
145
161
  end
146
162
 
147
163
  def run_rant(*args)
148
- `#{Rant::Sys.sp(Rant::Env::RUBY)} #{Rant::Sys.sp(RANT_BIN)} #{args.flatten.arglist}`
164
+ `#{Rant::Sys.sp(Rant::Env::RUBY)} #{Rant::Sys.sp(RANT_BIN)} #{args.flatten.join(' ')}`
149
165
  end
150
166
 
151
167
  def run_import(*args)
152
- `#{Rant::Sys.sp(Rant::Env::RUBY)} #{Rant::Sys.sp(RANT_IMPORT_BIN)} #{args.flatten.arglist}`
168
+ `#{Rant::Sys.sp(Rant::Env::RUBY)} #{Rant::Sys.sp(RANT_IMPORT_BIN)} #{args.flatten.join(' ')}`
153
169
  end
154
170
 
155
171
  def run_ruby(*args)
156
- `#{Rant::Sys.sp(Rant::Env::RUBY)} #{args.flatten.arglist}`
172
+ `#{Rant::Sys.sp(Rant::Env::RUBY)} #{args.flatten.join(' ')}`
173
+ end
174
+
175
+ $have_unzip = !!Rant::Env.find_bin("unzip")
176
+
177
+ def unpack_archive(atype, archive)
178
+ case atype
179
+ when :tgz
180
+ if ::Rant::Env.have_tar?
181
+ `tar -xzf #{archive}`
182
+ else
183
+ minitar_unpack archive
184
+ end
185
+ when :zip
186
+ if $have_unzip
187
+ `unzip -q #{archive}`
188
+ else
189
+ rubyzip_unpack archive
190
+ end
191
+ else
192
+ raise "can't unpack archive type #{atype}"
193
+ end
194
+ end
195
+ def minitar_unpack(archive)
196
+ require 'rant/archive/minitar'
197
+ tgz = Zlib::GzipReader.new(File.open(archive, 'rb'))
198
+ # unpack closes tgz
199
+ Rant::Archive::Minitar.unpack(tgz, '.')
200
+ end
201
+ def rubyzip_unpack(archive)
202
+ require 'rant/archive/rubyzip'
203
+ f = Rant::Archive::Rubyzip::ZipFile.open archive
204
+ f.entries.each { |e|
205
+ dir, = File.split(e.name)
206
+ FileUtils.mkpath dir unless test ?d, dir
207
+ f.extract e, e.name
208
+ }
209
+ f.close
210
+ end
211
+
212
+ # Returns a list with the files required by the IO object script.
213
+ def extract_requires(script, dynamic_requires = [])
214
+ in_ml_comment = false
215
+ requires = []
216
+ script.each { |line|
217
+ if in_ml_comment
218
+ if line =~ /^=end/
219
+ in_ml_comment = false
220
+ end
221
+ next
222
+ end
223
+ # skip shebang line
224
+ next if line =~ /^#! ?(\/|\\)?\w/
225
+ # skip pure comment lines
226
+ next if line =~ /^\s*#/
227
+ if line =~ /^=begin\s/
228
+ in_ml_comment = true
229
+ next
230
+ end
231
+ name = nil
232
+ lib_file = nil
233
+ if line =~ /\s*(require|load)\s*('|")([^\2]*)\2/
234
+ fn = $3
235
+ if fn =~ /\#\{[^\}]+\}/ || fn =~ /\#\@/
236
+ dynamic_requires << fn
237
+ else
238
+ requires << fn
239
+ end
240
+ end
241
+ }
242
+ requires
157
243
  end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.10
3
3
  specification_version: 1
4
4
  name: rant
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.3.8
7
- date: 2005-05-15
6
+ version: 0.4.0
7
+ date: 2005-07-10
8
8
  summary: Rant is a Ruby based build tool.
9
9
  require_paths:
10
10
  - lib
@@ -30,13 +30,10 @@ authors:
30
30
  - Stefan Lang
31
31
  files:
32
32
  - NEWS
33
- - TODO
34
33
  - README
35
34
  - Rantfile
36
35
  - install.rb
37
36
  - run_rant
38
- - devel-notes
39
- - rantmethods.rb
40
37
  - run_import
41
38
  - setup.rb
42
39
  - COPYING
@@ -54,6 +51,7 @@ files:
54
51
  - lib/rant/import
55
52
  - lib/rant/plugin_methods.rb
56
53
  - lib/rant/plugin
54
+ - lib/rant/archive
57
55
  - lib/rant/import.rb
58
56
  - lib/rant/c/include.rb
59
57
  - lib/rant/import/c
@@ -63,15 +61,27 @@ files:
63
61
  - lib/rant/import/rubydoc.rb
64
62
  - lib/rant/import/rubytest.rb
65
63
  - lib/rant/import/rubypackage.rb
64
+ - lib/rant/import/archive.rb
65
+ - lib/rant/import/package
66
+ - lib/rant/import/archive
66
67
  - lib/rant/import/subfile.rb
67
- - lib/rant/import/package.rb
68
68
  - lib/rant/import/clean.rb
69
69
  - lib/rant/import/autoclean.rb
70
70
  - lib/rant/import/c/dependencies.rb
71
71
  - lib/rant/import/win32/rubycmdwrapper.rb
72
+ - lib/rant/import/package/tgz.rb
73
+ - lib/rant/import/package/zip.rb
74
+ - lib/rant/import/archive/tgz.rb
75
+ - lib/rant/import/archive/zip.rb
72
76
  - lib/rant/plugin/README
73
77
  - lib/rant/plugin/configure.rb
74
78
  - lib/rant/plugin/csharp.rb
79
+ - lib/rant/archive/minitar.rb
80
+ - lib/rant/archive/rubyzip
81
+ - lib/rant/archive/rubyzip.rb
82
+ - lib/rant/archive/rubyzip/stdrubyext.rb
83
+ - lib/rant/archive/rubyzip/ioextras.rb
84
+ - lib/rant/archive/rubyzip/tempfile_bugfixed.rb
75
85
  - test/c
76
86
  - test/test_filetask.rb
77
87
  - test/test_lighttask.rb
@@ -128,6 +138,7 @@ files:
128
138
  - test/import/truth
129
139
  - test/import/subfile
130
140
  - test/import/directedrule
141
+ - test/import/package
131
142
  - test/import/c/dependencies
132
143
  - test/import/c/dependencies/src
133
144
  - test/import/c/dependencies/bar.h
@@ -151,6 +162,17 @@ files:
151
162
  - test/import/subfile/autoclean.rf
152
163
  - test/import/directedrule/Rantfile
153
164
  - test/import/directedrule/test_directedrule.rb
165
+ - test/import/package/sub
166
+ - test/import/package/deep
167
+ - test/import/package/sub2
168
+ - test/import/package/Rantfile
169
+ - test/import/package/test_package.rb
170
+ - test/import/package/MANIFEST
171
+ - test/import/package/sub/f1
172
+ - test/import/package/deep/sub
173
+ - test/import/package/deep/sub/sub
174
+ - test/import/package/deep/sub/sub/f1
175
+ - test/import/package/sub2/f1
154
176
  - test/plugin/configure
155
177
  - test/plugin/csharp
156
178
  - test/plugin/rantfile
@@ -183,6 +205,7 @@ files:
183
205
  - doc/csharp.rdoc
184
206
  - doc/rant-import.rdoc
185
207
  - doc/examples
208
+ - doc/package.rdoc
186
209
  - doc/examples/directedrule
187
210
  - doc/examples/myprog
188
211
  - doc/examples/c_dependencies
@@ -206,6 +229,11 @@ files:
206
229
  - doc/examples/c_dependencies/src/util.c
207
230
  - doc/examples/c_dependencies/include/hello.h
208
231
  - doc/examples/c_dependencies/include/util.h
232
+ - misc/TODO
233
+ - misc/t.rb
234
+ - misc/mt.rb
235
+ - misc/devel-notes
236
+ - misc/rantmethods.rb
209
237
  test_files: []
210
238
  rdoc_options:
211
239
  - "-S"
@@ -224,6 +252,7 @@ extra_rdoc_files:
224
252
  - doc/rant.rdoc
225
253
  - doc/csharp.rdoc
226
254
  - doc/rant-import.rdoc
255
+ - doc/package.rdoc
227
256
  - README
228
257
  - doc/examples/myprog/README
229
258
  - lib/rant/plugin/README
data/TODO DELETED
@@ -1,21 +0,0 @@
1
-
2
- = TODO
3
-
4
- == GET RID OF CLASS Rant::Path
5
- Done.
6
-
7
- == Packaging
8
- Try minitar if tar is not available.
9
-
10
- == C# plugin
11
- Define the method +assembly+ for building a file with the C# compiler?
12
- Done.
13
-
14
- == Predefined tasks
15
-
16
- Add a 'distclean' task that removes all files and directories
17
- generatet by any file task.
18
-
19
- == Java plugin
20
-
21
- At least for the 1.0.0 release.