buildr 1.3.5-x86-mswin32 → 1.4.0-x86-mswin32

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 (151) hide show
  1. data/CHANGELOG +153 -8
  2. data/README.rdoc +1 -1
  3. data/addon/buildr/antlr.rb +5 -5
  4. data/addon/buildr/drb.rb +18 -18
  5. data/addon/buildr/hibernate.rb +18 -14
  6. data/addon/buildr/javacc.rb +4 -4
  7. data/addon/buildr/jetty.rb +5 -5
  8. data/addon/buildr/nailgun.rb +23 -23
  9. data/addon/buildr/openjpa.rb +1 -1
  10. data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
  11. data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
  12. data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  13. data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  14. data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  15. data/addon/buildr/protobuf.rb +75 -0
  16. data/addon/buildr/xmlbeans.rb +5 -5
  17. data/buildr.buildfile +2 -2
  18. data/buildr.gemspec +8 -7
  19. data/doc/_layouts/default.html +2 -2
  20. data/doc/artifacts.textile +4 -4
  21. data/doc/building.textile +35 -3
  22. data/doc/contributing.textile +5 -0
  23. data/doc/download.textile +16 -5
  24. data/doc/extending.textile +38 -12
  25. data/doc/installing.textile +6 -5
  26. data/doc/languages.textile +182 -42
  27. data/doc/more_stuff.textile +2 -2
  28. data/doc/packaging.textile +14 -15
  29. data/doc/projects.textile +7 -2
  30. data/doc/quick_start.textile +4 -4
  31. data/doc/scripts/buildr-git.rb +63 -63
  32. data/doc/scripts/gitflow.rb +21 -21
  33. data/doc/settings_profiles.textile +9 -2
  34. data/doc/testing.textile +16 -5
  35. data/etc/KEYS +38 -0
  36. data/lib/buildr.rb +1 -1
  37. data/lib/buildr/core.rb +1 -0
  38. data/lib/buildr/core/application.rb +33 -27
  39. data/lib/buildr/core/build.rb +41 -28
  40. data/lib/buildr/core/cc.rb +172 -0
  41. data/lib/buildr/core/checks.rb +1 -1
  42. data/lib/buildr/core/common.rb +7 -6
  43. data/lib/buildr/core/compile.rb +7 -8
  44. data/lib/buildr/core/doc.rb +263 -0
  45. data/lib/buildr/core/environment.rb +6 -6
  46. data/lib/buildr/core/filter.rb +77 -35
  47. data/lib/buildr/core/generate.rb +7 -7
  48. data/lib/buildr/core/help.rb +1 -1
  49. data/lib/buildr/core/osx.rb +6 -6
  50. data/lib/buildr/core/progressbar.rb +4 -4
  51. data/lib/buildr/core/project.rb +144 -36
  52. data/lib/buildr/core/shell.rb +34 -34
  53. data/lib/buildr/core/test.rb +89 -20
  54. data/lib/buildr/core/transports.rb +8 -7
  55. data/lib/buildr/core/util.rb +77 -23
  56. data/lib/buildr/groovy/bdd.rb +5 -5
  57. data/lib/buildr/groovy/compiler.rb +19 -15
  58. data/lib/buildr/groovy/shell.rb +6 -6
  59. data/lib/buildr/ide/eclipse.rb +148 -75
  60. data/lib/buildr/ide/eclipse/java.rb +3 -3
  61. data/lib/buildr/ide/eclipse/plugin.rb +8 -5
  62. data/lib/buildr/ide/eclipse/scala.rb +4 -2
  63. data/lib/buildr/ide/idea.rb +2 -2
  64. data/lib/buildr/ide/idea7x.rb +23 -4
  65. data/lib/buildr/java.rb +1 -0
  66. data/lib/buildr/java/ant.rb +4 -4
  67. data/lib/buildr/java/bdd.rb +51 -54
  68. data/lib/buildr/java/cobertura.rb +57 -35
  69. data/lib/buildr/java/commands.rb +14 -5
  70. data/lib/buildr/java/compiler.rb +3 -217
  71. data/lib/buildr/java/deprecated.rb +4 -4
  72. data/lib/buildr/java/doc.rb +70 -0
  73. data/lib/buildr/java/emma.rb +22 -22
  74. data/lib/buildr/java/jruby.rb +4 -4
  75. data/lib/buildr/java/jtestr_runner.rb.erb +27 -25
  76. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  77. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +8 -3
  78. data/lib/buildr/java/packaging.rb +30 -29
  79. data/lib/buildr/java/pom.rb +4 -4
  80. data/lib/buildr/java/rjb.rb +6 -6
  81. data/lib/buildr/java/test_result.rb +61 -85
  82. data/lib/buildr/java/tests.rb +44 -27
  83. data/lib/buildr/java/version_requirement.rb +8 -8
  84. data/lib/buildr/packaging/archive.rb +55 -22
  85. data/lib/buildr/packaging/artifact.rb +75 -36
  86. data/lib/buildr/packaging/artifact_namespace.rb +90 -78
  87. data/lib/buildr/packaging/artifact_search.rb +5 -5
  88. data/lib/buildr/packaging/gems.rb +11 -7
  89. data/lib/buildr/packaging/package.rb +10 -7
  90. data/lib/buildr/packaging/tar.rb +14 -14
  91. data/lib/buildr/packaging/version_requirement.rb +30 -10
  92. data/lib/buildr/packaging/ziptask.rb +51 -13
  93. data/lib/buildr/scala.rb +1 -0
  94. data/lib/buildr/scala/bdd.rb +25 -20
  95. data/lib/buildr/scala/compiler.rb +87 -40
  96. data/lib/buildr/scala/doc.rb +106 -0
  97. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
  98. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.java +57 -0
  99. data/lib/buildr/scala/shell.rb +14 -9
  100. data/lib/buildr/scala/tests.rb +33 -26
  101. data/lib/buildr/shell.rb +33 -33
  102. data/rakelib/all-in-one.rake +113 -0
  103. data/rakelib/checks.rake +1 -1
  104. data/rakelib/doc.rake +7 -0
  105. data/rakelib/package.rake +1 -1
  106. data/rakelib/release.rake +9 -6
  107. data/rakelib/rspec.rake +26 -7
  108. data/rakelib/setup.rake +15 -3
  109. data/rakelib/stage.rake +18 -11
  110. data/spec/addon/drb_spec.rb +25 -25
  111. data/spec/core/application_spec.rb +111 -21
  112. data/spec/core/build_spec.rb +16 -15
  113. data/spec/core/cc_spec.rb +174 -0
  114. data/spec/core/checks_spec.rb +34 -34
  115. data/spec/core/common_spec.rb +51 -5
  116. data/spec/core/compile_spec.rb +89 -14
  117. data/spec/core/extension_spec.rb +127 -19
  118. data/spec/core/generate_spec.rb +2 -2
  119. data/spec/core/project_spec.rb +10 -10
  120. data/spec/core/test_spec.rb +144 -35
  121. data/spec/core/transport_spec.rb +8 -8
  122. data/spec/core/util_spec.rb +63 -5
  123. data/spec/groovy/bdd_spec.rb +5 -5
  124. data/spec/groovy/compiler_spec.rb +29 -18
  125. data/spec/ide/eclipse_spec.rb +185 -9
  126. data/spec/ide/idea7x_spec.rb +22 -10
  127. data/spec/java/ant_spec.rb +9 -5
  128. data/spec/java/bdd_spec.rb +29 -37
  129. data/spec/java/cobertura_spec.rb +12 -12
  130. data/spec/java/commands_spec.rb +34 -0
  131. data/spec/java/compiler_spec.rb +53 -53
  132. data/spec/java/emma_spec.rb +11 -11
  133. data/spec/java/java_spec.rb +10 -10
  134. data/spec/java/packaging_spec.rb +67 -20
  135. data/spec/java/test_coverage_helper.rb +18 -18
  136. data/spec/java/tests_spec.rb +13 -9
  137. data/spec/packaging/archive_spec.rb +187 -20
  138. data/spec/packaging/artifact_namespace_spec.rb +172 -83
  139. data/spec/packaging/artifact_spec.rb +83 -18
  140. data/spec/packaging/packaging_spec.rb +41 -14
  141. data/spec/sandbox.rb +23 -12
  142. data/spec/scala/bdd_spec.rb +13 -8
  143. data/spec/scala/compiler_spec.rb +18 -13
  144. data/spec/scala/scala.rb +3 -3
  145. data/spec/scala/tests_spec.rb +46 -24
  146. data/spec/spec_helpers.rb +28 -10
  147. data/spec/version_requirement_spec.rb +25 -11
  148. metadata +149 -133
  149. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner$.class +0 -0
  150. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.scala +0 -35
  151. data/rakelib/stage.rake~ +0 -213
