ittayd-buildr 1.3.4 → 1.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (169) hide show
  1. data/CHANGELOG +62 -9
  2. data/NOTICE +1 -1
  3. data/README.rdoc +9 -21
  4. data/Rakefile +20 -39
  5. data/_buildr +1 -0
  6. data/{spec/java/ant.rb → _jbuildr} +11 -15
  7. metadata +30 -210
  8. data/DISCLAIMER +0 -7
  9. data/addon/buildr/antlr.rb +0 -65
  10. data/addon/buildr/cobertura.rb +0 -22
  11. data/addon/buildr/drb.rb +0 -281
  12. data/addon/buildr/emma.rb +0 -22
  13. data/addon/buildr/hibernate.rb +0 -142
  14. data/addon/buildr/javacc.rb +0 -85
  15. data/addon/buildr/jdepend.rb +0 -60
  16. data/addon/buildr/jetty.rb +0 -248
  17. data/addon/buildr/jibx.rb +0 -86
  18. data/addon/buildr/nailgun.rb +0 -221
  19. data/addon/buildr/openjpa.rb +0 -90
  20. data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
  21. data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
  22. data/addon/buildr/org/apache/buildr/BuildrNail.java +0 -41
  23. data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  24. data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  25. data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  26. data/addon/buildr/org/apache/buildr/JettyWrapper.java +0 -144
  27. data/addon/buildr/path.rb +0 -136
  28. data/addon/buildr/xmlbeans.rb +0 -93
  29. data/buildr.buildfile +0 -53
  30. data/buildr.gemspec +0 -58
  31. data/doc/css/default.css +0 -228
  32. data/doc/css/print.css +0 -100
  33. data/doc/css/syntax.css +0 -52
  34. data/doc/images/apache-incubator-logo.png +0 -0
  35. data/doc/images/buildr-hires.png +0 -0
  36. data/doc/images/buildr.png +0 -0
  37. data/doc/images/favicon.png +0 -0
  38. data/doc/images/growl-icon.tiff +0 -0
  39. data/doc/images/note.png +0 -0
  40. data/doc/images/project-structure.png +0 -0
  41. data/doc/images/tip.png +0 -0
  42. data/doc/images/zbuildr.tif +0 -0
  43. data/doc/pages/artifacts.textile +0 -207
  44. data/doc/pages/building.textile +0 -240
  45. data/doc/pages/contributing.textile +0 -208
  46. data/doc/pages/download.textile +0 -62
  47. data/doc/pages/extending.textile +0 -175
  48. data/doc/pages/getting_started.textile +0 -273
  49. data/doc/pages/index.textile +0 -42
  50. data/doc/pages/languages.textile +0 -407
  51. data/doc/pages/mailing_lists.textile +0 -17
  52. data/doc/pages/more_stuff.textile +0 -314
  53. data/doc/pages/packaging.textile +0 -427
  54. data/doc/pages/projects.textile +0 -274
  55. data/doc/pages/recipes.textile +0 -103
  56. data/doc/pages/settings_profiles.textile +0 -274
  57. data/doc/pages/testing.textile +0 -212
  58. data/doc/pages/troubleshooting.textile +0 -103
  59. data/doc/pages/whats_new.textile +0 -323
  60. data/doc/print.haml +0 -51
  61. data/doc/print.toc.yaml +0 -29
  62. data/doc/scripts/buildr-git.rb +0 -412
  63. data/doc/scripts/install-jruby.sh +0 -44
  64. data/doc/scripts/install-linux.sh +0 -64
  65. data/doc/scripts/install-osx.sh +0 -52
  66. data/doc/site.haml +0 -56
  67. data/doc/site.toc.yaml +0 -47
  68. data/etc/KEYS +0 -151
  69. data/etc/git-svn-authors +0 -16
  70. data/lib/buildr.rb +0 -33
  71. data/lib/buildr/core.rb +0 -29
  72. data/lib/buildr/core/application.rb +0 -665
  73. data/lib/buildr/core/build.rb +0 -311
  74. data/lib/buildr/core/checks.rb +0 -254
  75. data/lib/buildr/core/common.rb +0 -150
  76. data/lib/buildr/core/compile.rb +0 -590
  77. data/lib/buildr/core/environment.rb +0 -117
  78. data/lib/buildr/core/filter.rb +0 -366
  79. data/lib/buildr/core/generate.rb +0 -195
  80. data/lib/buildr/core/help.rb +0 -119
  81. data/lib/buildr/core/osx.rb +0 -49
  82. data/lib/buildr/core/progressbar.rb +0 -156
  83. data/lib/buildr/core/project.rb +0 -923
  84. data/lib/buildr/core/test.rb +0 -715
  85. data/lib/buildr/core/transports.rb +0 -560
  86. data/lib/buildr/core/util.rb +0 -294
  87. data/lib/buildr/groovy.rb +0 -18
  88. data/lib/buildr/groovy/bdd.rb +0 -106
  89. data/lib/buildr/groovy/compiler.rb +0 -138
  90. data/lib/buildr/ide.rb +0 -19
  91. data/lib/buildr/ide/eclipse.rb +0 -222
  92. data/lib/buildr/ide/idea.ipr.template +0 -300
  93. data/lib/buildr/ide/idea.rb +0 -190
  94. data/lib/buildr/ide/idea7x.ipr.template +0 -290
  95. data/lib/buildr/ide/idea7x.rb +0 -212
  96. data/lib/buildr/java.rb +0 -23
  97. data/lib/buildr/java/ant.rb +0 -92
  98. data/lib/buildr/java/bdd.rb +0 -451
  99. data/lib/buildr/java/cobertura.rb +0 -236
  100. data/lib/buildr/java/commands.rb +0 -211
  101. data/lib/buildr/java/compiler.rb +0 -348
  102. data/lib/buildr/java/deprecated.rb +0 -141
  103. data/lib/buildr/java/emma.rb +0 -238
  104. data/lib/buildr/java/jruby.rb +0 -117
  105. data/lib/buildr/java/jtestr_runner.rb.erb +0 -116
  106. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  107. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +0 -119
  108. data/lib/buildr/java/packaging.rb +0 -717
  109. data/lib/buildr/java/pom.rb +0 -174
  110. data/lib/buildr/java/rjb.rb +0 -155
  111. data/lib/buildr/java/test_result.rb +0 -307
  112. data/lib/buildr/java/tests.rb +0 -329
  113. data/lib/buildr/java/version_requirement.rb +0 -172
  114. data/lib/buildr/packaging.rb +0 -24
  115. data/lib/buildr/packaging/archive.rb +0 -488
  116. data/lib/buildr/packaging/artifact.rb +0 -759
  117. data/lib/buildr/packaging/artifact_namespace.rb +0 -972
  118. data/lib/buildr/packaging/artifact_search.rb +0 -140
  119. data/lib/buildr/packaging/gems.rb +0 -102
  120. data/lib/buildr/packaging/package.rb +0 -233
  121. data/lib/buildr/packaging/tar.rb +0 -186
  122. data/lib/buildr/packaging/version_requirement.rb +0 -172
  123. data/lib/buildr/packaging/zip.rb +0 -64
  124. data/lib/buildr/packaging/ziptask.rb +0 -313
  125. data/lib/buildr/resources/buildr.icns +0 -0
  126. data/lib/buildr/scala.rb +0 -19
  127. data/lib/buildr/scala/compiler.rb +0 -109
  128. data/lib/buildr/scala/tests.rb +0 -203
  129. data/rakelib/apache.rake +0 -191
  130. data/rakelib/changelog.rake +0 -57
  131. data/rakelib/doc.rake +0 -103
  132. data/rakelib/package.rake +0 -76
  133. data/rakelib/release.rake +0 -65
  134. data/rakelib/rspec.rake +0 -83
  135. data/rakelib/rubyforge.rake +0 -56
  136. data/rakelib/scm.rake +0 -49
  137. data/rakelib/setup.rake +0 -81
  138. data/rakelib/stage.rake +0 -48
  139. data/spec/addon/drb_spec.rb +0 -328
  140. data/spec/core/application_spec.rb +0 -419
  141. data/spec/core/build_spec.rb +0 -423
  142. data/spec/core/checks_spec.rb +0 -519
  143. data/spec/core/common_spec.rb +0 -670
  144. data/spec/core/compile_spec.rb +0 -582
  145. data/spec/core/generate_spec.rb +0 -33
  146. data/spec/core/project_spec.rb +0 -776
  147. data/spec/core/test_spec.rb +0 -1098
  148. data/spec/core/transport_spec.rb +0 -500
  149. data/spec/groovy/bdd_spec.rb +0 -80
  150. data/spec/groovy/compiler_spec.rb +0 -239
  151. data/spec/ide/eclipse_spec.rb +0 -311
  152. data/spec/java/bdd_spec.rb +0 -358
  153. data/spec/java/cobertura_spec.rb +0 -77
  154. data/spec/java/compiler_spec.rb +0 -446
  155. data/spec/java/emma_spec.rb +0 -120
  156. data/spec/java/java_spec.rb +0 -96
  157. data/spec/java/packaging_spec.rb +0 -1120
  158. data/spec/java/test_coverage_spec.rb +0 -255
  159. data/spec/java/tests_spec.rb +0 -471
  160. data/spec/packaging/archive_spec.rb +0 -503
  161. data/spec/packaging/artifact_namespace_spec.rb +0 -646
  162. data/spec/packaging/artifact_spec.rb +0 -795
  163. data/spec/packaging/packaging_helper.rb +0 -63
  164. data/spec/packaging/packaging_spec.rb +0 -589
  165. data/spec/sandbox.rb +0 -139
  166. data/spec/scala/compiler_spec.rb +0 -228
  167. data/spec/scala/tests_spec.rb +0 -215
  168. data/spec/spec_helpers.rb +0 -327
  169. data/spec/version_requirement_spec.rb +0 -123