@@ -39,23 +39,25 @@ describe Buildr::JUnit do
39
39
  project('foo').test.compile.dependencies.should include(artifact("junit:junit:jar:#{JUnit.version}"))
40
40
  project('foo').test.dependencies.should include(artifact("junit:junit:jar:#{JUnit.version}"))
41
41
  end
42
-
42
+
43
43
  it 'should have REQUIRES up to version 1.5 since it was deprecated in 1.3.3' do
44
44
  Buildr::VERSION.should < '1.5'
45
45
  lambda { JUnit::REQUIRES }.should_not raise_error
46
46
  end
47
-
47
+
48
48
  it 'should pick JUnit version from junit build settings' do
49
49
  Buildr::JUnit.instance_eval { @dependencies = nil }
50
50
  write 'build.yaml', 'junit: 1.2.3'
51
51
  define('foo') { test.using(:junit) }
52
52
  project('foo').test.compile.dependencies.should include(artifact("junit:junit:jar:1.2.3"))
53
53
  end
54
-
54
+
55
55
  it 'should include JMock dependencies' do
56
56
  define('foo') { test.using(:junit) }
57
- project('foo').test.compile.dependencies.should include(artifact("jmock:jmock:jar:#{JMock.version}"))
58
- project('foo').test.dependencies.should include(artifact("jmock:jmock:jar:#{JMock.version}"))
57
+ two_or_later = JMock.version[0,1].to_i >= 2
58
+ group = two_or_later ? "org.jmock" : "jmock"
59
+ project('foo').test.compile.dependencies.should include(artifact("#{group}:jmock:jar:#{JMock.version}"))
60
+ project('foo').test.dependencies.should include(artifact("#{group}:jmock:jar:#{JMock.version}"))
59
61
  end
60
62
 
61
63
  it 'should pick JUnit version from junit build settings' do
@@ -65,7 +67,7 @@ describe Buildr::JUnit do
65
67
  define('foo') { test.using(:junit) }
66
68
  project('foo').test.compile.dependencies.should include(artifact("jmock:jmock:jar:1.2.3"))
67
69
  end
68
-
70
+
69
71
  it 'should include public classes extending junit.framework.TestCase' do
70
72
  write 'src/test/java/com/example/FirstTest.java', <<-JAVA
71
73
  package com.example;
@@ -287,7 +289,7 @@ describe Buildr::JUnit do
287
289
  fork_tests :each
288
290
  project('foo').test.failed_tests.should be_empty
289
291
  end
290
-
292
+
291
293
  after do
292
294
  # Yes, this is ugly. Better solution?
293
295
  Buildr::JUnit.instance_eval { @dependencies = nil }
@@ -374,8 +376,10 @@ describe Buildr::TestNG do
374
376
 
375
377
  it 'should include TestNG dependencies' do
376
378
  define('foo') { test.using :testng }
377
- project('foo').test.compile.dependencies.should include(artifact("jmock:jmock:jar:#{JMock.version}"))
378
- project('foo').test.dependencies.should include(artifact("jmock:jmock:jar:#{JMock.version}"))
379
+ two_or_later = JMock.version[0,1].to_i >= 2
380
+ group = two_or_later ? "org.jmock" : "jmock"
381
+ project('foo').test.compile.dependencies.should include(artifact("#{group}:jmock:jar:#{JMock.version}"))
382
+ project('foo').test.dependencies.should include(artifact("#{group}:jmock:jar:#{JMock.version}"))
379
383
  end
380
384
 
381
385
  it 'should include classes using TestNG annotations' do
@@ -22,6 +22,8 @@ describe 'ArchiveTask', :shared=>true do
22
22
  @dir = File.expand_path('test')
23
23
  @files = %w{Test1.txt Text2.html}.map { |file| File.expand_path(file, @dir) }.
24
24
  each { |file| write file, content_for(file) }
25
+ @empty_dirs = %w{EmptyDir1 EmptyDir2}.map { |file| File.expand_path(file, @dir) }.
26
+ each { |file| mkdir file }
25
27
  end
26
28
 
27
29
  # Not too smart, we just create some content based on file name to make sure you read what you write.
@@ -59,6 +61,11 @@ describe 'ArchiveTask', :shared=>true do
59
61
  inspect_archive { |archive| archive.should be_empty }
60
62
  end
61
63
 
64
+ it 'should raise error when include() is called with nil values' do
65
+ lambda { archive(@archive).include(nil) }.should raise_error
66
+ lambda { archive(@archive).include([nil]) }.should raise_error
67
+ end
68
+
62
69
  it 'should create empty archive if called #clean method' do
63
70
  archive(@archive).include(@files).clean.invoke
64
71
  inspect_archive { |archive| archive.should be_empty }
@@ -83,6 +90,22 @@ describe 'ArchiveTask', :shared=>true do
83
90
  inspect_archive.keys.should include('included')
84
91
  end
85
92
 
93
+ it 'should archive artifacts' do
94
+ write 'library-1.0.txt', 'library-1.0'
95
+ artifact("org.example:library:txt:1.0").from 'library-1.0.txt'
96
+ archive(@archive).include("org.example:library:txt:1.0").invoke
97
+ inspect_archive.keys.should include('library-1.0.txt')
98
+ end
99
+
100
+ it 'should archive project artifacts' do
101
+ define 'p1' do
102
+ project.version = '1.0'
103
+ package(:zip)
104
+ end
105
+ archive(@archive).include(project('p1')).invoke
106
+ inspect_archive.keys.should include('p1-1.0.zip')
107
+ end
108
+
86
109
  it 'should include entry for directory' do
87
110
  archive(@archive).include(@dir).invoke
88
111
  inspect_archive { |archive| @files.each { |f| archive['test/' + File.basename(f)].should eql(content_for(f)) } }
@@ -112,12 +135,18 @@ describe 'ArchiveTask', :shared=>true do
112
135
  end
113
136
  end
114
137
 
138
+ it 'should raise error when using :from with nil value' do
139
+ lambda {
140
+ archive(@archive).include(:from=>nil)
141
+ }.should raise_error
142
+ end
143
+
115
144
  it 'should exclude entire directory and all its children' do
116
145
  mkpath "#{@dir}/sub"
117
146
  write "#{@dir}/sub/test"
118
147
  archive(@archive).include(@dir).exclude("#{@dir}/sub").invoke
119
148
  inspect_archive do |archive|
120
- archive.keys.select { |file| file =~ /sub/ }.should be_empty
149
+ archive.keys.select { |file| file =~ /sub/ }.should be_empty
121
150
  end
122
151
  end
123
152
 
@@ -171,6 +200,11 @@ describe 'ArchiveTask', :shared=>true do
171
200
  archive(@archive).include(@files.first, :as=>'test/sample').invoke
172
201
  inspect_archive { |archive| @files.each { |f| archive['test/sample'].should eql(content_for(@files.first)) } }
173
202
  end
203
+
204
+ it 'should archive directory into specified alias, without using "."' do
205
+ archive(@archive).include(@dir, :as=>'.').invoke
206
+ inspect_archive { |archive| archive.keys.should_not include(".") }
207
+ end
174
208
 
175
209
  it 'should archive file into specified name/path' do
176
210
  archive(@archive).include(@files.first, :as=>'test/sample', :path=>'path').invoke
@@ -219,19 +253,19 @@ describe 'ArchiveTask', :shared=>true do
219
253
  create_for_merge do |src|
220
254
  archive(@archive).merge(src).include(File.basename(@files.first))
221
255
  archive(@archive).invoke
222
- inspect_archive do |archive|
256
+ inspect_archive do |archive|
223
257
  archive[File.basename(@files.first)].should eql(content_for(@files.first))
224
258
  archive[File.basename(@files.last)].should be_nil
225
259
  end
226
260
  end
227
261
  end
228
-
262
+
229
263
  it 'should expand another archive file with exclude pattern' do
230
264
  create_for_merge do |src|
231
265
  archive(@archive).merge(src).exclude(File.basename(@files.first))
232
266
  archive(@archive).invoke
233
- inspect_archive do |archive|
234
- @files[1..-1].each { |f| archive[File.basename(f)].should eql(content_for(f)) }
267
+ inspect_archive do |archive|
268
+ @files[1..-1].each { |f| archive[File.basename(f)].should eql(content_for(f)) }
235
269
  archive[File.basename(@files.first)].should be_nil
236
270
  end
237
271
  end
@@ -285,7 +319,7 @@ describe 'ArchiveTask', :shared=>true do
285
319
  # all included files newer.
286
320
  File.utime Time.now - 100, Time.now - 100, @archive
287
321
  archive(@archive).include(@files).invoke
288
- File.stat(@archive).mtime.should be_close(Time.now, 10)
322
+ File.stat(@archive).mtime.should be_close(Time.now, 10)
289
323
  end
290
324
 
291
325
  it 'should do nothing if all files are uptodate' do
@@ -293,7 +327,7 @@ describe 'ArchiveTask', :shared=>true do
293
327
  # By touching all files in the past, there's nothing new to update.
294
328
  (@files + [@archive]).each { |f| File.utime Time.now - 100, Time.now - 100, f }
295
329
  archive(@archive).include(@files).invoke
296
- File.stat(@archive).mtime.should be_close(Time.now - 100, 10)
330
+ File.stat(@archive).mtime.should be_close(Time.now - 100, 10)
297
331
  end
298
332
 
299
333
  it 'should update if one of the files is recent' do
@@ -342,7 +376,7 @@ describe TarTask, ' gzipped' do
342
376
 
343
377
  def inspect_archive
344
378
  entries = {}
345
- Zlib::GzipReader.open @archive do |gzip|
379
+ Zlib::GzipReader.open @archive do |gzip|
346
380
  Archive::Tar::Minitar.open gzip, 'r' do |reader|
347
381
  reader.each { |entry| entries[entry.directory ? "#{entry.name}/" : entry.name] = entry.read }
348
382
  end
@@ -370,23 +404,50 @@ describe ZipTask do
370
404
  entries
371
405
  end
372
406
 
407
+ it 'should include empty dirs' do
408
+ archive(@archive).include(@dir)
409
+ archive(@archive).invoke
410
+ inspect_archive do |archive|
411
+ archive.keys.should include('test/EmptyDir1/')
412
+ end
413
+ end
414
+
415
+ it 'should include empty dirs from Dir' do
416
+ archive(@archive).include(Dir["#{@dir}/*"])
417
+ archive(@archive).invoke
418
+ inspect_archive do |archive|
419
+ archive.keys.should include('EmptyDir1/')
420
+ end
421
+ end
422
+
373
423
  it 'should work with path object' do
374
424
  archive(@archive).path('code').include(@files)
375
425
  archive(@archive).invoke
376
426
  inspect_archive { |archive| archive.keys.should include('code/') }
377
427
  end
428
+
429
+ it 'should have path object that includes empty dirs' do
430
+ archive(@archive).path('code').include(Dir["#{@dir}/*"])
431
+ archive(@archive).invoke
432
+ inspect_archive do |archive|
433
+ archive.keys.should include('code/EmptyDir1/')
434
+ end
435
+ end
378
436
 
379
- it 'should preserve file permissions' do
380
- # with JRuby it's important to use absolute paths with File.chmod()
381
- # http://jira.codehaus.org/browse/JRUBY-3300
382
- hello = File.expand_path('src/main/bin/hello')
383
- write hello, 'echo hi'
384
- File.chmod(0777, hello) ||
385
- fail("Failed to set permission on #{hello}") unless (File.stat(hello).mode & 0777) == 0777
437
+ # chmod is not reliable on Windows
438
+ unless Buildr::Util.win_os?
439
+ it 'should preserve file permissions' do
440
+ # with JRuby it's important to use absolute paths with File.chmod()
441
+ # http://jira.codehaus.org/browse/JRUBY-3300
442
+ hello = File.expand_path('src/main/bin/hello')
443
+ write hello, 'echo hi'
444
+ File.chmod(0777, hello)
445
+ fail("Failed to set permission on #{hello}") unless (File.stat(hello).mode & 0777) == 0777
386
446
 