@@ -1,670 +0,0 @@
1
- # Licensed to the Apache Software Foundation (ASF) under one or more
2
- # contributor license agreements. See the NOTICE file distributed with this
3
- # work for additional information regarding copyright ownership. The ASF
4
- # licenses this file to you under the Apache License, Version 2.0 (the
5
- # "License"); you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
- # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
- # License for the specific language governing permissions and limitations under
14
- # the License.
15
-
16
-
17
- require File.join(File.dirname(__FILE__), '../spec_helpers')
18
-
19
- describe Buildr.method(:struct) do
20
- before do
21
- @hash = { :foo=>'foo:jar', :bar=>'bar:jar' }
22
- @struct = struct(@hash)
23
- end
24
-
25
- it 'should be object with key-value pairs' do
26
- @struct.foo.should eql('foo:jar')
27
- @struct.bar.should eql('bar:jar')
28
- end
29
-
30
- it 'should fail when requesting non-existent key' do
31
- lambda { @struct.foobar }.should raise_error(NoMethodError)
32
- end
33
-
34
- it 'should return members when requested' do
35
- @struct.members.sort.should eql(@hash.keys.map(&:to_s).sort)
36
- end
37
-
38
- it 'should return valued when requested' do
39
- @struct.values.sort.should eql(@hash.values.sort)
40
- end
41
- end
42
-
43
-
44
- describe Buildr.method(:write) do
45
- it 'should create path' do
46
- write 'foo/test'
47
- File.directory?('foo').should be_true
48
- File.exist?('foo/test').should be_true
49
- end
50
-
51
- it 'should write content to file' do
52
- write 'test', 'content'
53
- File.read('test').should eql('content')
54
- end
55
-
56
- it 'should retrieve content from block, if block given' do
57
- write('test') { 'block' }
58
- File.read('test').should eql('block')
59
- end
60
-
61
- it 'should write empty file if no content provided' do
62
- write 'test'
63
- File.read('test').should eql('')
64
- end
65
-
66
- it 'should return content as a string' do
67
- write('test', 'content').should eql('content')
68
- end
69
-
70
- it 'should return empty string if no content provided' do
71
- write('test').should eql('')
72
- end
73
- end
74
-
75
-
76
- describe Buildr.method(:read) do
77
- before do
78
- write @file = 'test', @content = 'content'
79
- end
80
-
81
- it 'should return contents of named file' do
82
- read(@file).should eql(@content)
83
- end
84
-
85
- it 'should yield to block if block given' do
86
- read @file do |content|
87
- content.should eql(@content)
88
- end
89
- end
90
-
91
- it 'should return block response if block given' do
92
- read(@file) { 5 }.should be(5)
93
- end
94
- end
95
-
96
-
97
- describe Buildr.method(:download) do
98
- before do
99
- @content = 'we has download!'
100
- @http = mock('http')
101
- @http.stub!(:request).and_return(Net::HTTPNotModified.new(nil, nil, nil))
102
- end
103
-
104
- def tasks()
105
- [ download('http://localhost/download'), download('downloaded'=>'http://localhost/download') ]
106
- end
107
-
108
- it 'should be a file task' do
109
- tasks.each { |task| task.should be_kind_of(Rake::FileTask) }
110
- end
111
-
112
- it 'should accept a String and download from that URL' do
113
- define 'foo' do
114
- download('http://localhost/download').tap do |task|
115
- task.source.should_receive(:read).and_yield [@content]
116
- task.invoke
117
- task.should contain(@content)
118
- end
119
- end
120
- end
121
-
122
- it 'should accept a URI and download from that URL' do
123
- define 'foo' do
124
- download(URI.parse('http://localhost/download')).tap do |task|
125
- task.source.should_receive(:read).and_yield [@content]
126
- task.invoke
127
- task.should contain(@content)
128
- end
129
- end
130
- end
131
-
132
- it 'should accept a path and String and download from that URL' do
133
- define 'foo' do
134
- download('downloaded'=>'http://localhost/download').tap do |task|
135
- task.source.should_receive(:read).and_yield [@content]
136
- task.invoke
137
- task.should contain(@content)
138
- end
139
- end
140
- end
141
-
142
- it 'should accept an artifact and String and download from that URL' do
143
- define 'foo' do
144
- artifact('com.example:library:jar:2.0').tap do |artifact|
145
- download(artifact=>'http://localhost/download').source.should_receive(:read).and_yield [@content]
146
- artifact.invoke
147
- artifact.should contain(@content)
148
- end
149
- end
150
- end
151
-
152
- it 'should accept a path and URI and download from that URL' do
153
- define 'foo' do
154
- download('downloaded'=>URI.parse('http://localhost/download')).tap do |task|
155
- task.source.should_receive(:read).and_yield [@content]
156
- task.invoke
157
- task.should contain(@content)
158
- end
159
- end
160
- end
161
-
162
- it 'should create path for download' do
163
- define 'foo' do
164
- download('path/downloaded'=>URI.parse('http://localhost/download')).tap do |task|
165
- task.source.should_receive(:read).and_yield [@content]
166
- task.invoke
167
- task.should contain(@content)
168
- end
169
- end
170
- end
171
-
172
- it 'should fail if resource not found' do
173
- tasks.each do |task|
174
- task.source.should_receive(:read).and_raise URI::NotFoundError
175
- lambda { task.invoke }.should raise_error(URI::NotFoundError)
176
- end
177
- tasks.last.should_not exist
178
- end
179
-
180
- it 'should fail on any other error' do
181
- tasks.each do |task|
182
- task.source.should_receive(:read).and_raise RuntimeError
183
- lambda { task.invoke }.should raise_error(RuntimeError)
184
- end
185
- tasks.last.should_not exist
186
- end
187
-
188
- it 'should execute only if file does not already exist' do
189
- define 'foo' do
190
- download('downloaded'=>'http://localhost/download').tap do |task|
191
- task.source.should_not_receive(:read)
192
- write task.to_s, 'not really'
193
- task.invoke
194
- end
195
- end
196
- end
197
-
198
- it 'should execute without a proxy if none specified' do
199
- Net::HTTP.should_receive(:new).with('localhost', 80).twice.and_return(@http)
200
- tasks.each(&:invoke)
201
- end
202
-
203
- it 'should pass Buildr proxy options' do
204
- Buildr.options.proxy.http = 'http://proxy:8080'
205
- Net::HTTP.should_receive(:new).with('localhost', 80, 'proxy', 8080, nil, nil).twice.and_return(@http)
206
- tasks.each(&:invoke)
207
- end
208
-
209
- it 'should set HTTP proxy from HTTP_PROXY environment variable' do
210
- ENV['HTTP_PROXY'] = 'http://proxy:8080'
211
- Net::HTTP.should_receive(:new).with('localhost', 80, 'proxy', 8080, nil, nil).twice.and_return(@http)
212
- tasks.each(&:invoke)
213
- end
214
- end
215
-
216
-
217
- describe Buildr.method(:filter) do
218
- def source
219
- File.expand_path('src')
220
- end
221
-
222
- it 'should return a Filter for the source' do
223
- filter(source).should be_kind_of(Filter)
224
- end
225
-
226
- it 'should use the source directory' do
227
- filter(source).sources.should include(file(source))
228
- end
229
-
230
- it 'should use the source directories' do
231
- dirs = ['first', 'second']
232
- filter('first', 'second').sources.should include(*dirs.map { |dir| file(File.expand_path(dir)) })
233
- end
234
-
235
- it 'should accept a file task' do
236
- task = file(source)
237
- filter(task).sources.each { |source| source.should be(task) }
238
- end
239
- end
240
-
241
-
242
- describe Buildr::Filter do
243
- before do
244
- @filter = Filter.new
245
- 1.upto(4) do |i|
246
- write "src/file#{i}", "file#{i} raw"
247
- end
248
- @early = Time.now - 1000
249
- end
250
-
251
- it 'should respond to :from and return self' do
252
- @filter.from('src').should be(@filter)
253
- end
254
-
255
- it 'should respond to :from and add source directory' do
256
- lambda { @filter.from('src') }.should change { @filter.sources }
257
- end
258
-
259
- it 'should respond to :from and add source directories' do
260
- dirs = ['first', 'second']
261
- @filter.from(*dirs)
262
- @filter.sources.should include(*dirs.map { |dir| file(File.expand_path(dir)) })
263
- end
264
-
265
- it 'should return source directories as file task' do
266
- @filter.from('src').sources.each { |source| source.should be_kind_of(Rake::FileTask) }
267
- end
268
-
269
- it 'should return source directories as expanded path' do
270
- @filter.from('src').sources.each { |source| source.to_s.should eql(File.expand_path('src')) }
271
- end
272
-
273
- it 'should respond to :into and return self' do
274
- @filter.into('target').should be(@filter)
275
- end
276
-
277
- it 'should respond to :into and set target directory' do
278
- lambda { @filter.into('src') }.should change { @filter.target }
279
- @filter.into('target').target.should be(file(File.expand_path('target')))
280
- end
281
-
282
- it 'should return target directory as file task' do
283
- @filter.into('target').target.should be_kind_of(Rake::FileTask)
284
- end
285
-
286
- it 'should return target directory as expanded path' do
287
- @filter.into('target').target.to_s.should eql(File.expand_path('target'))
288
- end
289
-
290
- it 'should respond to :using and return self' do
291
- @filter.using().should be(@filter)
292
- end
293
-
294
- it 'should respond to :using and set mapping from the argument' do
295
- mapping = { 'foo'=>'bar' }
296
- lambda { @filter.using mapping }.should change { @filter.mapping }.to(mapping)
297
- end
298
-
299
- it 'should respond to :using and set mapping from the block' do
300
- @filter.using { 5 }.mapping.call.should be(5)
301
- end
302
-
303
- it 'should respond to :include and return self' do
304
- @filter.include('file').should be(@filter)
305
- end
306
-
307
- it 'should respond to :include and use these inclusion patterns' do
308
- @filter.from('src').into('target').include('file2', 'file3').run
309
- Dir['target/*'].sort.should eql(['target/file2', 'target/file3'])
310
- end
311
-
312
- it 'should respond to :exclude and return self' do
313
- @filter.exclude('file').should be(@filter)
314
- end
315
-
316
- it 'should respond to :exclude and use these exclusion patterns' do
317
- @filter.from('src').into('target').exclude('file2', 'file3').run
318
- Dir['target/*'].sort.should eql(['target/file1', 'target/file4'])
319
- end
320
-
321
- it 'should copy files over' do
322
- @filter.from('src').into('target').run
323
- Dir['target/*'].sort.each do |file|
324
- read(file).should eql("#{File.basename(file)} raw")
325
- end
326
- end
327
-
328
- it 'should copy dot files over' do
329
- write 'src/.config', '# configuration'
330
- @filter.from('src').into('target').run
331
- read('target/.config').should eql('# configuration')
332
- end
333
-
334
- it 'should copy empty directories as well' do
335
- mkpath 'src/empty'
336
- @filter.from('src').into('target').run
337
- File.directory?('target/empty').should be_true
338
- end
339
-
340
- it 'should copy files from multiple source directories' do
341
- 4.upto(6) { |i| write "src2/file#{i}", "file#{i} raw" }
342
- @filter.from('src', 'src2').into('target').run
343
- Dir['target/*'].each do |file|
344
- read(file).should eql("#{File.basename(file)} raw")
345
- end
346
- Dir['target/*'].should include(*(1..6).map { |i| "target/file#{i}" })
347
- end
348
-
349
- it 'should copy files recursively' do
350
- mkpath 'src/path1' ; write 'src/path1/left'
351
- mkpath 'src/path2' ; write 'src/path2/right'
352
- @filter.from('src').into('target').run
353
- Dir['target/**/*'].should include(*(1..4).map { |i| "target/file#{i}" })
354
- Dir['target/**/*'].should include('target/path1/left', 'target/path2/right')
355
- end
356
-
357
- it 'should apply hash mapping using Maven style' do
358
- 1.upto(4) { |i| write "src/file#{i}", "file#{i} with ${key1} and ${key2}" }
359
- @filter.from('src').into('target').using('key1'=>'value1', 'key2'=>'value2').run
360
- Dir['target/*'].each do |file|
361
- read(file).should eql("#{File.basename(file)} with value1 and value2")
362
- end
363
- end
364
-
365
- it 'should apply hash mapping using Ant style' do
366
- 1.upto(4) { |i| write "src/file#{i}", "file#{i} with @key1@ and @key2@" }
367
- @filter.from('src').into('target').using(:ant, 'key1'=>'value1', 'key2'=>'value2').run
368
- Dir['target/*'].each do |file|
369
- read(file).should eql("#{File.basename(file)} with value1 and value2")
370
- end
371
- end
372
-
373
- it 'should apply hash mapping using Ruby style' do
374
- 1.upto(4) { |i| write "src/file#{i}", "file#{i} with \#{key1} and \#{key2}" }
375
- @filter.from('src').into('target').using(:ruby, 'key1'=>'value1', 'key2'=>'value2').run
376
- Dir['target/*'].each do |file|
377
- read(file).should eql("#{File.basename(file)} with value1 and value2")
378
- end
379
- end
380
-
381
- it 'should use erb when given a binding' do
382
- 1.upto(4) { |i| write "src/file#{i}", "file#{i} with <%= key1 %> and <%= key2 * 2 %>" }
383
- key1 = 'value1'
384
- key2 = 12
385
- @filter.from('src').into('target').using(binding).run
386
- Dir['target/*'].each do |file|
387
- read(file).should eql("#{File.basename(file)} with value1 and 24")
388
- end
389
- end
390
-
391
- it 'should apply hash mapping using erb' do
392
- 1.upto(4) { |i| write "src/file#{i}", "file#{i} with <%= key1 %> and <%= key2 * 2 %>" }
393
- @filter.from('src').into('target').using(:erb, 'key1'=>'value1', 'key2'=> 12).run
394
- Dir['target/*'].each do |file|
395
- read(file).should eql("#{File.basename(file)} with value1 and 24")
396
- end
397
- end
398
-
399
- it 'should use an object binding when using erb' do
400
- 1.upto(4) { |i| write "src/file#{i}", "file#{i} with <%= key1 %> and <%= key2 * 2 %>" }
401
- obj = Struct.new(:key1, :key2).new('value1', 12)
402
- @filter.from('src').into('target').using(:erb, obj).run
403
- Dir['target/*'].each do |file|
404
- read(file).should eql("#{File.basename(file)} with value1 and 24")
405
- end
406
- end
407
-
408
- it 'should use a given block context when using erb' do
409
- 1.upto(4) { |i| write "src/file#{i}", "file#{i} with <%= key1 %> and <%= key2 * 2 %>" }
410
- key1 = 'value1'
411
- key2 = 12
412
- @filter.from('src').into('target').using(:erb){}.run
413
- Dir['target/*'].each do |file|
414
- read(file).should eql("#{File.basename(file)} with value1 and 24")
415
- end
416
- end
417
-
418
- it 'should using Maven mapper by default' do
419
- @filter.using('key1'=>'value1', 'key2'=>'value2').mapper.should eql(:maven)
420
- end
421
-
422
- it 'should apply hash mapping using regular expression' do
423
- 1.upto(4) { |i| write "src/file#{i}", "file#{i} with #key1# and #key2#" }
424
- @filter.from('src').into('target').using(/#(.*?)#/, 'key1'=>'value1', 'key2'=>'value2').run
425
- Dir['target/*'].each do |file|
426
- read(file).should eql("#{File.basename(file)} with value1 and value2")
427
- end
428
- end
429
-
430
- it 'should apply proc mapping' do
431
- @filter.from('src').into('target').using { |file, content| 'proc mapped' }.run
432
- Dir['target/*'].each do |file|
433
- read(file).should eql('proc mapped')
434
- end
435
- end
436
-
437
- it 'should apply proc mapping with relative file name' do
438
- @filter.from('src').into('target').using { |file, content| file.should =~ /^file\d$/ }.run
439
- end
440
-
441
- it 'should apply proc mapping with file content' do
442
- @filter.from('src').into('target').using { |file, content| content.should =~ /^file\d raw/ }.run
443
- end
444
-
445
- it 'should make target directory' do
446
- lambda { @filter.from('src').into('target').run }.should change { File.exist?('target') }.to(true)
447
- end
448
-
449
- it 'should touch target directory' do
450
- mkpath 'target' ; File.utime @early, @early, 'target'
451
- @filter.from('src').into('target').run
452
- File.stat('target').mtime.should be_close(Time.now, 10)
453
- end
454
-
455
- it 'should not touch target directory unless running' do
456
- mkpath 'target' ; File.utime @early, @early, 'target'
457
- @filter.from('src').into('target').exclude('*').run
458
- File.mtime('target').should be_close(@early, 10)
459
- end
460
-
461
- it 'should run only on new files' do
462
- # Make source files older so they're not copied twice.
463
- Dir['src/**/*'].each { |file| File.utime(@early, @early, file) }
464
- @filter.from('src').into('target').run
465
- @filter.from('src').into('target').using { |file, content| file.should eql('file2') }.run
466
- end
467
-
468
- it 'should return true when run copies any files' do
469
- @filter.from('src').into('target').run.should be(true)
470
- end
471
-
472
- it 'should return false when run does not copy any files' do
473
- # Make source files older so they're not copied twice.
474
- Dir['src/**/*'].each { |file| File.utime(@early, @early, file) }
475
- @filter.from('src').into('target').run
476
- @filter.from('src').into('target').run.should be(false)
477
- end
478
-
479
- it 'should fail if source directory doesn\'t exist' do
480
- lambda { Filter.new.from('srced').into('target').run }.should raise_error(RuntimeError, /doesn't exist/)
481
- end
482
-
483
- it 'should fail is target directory not set' do
484
- lambda { Filter.new.from('src').run }.should raise_error(RuntimeError, /No target directory/)
485
- end
486
-
487
- it 'should copy read-only files as writeable' do
488
- Dir['src/*'].each { |file| File.chmod(0444, file) }
489
- @filter.from('src').into('target').run
490
- Dir['target/*'].sort.each do |file|
491
- File.readable?(file).should be_true
492
- File.writable?(file).should be_true
493
- (File.stat(file).mode & 0o200).should == 0o200
494
- end
495
- end
496
- end
497
-
498
- describe Filter::Mapper do
499
-
500
- module MooMapper
501
- def moo_config(*args, &block)
502
- raise ArgumentError, "Expected moo block" unless block_given?
503
- { :moos => args, :callback => block }
504
- end
505
-
506
- def moo_transform(content, path = nil)
507
- content.gsub(/moo+/i) do |str|
508
- moos = yield :moos # same than config[:moos]
509
- moo = moos[str.size - 3] || str
510
- config[:callback].call(moo)
511
- end
512
- end
513
- end
514
-
515
- it 'should allow plugable mapping types' do
516
- mapper = Filter::Mapper.new.extend(MooMapper)
517
- mapper.using(:moo, 'ooone', 'twoo') do |str|
518
- i = nil; str.capitalize.gsub(/\w/) { |s| s.send( (i = !i) ? 'upcase' : 'downcase' ) }
519
- end
520
- mapper.transform('Moo cow, mooo cows singing mooooo').should == 'OoOnE cow, TwOo cows singing MoOoOo'
521
- end
522
-
523
- end
524
-
525
- describe Buildr.method(:options) do
526
- it 'should return an Options object' do
527
- options.should be_kind_of(Options)
528
- end
529
-
530
- it 'should return an Options object each time' do
531
- options.should be(options)
532
- end
533
-
534
- it 'should return the same Options object when called on Object, Buildr or Project' do
535
- options.should be(Buildr.options)
536
- define('foo') { options.should be(Buildr.options) }
537
- end
538
- end
539
-
540
- describe Buildr::Options, 'proxy.exclude' do
541
- before do
542
- options.proxy.http = 'http://myproxy:8080'
543
- @domain = 'domain'
544
- @host = "host.#{@domain}"
545
- @uri = URI("http://#{@host}")
546
- @no_proxy_args = [@host, 80]
547
- @proxy_args = @no_proxy_args + ['myproxy', 8080, nil, nil]
548
- @http = mock('http')
549
- @http.stub!(:request).and_return(Net::HTTPNotModified.new(nil, nil, nil))
550
- end
551
-
552
- it 'should be an array' do
553
- options.proxy.exclude.should be_empty
554
- options.proxy.exclude = @domain
555
- options.proxy.exclude.should include(@domain)
556
- end
557
-
558
- it 'should support adding to array' do
559
- options.proxy.exclude << @domain
560
- options.proxy.exclude.should include(@domain)
561
- end
562
-
563
- it 'should support resetting array' do
564
- options.proxy.exclude = @domain
565
- options.proxy.exclude = nil
566
- options.proxy.exclude.should be_empty
567
- end
568
-
569
- it 'should use proxy when not excluded' do
570
- Net::HTTP.should_receive(:new).with(*@proxy_args).and_return(@http)
571
- @uri.read :proxy=>options.proxy
572
- end
573
-
574
- it 'should use proxy unless excluded' do
575
- options.proxy.exclude = "not.#{@domain}"
576
- Net::HTTP.should_receive(:new).with(*@proxy_args).and_return(@http)
577
- @uri.read :proxy=>options.proxy
578
- end
579
-
580
- it 'should not use proxy if excluded' do
581
- options.proxy.exclude = @host
582
- Net::HTTP.should_receive(:new).with(*@no_proxy_args).and_return(@http)
583
- @uri.read :proxy=>options.proxy
584
- end
585
-
586
- it 'should support multiple host names' do
587
- options.proxy.exclude = ['optimus', 'prime']
588
- Net::HTTP.should_receive(:new).with('optimus', 80).and_return(@http)
589
- URI('http://optimus').read :proxy=>options.proxy
590
- Net::HTTP.should_receive(:new).with('prime', 80).and_return(@http)
591
- URI('http://prime').read :proxy=>options.proxy
592
- Net::HTTP.should_receive(:new).with('bumblebee', *@proxy_args[1..-1]).and_return(@http)
593
- URI('http://bumblebee').read :proxy=>options.proxy
594
- end
595
-
596
- it 'should support glob pattern on host name' do
597
- options.proxy.exclude = "*.#{@domain}"
598
- Net::HTTP.should_receive(:new).with(*@no_proxy_args).and_return(@http)
599
- @uri.read :proxy=>options.proxy
600
- end
601
- end
602
-
603
-
604
- describe Hash, '::from_java_properties' do
605
- it 'should return hash' do
606
- hash = Hash.from_java_properties(<<-PROPS)
607
- name1=value1
608
- name2=value2
609
- PROPS
610
- hash.should == {'name1'=>'value1', 'name2'=>'value2'}
611
- end
612
-
613
- it 'should ignore comments and empty lines' do
614
- hash = Hash.from_java_properties(<<-PROPS)
615
-
616
- name1=value1
617
-
618
- name2=value2
619
-
620
- PROPS
621
- hash.should == {'name1'=>'value1', 'name2'=>'value2'}
622
- end
623
-
624
- it 'should allow multiple lines' do
625
- hash = Hash.from_java_properties(<<-PROPS)
626
- name1=start\
627
- end
628
-
629
- name2=first\
630
- second\
631
- third
632
-
633
- PROPS
634
- hash.should == {'name1'=>'start end', 'name2'=>'first second third'}
635
- end
636
-
637
- it 'should handle \t, \r, \n and \f' do
638
- hash = Hash.from_java_properties(<<-PROPS)
639
-
640
- name1=with\tand\r
641
-
642
- name2=with\\nand\f
643
-
644
- name3=double\\\\hash
645
- PROPS
646
- hash.should == {'name1'=>"with\tand", 'name2'=>"with\nand\f", 'name3'=>'double\hash'}
647
- end
648
-
649
- it 'should ignore whitespace' do
650
- hash = Hash.from_java_properties('name1 = value1')
651
- hash.should == {'name1'=>'value1'}
652
- end
653
- end
654
-
655
-
656
- describe Hash, '#to_java_properties' do
657
- it 'should return name/value pairs' do
658
- props = {'name1'=>'value1', 'name2'=>'value2'}.to_java_properties
659
- props.split("\n").size.should be(2)
660
- props.split("\n").should include('name1=value1')
661
- props.split("\n").should include('name2=value2')
662
- end
663
-
664
- it 'should handle \t, \r, \n and \f' do
665
- props = {'name1'=>"with\tand\r", 'name2'=>"with\nand\f", 'name3'=>'double\hash'}.to_java_properties
666
- props.split("\n").should include("name1=with\\tand\\r")
667
- props.split("\n").should include("name2=with\\nand\\f")
668
- props.split("\n").should include("name3=double\\\\hash")
669
- end
670
- end