387
- zip('foo.zip').include('src/main/bin/*').invoke
388
- unzip('target' => 'foo.zip').extract
389
- (File.stat('target/hello').mode & 0777).should == 0777
447
+ zip('foo.zip').include('src/main/bin/*').invoke
448
+ unzip('target' => 'foo.zip').extract
449
+ (File.stat('target/hello').mode & 0777).should == 0777
450
+ end
390
451
  end
391
452
 
392
453
  end
@@ -399,6 +460,8 @@ describe Unzip do
399
460
  @files = %w{Test1.txt Text2.html}.map { |file| File.join(@dir, file) }.
400
461
  each { |file| write file, content_for(file) }
401
462
  @target = File.expand_path('target')
463
+ @targz = File.expand_path('test.tar.gz')
464
+ @targz2 = File.expand_path('test.tgz')
402
465
  end
403
466
 
404
467
  # Not too smart, we just create some content based on file name to
@@ -407,11 +470,21 @@ describe Unzip do
407
470
  "Content for #{File.basename(file)}"
408
471
  end
409
472
 
473
+ def with_tar(*args)
474
+ tar(@targz).include(*args.empty? ? @files : args).invoke
475
+ yield
476
+ end
477
+
478
+ def with_tar_too(*args)
479
+ tar(@targz2).include(*args.empty? ? @files : args).invoke
480
+ yield
481
+ end
482
+
410
483
  def with_zip(*args)
411
484
  zip(@zip).include(*args.empty? ? @files : args).invoke
412
485
  yield
413
486
  end
414
-
487
+
415
488
  it 'should touch target directory' do
416
489
  with_zip do
417
490
  mkdir @target
@@ -428,6 +501,20 @@ describe Unzip do
428
501
  end
429
502
  end
430
503
 
504
+ it 'should expand files from a tar.gz file' do
505
+ with_tar do
506
+ unzip(@target=>@targz).target.invoke
507
+ @files.each { |f| File.read(File.join(@target, File.basename(f))).should eql(content_for(f)) }
508
+ end
509
+ end
510
+
511
+ it 'should expand files from a .tgz file' do
512
+ with_tar_too do
513
+ unzip(@target=>@targz2).target.invoke
514
+ @files.each { |f| File.read(File.join(@target, File.basename(f))).should eql(content_for(f)) }
515
+ end
516
+ end
517
+
431
518
  it 'should expand all files' do
432
519
  with_zip do
433
520
  unzip(@target=>@zip).target.invoke
@@ -435,6 +522,13 @@ describe Unzip do
435
522
  end
436
523
  end
437
524
 
525
+ it 'should expand all files from a .tar.gz file' do
526
+ with_tar do
527
+ unzip(@target=>@targz).target.invoke
528
+ FileList[File.join(@target, '*')].size.should be(@files.size)
529
+ end
530
+ end
531
+
438
532
  it 'should expand only included files' do
439
533
  with_zip do
440
534
  only = File.basename(@files.first)
@@ -444,6 +538,15 @@ describe Unzip do
444
538
  end
445
539
  end
446
540
 
541
+ it 'should expand only included files from a .tar.gz file' do
542
+ with_tar do
543
+ only = File.basename(@files.first)
544
+ unzip(@target=>@targz).include(only).target.invoke
545
+ FileList[File.join(@target, '*')].should include(File.expand_path(only, @target))
546
+ FileList[File.join(@target, '*')].size.should be(1)
547
+ end
548
+ end
549
+
447
550
  it 'should expand all but excluded files' do
448
551
  with_zip do
449
552
  except = File.basename(@files.first)
@@ -453,6 +556,15 @@ describe Unzip do
453
556
  end
454
557
  end
455
558
 
559
+ it 'should expand all but excluded files with a .tar.gz file' do
560
+ with_tar do
561
+ except = File.basename(@files.first)
562
+ unzip(@target=>@targz).exclude(except).target.invoke
563
+ FileList[File.join(@target, '*')].should_not include(File.expand_path(except, @target))
564
+ FileList[File.join(@target, '*')].size.should be(@files.size - 1)
565
+ end
566
+ end
567
+
456
568
  it 'should include with nested path patterns' do
457
569
  with_zip @files, :path=>'test/path' do
458
570
  only = File.basename(@files.first)
@@ -469,6 +581,22 @@ describe Unzip do
469
581
  end
470
582
  end
471
583
 
584
+ it 'should include with nested path patterns with a .tar.gz file' do
585
+ with_tar @files, :path=>'test/path' do
586
+ only = File.basename(@files.first)
587
+ unzip(@target=>@targz).include(only).target.invoke
588
+ FileList[File.join(@target, '*')].should be_empty
589
+
590
+ Rake::Task.clear ; rm_rf @target
591
+ unzip(@target=>@targz).include('test/path/' + only).target.invoke
592
+ FileList[File.join(@target, 'test/path/*')].size.should be(1)
593
+
594
+ Rake::Task.clear ; rm_rf @target
595
+ unzip(@target=>@targz).include('test/**/*').target.invoke
596
+ FileList[File.join(@target, 'test/path/*')].size.should be(2)
597
+ end
598
+ end
599
+
472
600
  it 'should include with relative path' do
473
601
  with_zip @files, :path=>'test/path' do
474
602
  only = File.basename(@files.first)
@@ -488,7 +616,27 @@ describe Unzip do
488
616
  FileList[File.join(@target, 'path/*')].size.should be(2)
489
617
  end
490
618
  end
491
-
619
+
620
+ it 'should include with relative path with a .tar.gz file' do
621
+ with_tar @files, :path=>'test/path' do
622
+ only = File.basename(@files.first)
623
+ unzip(@target=>@targz).tap { |unzip| unzip.from_path('test').include(only) }.target.invoke
624
+ FileList[File.join(@target, '*')].should be_empty
625
+
626
+ Rake::Task.clear ; rm_rf @target
627
+ unzip(@target=>@targz).tap { |unzip| unzip.from_path('test').include('test/*') }.target.invoke
628
+ FileList[File.join(@target, 'path/*')].should be_empty
629
+
630
+ Rake::Task.clear ; rm_rf @target
631
+ unzip(@target=>@targz).tap { |unzip| unzip.from_path('test').include('path/*' + only) }.target.invoke
632
+ FileList[File.join(@target, 'path/*')].size.should be(1)
633
+
634
+ Rake::Task.clear ; rm_rf @target
635
+ unzip(@target=>@targz).tap { |unzip| unzip.from_path('test').include('path/*') }.target.invoke
636
+ FileList[File.join(@target, 'path/*')].size.should be(2)
637
+ end
638
+ end
639
+
492
640
  it 'should exclude with relative path' do
493
641
  with_zip @files, :path=>'test' do
494
642
  except = File.basename(@files.first)
@@ -498,6 +646,15 @@ describe Unzip do
498
646
  end
499
647
  end
500
648
 
649
+ it 'should exclude with relative path on a tar.gz file' do
650
+ with_tar @files, :path=>'test' do
651
+ except = File.basename(@files.first)
652
+ unzip(@target=>@targz).tap { |unzip| unzip.from_path('test').exclude(except) }.target.invoke
653
+ FileList[File.join(@target, '*')].should include(File.join(@target, File.basename(@files[1])))
654
+ FileList[File.join(@target, '*')].size.should be(@files.size - 1)
655
+ end
656
+ end
657
+
501
658
  it "should handle relative paths without any includes or excludes" do
502
659
  lib_files = %w{Test3.so Test4.rb}.
503
660
  map { |file| File.join(@dir, file) }.
@@ -508,6 +665,16 @@ describe Unzip do
508
665
  FileList[File.join(@target, '**/*')].should have(2).files
509
666
  end
510
667
 
668
+ it "should handle relative paths without any includes or excludes with a tar.gz file" do
669
+ lib_files = %w{Test3.so Test4.rb}.
670
+ map { |file| File.join(@dir, file) }.
671
+ each { |file| write file, content_for(file) }
672
+ tar(@targz).include(@files, :path => 'src').include(lib_files, :path => 'lib').invoke
673
+
674
+ unzip(@target=>@targz).tap { |unzip| unzip.from_path('lib') }.target.invoke
675
+ FileList[File.join(@target, '**/*')].should have(2).files
676
+ end
677
+
511
678
  it 'should return itself from root method' do
512
679
  task = unzip(@target=>@zip)
513
680
  task.root.should be(task)
@@ -26,46 +26,58 @@ describe Buildr::ArtifactNamespace do
26
26
  Object.send :remove_const, :A
27
27
  end
28
28
 
29
- describe '.root' do
29
+ describe '.root' do
30
30
  it 'should return the top level namespace' do
31
31
  Buildr::ArtifactNamespace.root.should be_root
32
32
  end
33
-
33
+
34
34
  it 'should yield the namespace if a block is given' do
35
- Buildr::ArtifactNamespace.root { |ns| ns.should be_root }
35
+ flag = false
36
+ Buildr::ArtifactNamespace.root { |ns| flag = true; ns.should be_root }
37
+ flag.should == true
38
+ end
39
+
40
+ it 'should return the root when used outside of a project definition' do
41
+ artifact_ns.should be_root
42
+ end
43
+
44
+ it 'should yield to a block when used outside of a project definition' do
45
+ flag = false
46
+ artifact_ns {|ns| flag = true; ns.should be_root}
47
+ flag.should == true
36
48
  end
37
49
  end
38
50
 
39
- describe '.instance' do
51
+ describe '.instance' do
40
52
  it 'should return the top level namespace when invoked outside a project definition' do
41
53
  artifact_ns.should be_root
42
54
  end
43
55
 
44
- it 'should return the namespace for the receiving project' do
56
+ it 'should return the namespace for the receiving project' do
45
57
  define('foo') { }
46
58
  project('foo').artifact_ns.name.should == 'foo'
47
59
  end
48
-
60
+
49
61
  it 'should return the current project namespace when invoked inside a project' do
50
62
  define 'foo' do
51
63
  artifact_ns.should_not be_root
52
64
  artifact_ns.name.should == 'foo'
53
- task :doit do
65
+ task :doit do
54
66
  artifact_ns.should_not be_root
55
67
  artifact_ns.name.should == 'foo'
56
68
  end.invoke
57
69
  end
58
70
  end
59
-
71
+
60
72
  it 'should return the root namespace if given :root' do
61
73
  artifact_ns(:root).should be_root
62
74
  end
63
-
64
- it 'should return the namespace for the given name' do
75
+
76
+ it 'should return the namespace for the given name' do
65
77
  artifact_ns(:foo).name.should == 'foo'
66
78
  artifact_ns('foo:bar').name.should == 'foo:bar'
67
79
  artifact_ns(['foo', 'bar', 'baz']).name.should == 'foo:bar:baz'
68
- abc_module do
80
+ abc_module do
69
81
  artifact_ns(A::B::C).name.should == 'A::B::C'
70
82
  end
71
83
  artifact_ns(:root).should be_root
@@ -79,12 +91,12 @@ describe Buildr::ArtifactNamespace do
79
91
  end
80
92
  end
81
93
 
82
- describe '#parent' do
83
- it 'should be nil for root namespace' do
94
+ describe '#parent' do
95
+ it 'should be nil for root namespace' do
84
96
  artifact_ns(:root).parent.should be_nil
85
97
  end
86
-
87
- it 'should be the parent namespace for nested modules' do
98
+
99
+ it 'should be the parent namespace for nested modules' do
88
100
  abc_module do
89
101
  artifact_ns(A::B::C).parent.should == artifact_ns(A::B)
90
102
  artifact_ns(A::B).parent.should == artifact_ns(A)
@@ -93,8 +105,8 @@ describe Buildr::ArtifactNamespace do
93
105
  end
94
106
 
95
107
  it 'should be the parent namespace for nested projects' do
96
- define 'a' do
97
- define 'b' do
108
+ define 'a' do
109
+ define 'b' do
98
110
  define 'c' do
99
111
  artifact_ns.parent.should == artifact_ns(parent)
100
112
  end
@@ -104,9 +116,9 @@ describe Buildr::ArtifactNamespace do
104
116
  end
105
117
  end
106
118
  end
107
-
119
+
108
120
  describe '#parent=' do
109
- it 'should reject to set parent for root namespace' do
121
+ it 'should reject to set parent for root namespace' do
110
122
  lambda { artifact_ns(:root).parent = :foo }.should raise_error(Exception, /cannot set parent/i)
111
123
  end
112
124
 
@@ -118,10 +130,10 @@ describe Buildr::ArtifactNamespace do
118
130
  end
119
131
 
120
132
  it 'should allow to set parent to :current' do
121
- abc_module do
133
+ abc_module do
122
134
  mod = A::B
123
135
  artifact_ns(mod).parent = :current
124
- def mod.stuff
136
+ def mod.stuff
125
137
  Buildr::artifact_ns(self)
126
138
  end
127
139
  define 'a' do
@@ -133,14 +145,14 @@ describe Buildr::ArtifactNamespace do
133
145
  end
134
146
  end
135
147
  end
136
-
137
- describe '#need' do
148
+
149
+ describe '#need' do
138
150
  it 'should accept an artifact spec' do
139
151
  define 'one' do
140
152
  artifact_ns.need 'a:b:c:1'
141
153
  # referenced by spec
142
154
  artifact_ns['a:b:c'].should_not be_selected
143
-
155
+
144
156
  # referenced by name
145
157
  artifact_ns[:b].should_not be_selected
146
158
  artifact_ns[:b].should be_satisfied_by('a:b:c:1')
@@ -155,7 +167,7 @@ describe Buildr::ArtifactNamespace do
155
167
  artifact_ns.need 'thing -> a:b:c:2.1 -> ~>2.0'
156
168
  # referenced by spec
157
169
  artifact_ns['a:b:c'].should_not be_selected
158
-
170
+
159
171
  # referenced by name
160
172
  artifact_ns.key?(:b).should be_false
161
173
  artifact_ns[:thing].should_not be_selected
@@ -165,7 +177,7 @@ describe Buildr::ArtifactNamespace do
165
177
  end
166
178
  end
167
179
 
168
- it 'should accept a hash :name -> requirement_spec' do
180
+ it 'should accept a hash :name -> requirement_spec' do
169
181
  define 'one' do
170
182
  artifact_ns.need :thing => 'a:b:c:2.1 -> ~>2.0'
171
183
  artifact_ns[:thing].should be_satisfied_by('a:b:c:2.5')
@@ -181,8 +193,8 @@ describe Buildr::ArtifactNamespace do
181
193
  end
182
194
  end
183
195
 
184
- it 'should take a hash :name -> specs_array' do
185
- define 'one' do
196
+ it 'should take a hash :name -> specs_array' do
197
+ define 'one' do
186
198
  artifact_ns.need :things => ['foo:bar:jar:1.0',
187
199
  'foo:baz:jar:2.0',]
188
200
  artifact_ns['foo:bar:jar'].should_not be_selected
@@ -194,8 +206,8 @@ describe Buildr::ArtifactNamespace do
194
206
  end
195
207
  end
196
208
 
197
- it 'should select best matching version if defined' do
198
- define 'one' do
209
+ it 'should select best matching version if defined' do
210
+ define 'one' do
199
211
  artifact_ns.use :a => 'foo:bar:jar:1.5'
200
212
  artifact_ns.use :b => 'foo:baz:jar:2.0'
201
213
  define 'two' do
@@ -205,7 +217,7 @@ describe Buildr::ArtifactNamespace do
205
217
  artifact_ns.need :c => 'foo:bat:jar:3.0'
206
218
  artifact_ns['foo:bat:jar'].should_not be_selected
207
219
  artifact_ns[:c].should_not be_selected
208
-
220
+
209
221
  artifact_ns.need :one => 'foo:bar:jar:>=1.0'
210
222
  artifact_ns[:one].version.should == '1.5'
211
223
  artifact_ns[:one].should be_selected
@@ -220,7 +232,7 @@ describe Buildr::ArtifactNamespace do
220
232
  end
221
233
  end
222
234
 
223
- describe '#use' do
235
+ describe '#use' do
224
236
  it 'should register the artifact on namespace' do
225
237
  define 'one' do
226
238
  artifact_ns.use :thing => 'a:b:c:1'
@@ -232,7 +244,7 @@ describe Buildr::ArtifactNamespace do
232
244
  artifact_ns[:thing].requirement.should be_nil
233
245
  artifact_ns[:thing].version.should == '2'
234
246
  artifact_ns[:thing].id.should == 'd'
235
-
247
+
236
248
  artifact_ns.use :copied => artifact_ns.parent[:thing]
237
249
  artifact_ns[:copied].should_not == artifact_ns.parent[:thing]
238
250
  artifact_ns[:copied].requirement.should be_nil
@@ -258,7 +270,7 @@ describe Buildr::ArtifactNamespace do
258
270
  artifact_ns['a:b:c'].version.should == '2'
259
271
  end
260
272
  end
261
-
273
+
262
274
  it 'should complain if namespace requirement is not satisfied' do
263
275
  define 'one' do
264
276
  artifact_ns.need :bar => 'foo:bar:baz:~>1.5'
@@ -266,7 +278,7 @@ describe Buildr::ArtifactNamespace do
266
278
  end
267
279
  end
268
280
 
269
- it 'should be able to register a group' do
281
+ it 'should be able to register a group' do
270
282
  specs = ['its:me:here:1', 'its:you:there:2']
271
283
  artifact_ns.use :them => specs
272
284
  artifact_ns[:them].map(&:to_spec).should == specs
@@ -274,7 +286,7 @@ describe Buildr::ArtifactNamespace do
274
286
  artifact_ns[:you].should be_nil
275
287
  end
276
288
 
277
- it 'should be able to assign sub namespaces' do
289
+ it 'should be able to assign sub namespaces' do
278
290
  artifact_ns(:foo).bar = "foo:bar:baz:0"
279
291
  artifact_ns(:moo).foo = artifact_ns(:foo)
280
292
  artifact_ns(:moo).foo.should == artifact_ns(:foo)
@@ -289,15 +301,22 @@ describe Buildr::ArtifactNamespace do
289
301
  end
290
302
  end
291
303
 
304
+ it 'should handle version string' do
305
+ foo = artifact_ns do |ns|
306
+ ns.bar = 'a:b:c:1'
307
+ end
308
+ foo.use :bar => '2.0'
309
+ foo.bar.version.should == '2.0'
310
+ end
292
311
  end
293
312
 
294
- describe '#values' do
295
- it 'returns the artifacts defined on namespace' do
313
+ describe '#values' do
314
+ it 'returns the artifacts defined on namespace' do
296
315
  define 'foo' do
297
316
  artifact_ns.use 'foo:one:baz:1.0'
298
317
  define 'bar' do
299
318
  artifact_ns.use 'foo:two:baz:1.0'
300
-
319
+
301
320
  specs = artifact_ns.values.map(&:to_spec)
302
321
  specs.should include('foo:two:baz:1.0')
303
322
  specs.should_not include('foo:one:baz:1.0')
@@ -309,13 +328,13 @@ describe Buildr::ArtifactNamespace do
309
328
  end
310
329
  end
311
330
 
312
- describe '#values_at' do
313
- it 'returns the named artifacts' do
331
+ describe '#values_at' do
332
+ it 'returns the named artifacts' do
314
333
  define 'foo' do
315
334
  artifact_ns.use 'foo:one:baz:1.0'
316
335
  define 'bar' do
317
336
  artifact_ns.use :foo_baz => 'foo:two:baz:1.0'
318
-
337
+
319
338
  specs = artifact_ns.values_at('one').map(&:to_spec)
320
339
  specs.should include('foo:one:baz:1.0')
321
340
  specs.should_not include('foo:two:baz:1.0')
@@ -332,7 +351,7 @@ describe Buildr::ArtifactNamespace do
332
351
  artifact_ns.use 'foo:one:baz:2.0'
333
352
  define 'bar' do
334
353
  artifact_ns.use :older => 'foo:one:baz:1.0'
335
-
354
+
336
355
  specs = artifact_ns.values_at('foo:one:baz').map(&:to_spec)
337
356
  specs.should include('foo:one:baz:1.0')
338
357
  specs.should_not include('foo:one:baz:2.0')
@@ -348,7 +367,7 @@ describe Buildr::ArtifactNamespace do
348
367
  artifact_ns.use 'foo:one:baz:2.0'
349
368
  define 'bar' do
350
369
  artifact_ns.use :older => 'foo:one:baz:1.0'
351
-
370
+
352
371
  specs = artifact_ns.values_at('foo:one:baz:>1.0').map(&:to_spec)
353
372
  specs.should include('foo:one:baz:2.0')
354
373
  specs.should_not include('foo:one:baz:1.0')
@@ -356,14 +375,57 @@ describe Buildr::ArtifactNamespace do
356
375
  end
357
376
  end
358
377
  end
359
-
360
- describe '#method_missing' do
361
- it 'should use cool_aid! to create a requirement' do
378
+
379
+ describe '#artifacts' do
380
+ it 'returns artifacts in namespace' do
381
+ define 'one' do
382
+ artifact_ns[:foo] = 'group:foo:jar:1'
383
+ artifact_ns[:bar] = 'group:bar:jar:1'
384
+ artifact_ns.artifacts.map{|a| a.to_spec}.should include('group:foo:jar:1', 'group:bar:jar:1')
385
+ end
386
+ end
387
+ end
388
+
389
+ describe '#keys' do
390
+ it 'returns names in namespace' do
391
+ define 'one' do
392
+ artifact_ns[:foo] = 'group:foo:jar:1'
393
+ artifact_ns[:bar] = 'group:bar:jar:1'
394
+ artifact_ns.keys.should include('foo', 'bar')
395
+ end
396
+ end
397
+ end
398
+
399
+ describe '#delete' do
400
+ it 'deletes corresponding artifact requirement' do
401
+ define 'one' do
402
+ artifact_ns[:foo] = 'group:foo:jar:1'
403
+ artifact_ns[:bar] = 'group:bar:jar:1'
404
+ artifact_ns.delete :bar
405
+ artifact_ns.artifacts.map{|a| a.to_spec}.should include('group:foo:jar:1')
406
+ artifact_ns[:foo].to_spec.should eql('group:foo:jar:1')
407
+ end
408
+ end
409
+ end
410
+
411
+ describe '#clear' do
412
+ it 'clears all artifact requirements in namespace' do
413
+ define 'one' do
414
+ artifact_ns[:foo] = 'group:foo:jar:1'
415
+ artifact_ns[:bar] = 'group:bar:jar:1'
416
+ artifact_ns.clear
417
+ artifact_ns.artifacts.should be_empty
418
+ end
419
+ end
420
+ end
421
+
422
+ describe '#method_missing' do
423
+ it 'should use cool_aid! to create a requirement' do
362
424
  define 'foo' do
363
425
  artifact_ns.cool_aid!('cool:aid:jar:2').should be_kind_of(ArtifactNamespace::ArtifactRequirement)
364
426
  artifact_ns[:cool_aid].version.should == '2'
365
427
  artifact_ns[:cool_aid].should_not be_selected
366
- define 'bar' do
428
+ define 'bar' do
367
429
  artifact_ns.cool_aid! 'cool:aid:man:3', '>2'
368
430
  artifact_ns[:cool_aid].version.should == '3'
369
431
  artifact_ns[:cool_aid].requirement.should be_satisfied_by('2.5')
@@ -372,11 +434,11 @@ describe Buildr::ArtifactNamespace do
372
434
  end
373
435
  end
374
436
 
375
- it 'should use cool_aid= as shorhand for [:cool_aid]=' do
437
+ it 'should use cool_aid= as shorhand for [:cool_aid]=' do
376
438
  artifact_ns.cool_aid = 'cool:aid:jar:1'
377
439
  artifact_ns[:cool_aid].should be_selected
378
440
  end
379
-
441
+
380
442
  it 'should use cool_aid as shorthand for [:cool_aid]' do
381
443
  artifact_ns.need :cool_aid => 'cool:aid:jar:1'
382
444
  artifact_ns.cool_aid.should_not be_selected
@@ -391,25 +453,25 @@ describe Buildr::ArtifactNamespace do
391
453
  end
392
454
  end
393
455
 
394
- describe '#ns' do
456
+ describe '#ns' do
395
457
  it 'should create a sub namespace' do
396
458
  artifact_ns.ns :foo
397
459
  artifact_ns[:foo].should be_kind_of(ArtifactNamespace)
398
460
  artifact_ns(:foo).should_not === artifact_ns.foo
399
461
  artifact_ns.foo.parent.should == artifact_ns
400
462
  end
401
-
463
+
402
464
  it 'should take any use arguments' do
403
465
  artifact_ns.ns :foo, :bar => 'foo:bar:jar:0', :baz => 'foo:baz:jar:0'
404
466
  artifact_ns.foo.bar.should be_selected
405
467
  artifact_ns.foo[:baz].should be_selected
406
468
  end
407
-
408
- it 'should access sub artifacts using with foo_bar like syntax' do
469
+
470
+ it 'should access sub artifacts using with foo_bar like syntax' do
409
471
  artifact_ns.ns :foo, :bar => 'foo:bar:jar:0', :baz => 'foo:baz:jar:0'
410
472
  artifact_ns[:foo_baz].should be_selected
411
473
  artifact_ns.foo_bar.should be_selected
412
-
474
+
413
475
  artifact_ns.foo.ns :bat, 'bat:man:jar:>1'
414
476
  batman = artifact_ns.foo.bat.man
415
477
  batman.should be_selected
@@ -418,7 +480,7 @@ describe Buildr::ArtifactNamespace do
418
480
  artifact_ns[:foo_bat_man].version.should == '3'
419
481
  end
420
482
 
421
- it 'should include sub artifacts when calling #values' do
483
+ it 'should include sub artifacts when calling #values' do
422
484
  artifact_ns.ns :bat, 'bat:man:jar:>1'
423
485
  artifact_ns.values.should_not be_empty
424
486
  artifact_ns.values.first.unversioned_spec.should == 'bat:man:jar'
@@ -435,13 +497,13 @@ describe Buildr::ArtifactNamespace do
435
497
  lambda { artifact_ns.ns(:foo) }.should raise_error(TypeError, /not a sub/i)
436
498
  end
437
499
 
438
- it 'should clone artifacts when assigned' do
500
+ it 'should clone artifacts when assigned' do
439
501
  artifact_ns(:foo).bar = "foo:bar:jar:0"
440
502
  artifact_ns(:moo).ns :muu, :miu => artifact_ns(:foo).bar
441
503
  artifact_ns(:moo).muu.miu.should_not == artifact_ns(:foo).bar
442
504
  artifact_ns(:moo).muu.miu.to_spec.should == artifact_ns(:foo).bar.to_spec
443
505
  end
444
-
506
+
445
507
  it 'should clone parent artifacts by name' do
446
508
  define 'foo' do
447
509
  artifact_ns.bar = "foo:bar:jar:0"
@@ -462,12 +524,39 @@ describe Buildr::ArtifactNamespace do
462
524
 
463
525
  end # ArtifactNamespace
464
526
 
527
+ describe Buildr::ArtifactNamespace::ArtifactRequirement do
528
+ before(:each) { Buildr::ArtifactNamespace.clear }
529
+ it 'should be created from artifact_ns' do
530
+ foo = artifact_ns do |ns|
531
+ ns.bar = 'a:b:c:1.0'
532
+ end
533
+ foo.bar.should be_kind_of(ArtifactNamespace::ArtifactRequirement)
534
+ end
535
+
536
+ it 'should handle version as string' do
537
+ foo = artifact_ns do |ns|
538
+ ns.bar = 'a:b:c:1.0'
539
+ end
540
+ foo.bar.version = '2.0'
541
+ foo.bar.version.should == '2.0'
542
+ end
543
+
544
+ it 'should handle version string directly' do
545
+ foo = artifact_ns do |ns|
546
+ ns.bar = 'a:b:c:1.0'
547
+ end
548
+ foo.bar = '2.0'
549
+ foo.bar.version.should == '2.0'
550
+ end
551
+
552
+ end # ArtifactRequirement
553
+
465
554
  describe Buildr do
466
555
  before(:each) { Buildr::ArtifactNamespace.clear }
467
556
 
468
- describe '.artifacts' do
557
+ describe '.artifacts' do
469
558
  it 'should take ruby symbols and ask the current namespace for them' do
470
- define 'foo' do
559
+ define 'foo' do
471
560
  artifact_ns.cool = 'cool:aid:jar:1.0'
472
561
  artifact_ns.use 'some:other:jar:1.0'
473
562
  artifact_ns.use 'bat:man:jar:1.0'
@@ -475,8 +564,8 @@ describe Buildr do
475
564
  compile.dependencies.map(&:to_spec).should include('cool:aid:jar:1.0', 'some:other:jar:1.0', 'bat:man:jar:1.0')
476
565
  end
477
566
  end
478
-
479
- it 'should take a namespace' do
567
+
568
+ it 'should take a namespace' do
480
569
  artifact_ns(:moo).muu = 'moo:muu:jar:1.0'
481
570
  define 'foo' do
482
571
  compile.with artifact_ns(:moo)
@@ -484,28 +573,28 @@ describe Buildr do
484
573
  end
485
574
  end
486
575
  end
487
-
576
+
488
577
  describe '.artifact' do
489
- it 'should search current namespace if given a symbol' do
490
- define 'foo' do
578
+ it 'should search current namespace if given a symbol' do
579
+ define 'foo' do
491
580
  artifact_ns.use :cool => 'cool:aid:jar:1.0'
492
581
  define 'bar' do
493
582
  artifact(:cool).should == artifact_ns[:cool].artifact
494
583
  end
495
584
  end
496
585
  end
497
-
498
- it 'should search current namespace if given a symbol spec' do
499
- define 'foo' do
586
+
587
+ it 'should search current namespace if given a symbol spec' do
588
+ define 'foo' do
500
589
  artifact_ns.use 'cool:aid:jar:1.0'
501
590
  define 'bar' do
502
591
  artifact(:'cool:aid:jar').should == artifact_ns[:aid].artifact
503
592
  end
504
593
  end
505
594
  end
506
-
595
+
507
596
  it 'should fail when no artifact by that name is found' do
508
- define 'foo' do
597
+ define 'foo' do
509
598
  artifact_ns.use 'cool:aid:jar:1.0'
510
599
  define 'bar' do
511
600
  lambda { artifact(:cool) }.should raise_error(IndexError, /artifact/)
@@ -524,12 +613,12 @@ describe "Extension using ArtifactNamespace" do
524
613
  ensure
525
614
  Object.send :remove_const, :A
526
615
  end
527
-
616
+
528
617
  it 'can register namespace listeners' do
529
618
  abc_module do
530
619
  # An example extension to illustrate namespace listeners and method forwarding
531
620
  class A::Example
532
-
621
+
533
622
  module Ext
534
623
  include Buildr::Extension
535
624
  def example; @example ||= A::Example.new; end
@@ -537,22 +626,22 @@ describe "Extension using ArtifactNamespace" do
537
626
  Rake::Task.define_task('example') { p.example.doit }
538
627
  end
539
628
  end
540
-
629
+
541
630
  REQUIRES = ArtifactNamespace.for(self) do |ns|
542
631
  ns.xmlbeans! 'org.apache.xmlbeans:xmlbeans:jar:2.3.0', '>2'
543
632
  ns.stax_api! 'stax:stax-api:jar:>=1.0.1'
544
633
  end
545
634
 
546
635
  attr_reader :options, :requires
547
-
636
+
548
637
  def initialize
549
638
  # We could actually use the REQUIRES namespace, but to make things
550
- # a bit more interesting, suppose each Example instance can have its
639
+ # a bit more interesting, suppose each Example instance can have its
551
640
  # own artifact requirements in adition to those specified on REQUIRES.
552
641
  # To achieve this we create an anonymous namespace.
553
642
  @requires = ArtifactNamespace.new # a namespace per instance
554
643
  REQUIRES.each { |requirement| @requires.need requirement }
555
-
644
+
556
645
  # For user convenience, we make the options object respond to
557
646
  # :xmlbeans, :xmlbeans=, :xmlbeans?
558
647
  # forwarding them to the namespace.
@@ -573,7 +662,7 @@ describe "Extension using ArtifactNamespace" do
573
662
  end
574
663
 
575
664
  include Spec::Matchers # for assertions
576
-
665
+
577
666
  # Called with the ArtifactRequirement that has just been selected
578
667
  # by a user. This allows extension author to selectively perform
579
668
  # some action by inspecting the requirement state.
@@ -591,20 +680,20 @@ describe "Extension using ArtifactNamespace" do
591
680
  # Now call ant task with our selected artifact and options
592
681
  classpath = requires.map(&:artifact).map(&:to_s).join(File::PATH_SEPARATOR)
593
682
  lambda { ant('thing') { |ant| ant.classpath classpath, :math => options[:math] } }
594
-
683
+
595
684
  # We are not a Project instance, hence we have no artifact_ns
596
685
  lambda { artifact_ns }.should raise_error(NameError)
597
686
 
598
687
  # Extension authors may NOT rely project's namespaces.
599
- # However the ruby-way gives you power and at the same time
688
+ # However the ruby-way gives you power and at the same time
600
689
  # makes you dangerous, (think open-modules, monkey-patching)
601
690
  # Given that buildr is pure ruby, consider it a sharp-edged sword.
602
- # Having said that, you may actually inspect a project's
691
+ # Having said that, you may actually inspect a project's
603
692
  # namespace, but don't write on it without letting your users
604
693
  # know you will.
605
694
  # This example obtains the current project namespace to make
606
695
  # some assertions.
607
-
696
+
608
697
  # To obtain a project's namespace we need either
609
698
  # 1) a reference to the project, and call artifact_ns on it
610
699
  # project.artifact_ns # the namespace for project
@@ -627,7 +716,7 @@ describe "Extension using ArtifactNamespace" do
627
716
  end
628
717
  end
629
718
  end
630
-
719
+
631
720
  define 'foo' do
632
721
  define 'bar' do
633
722
  extend A::Example::Ext
@@ -643,7 +732,7 @@ describe "Extension using ArtifactNamespace" do
643
732
 
644
733
  project('foo:bar').example.requires.should_not == project('foo:baz').example.requires
645
734
  project('foo:bar').example.requires.xmlbeans.should_not == project('foo:baz').example.requires.xmlbeans
646
-
735
+
647
736
  # current namespace outside a project is :root, see the stax callback
648
737
  project('foo:baz').example.options.stax_api = '1.6180'
649
738
  # we call the task outside the project, see #doit