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,117 +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
- module Buildr
18
-
19
- # Collection of options for controlling Buildr.
20
- class Options
21
-
22
- # We use this to present environment variable as arrays.
23
- class EnvArray < Array #:nodoc:
24
-
25
- def initialize(name)
26
- @name = name.upcase
27
- replace((ENV[@name] || ENV[@name.downcase] || '').split(/\s*,\s*/).reject(&:empty?))
28
- end
29
-
30
- (Array.instance_methods - Object.instance_methods - Enumerable.instance_methods).sort.each do |method|
31
- class_eval %{def #{method}(*args, &block) ; result = super ; write ; result ; end}
32
- end
33
-
34
- private
35
-
36
- def write
37
- ENV[@name.downcase] = nil
38
- ENV[@name] = map(&:to_s).join(',')
39
- end
40
-
41
- end
42
-
43
-
44
- # Wraps around the proxy environment variables:
45
- # * :http -- HTTP_PROXY
46
- # * :exclude -- NO_PROXY
47
- class Proxies
48
-
49
- # Returns the HTTP_PROXY URL.
50
- def http
51
- ENV['HTTP_PROXY'] || ENV['http_proxy']
52
- end
53
-
54
- # Sets the HTTP_PROXY URL.
55
- def http=(url)
56
- ENV['http_proxy'] = nil
57
- ENV['HTTP_PROXY'] = url
58
- end
59
-
60
- # Returns list of hosts to exclude from proxying (NO_PROXY).
61
- def exclude
62
- @exclude ||= EnvArray.new('NO_PROXY')
63
- end
64
-
65
- # Sets list of hosts to exclude from proxy (NO_PROXY). Accepts host name, array of names,
66
- # or nil to clear the list.
67
- def exclude=(url)
68
- exclude.clear
69
- exclude.concat [url].flatten if url
70
- exclude
71
- end
72
-
73
- end
74
-
75
- # :call-seq:
76
- # proxy => options
77
- #
78
- # Returns the proxy options. Currently supported options are:
79
- # * :http -- HTTP proxy for use when downloading.
80
- # * :exclude -- Do not use proxy for these hosts/domains.
81
- #
82
- # For example:
83
- # options.proxy.http = 'http://proxy.acme.com:8080'
84
- # You can also set it using the environment variable HTTP_PROXY.
85
- #
86
- # You can exclude individual hosts from being proxied, or entire domains, for example:
87
- # options.proxy.exclude = 'optimus'
88
- # options.proxy.exclude = ['optimus', 'prime']
89
- # options.proxy.exclude << '*.internal'
90
- def proxy
91
- @proxy ||= Proxies.new
92
- end
93
-
94
- end
95
-
96
-
97
- class << self
98
-
99
- # :call-seq:
100
- # options => Options
101
- #
102
- # Returns the Buildr options. See Options.
103
- def options
104
- @options ||= Options.new
105
- end
106
-
107
- end
108
-
109
- # :call-seq:
110
- # options => Options
111
- #
112
- # Returns the Buildr options. See Options.
113
- def options
114
- Buildr.options
115
- end
116
-
117
- end
@@ -1,366 +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 'erb'
18
-
19
-
20
- module Buildr
21
-
22
- # A filter knows how to copy files from one directory to another, applying mappings to the
23
- # contents of these files.
24
- #
25
- # You can specify the mapping using a Hash, and it will map ${key} fields found in each source
26
- # file into the appropriate value in the target file. For example:
27
- #
28
- # filter.using 'version'=>'1.2', 'build'=>Time.now
29
- #
30
- # will replace all occurrences of <tt>${version}</tt> with <tt>1.2</tt>, and <tt>${build}</tt>
31
- # with the current date/time.
32
- #
33
- # You can also specify the mapping by passing a proc or a method, that will be called for
34
- # each source file, with the file name and content, returning the modified content.
35
- #
36
- # Without any mapping, the filter simply copies files from the source directory into the target
37
- # directory.
38
- #
39
- # A filter has one target directory, but you can specify any number of source directories,
40
- # either when creating the filter or calling #from. Include/exclude patterns are specified
41
- # relative to the source directories, so:
42
- # filter.include '*.png'
43
- # will only include PNG files from any of the source directories.
44
- #
45
- # See Buildr#filter.
46
- class Filter
47
-
48
- def initialize #:nodoc:
49
- clear
50
- end
51
-
52
- # Returns the list of source directories (each being a file task).
53
- attr_reader :sources
54
-
55
- # :call-seq:
56
- # clear => self
57
- #
58
- # Clear filter sources and include/exclude patterns
59
- def clear
60
- @include = []
61
- @exclude = []
62
- @sources = FileList[]
63
- @mapper = Mapper.new
64
- self
65
- end
66
-
67
- # :call-seq:
68
- # from(*sources) => self
69
- #
70
- # Adds additional directories from which to copy resources.
71
- #
72
- # For example:
73
- # filter.from('src').into('target').using('build'=>Time.now)
74
- def from(*sources)
75
- @sources |= sources.flatten.map { |dir| file(File.expand_path(dir.to_s)) }
76
- self
77
- end
78
-
79
- # The target directory as a file task.
80
- attr_reader :target
81
-
82
- # :call-seq:
83
- # into(dir) => self
84
- #
85
- # Sets the target directory into which files are copied and returns self.
86
- #
87
- # For example:
88
- # filter.from('src').into('target').using('build'=>Time.now)
89
- def into(dir)
90
- @target = file(File.expand_path(dir.to_s)) { |task| run if target == task }
91
- self
92
- end
93
-
94
- # :call-seq:
95
- # include(*files) => self
96
- #
97
- # Specifies files to include and returns self. See FileList#include.
98
- #
99
- # By default all files are included. You can use this method to only include specific
100
- # files from the source directory.
101
- def include(*files)
102
- @include += files
103
- self
104
- end
105
- alias :add :include
106
-
107
- # :call-seq:
108
- # exclude(*files) => self
109
- #
110
- # Specifies files to exclude and returns self. See FileList#exclude.
111
- def exclude(*files)
112
- @exclude += files
113
- self
114
- end
115
-
116
- # The mapping. See #using.
117
- def mapping #:nodoc:
118
- @mapper.config
119
- end
120
-
121
- # The mapper to use. See #using.
122
- def mapper #:nodoc:
123
- @mapper.mapper_type
124
- end
125
-
126
- # :call-seq:
127
- # using(mapping) => self
128
- # using { |file_name, contents| ... } => self
129
- #
130
- # Specifies the mapping to use and returns self.
131
- #
132
- # The most typical mapping uses a Hash, and the default mapping uses the Maven style, so
133
- # <code>${key}</code> are mapped to the values. You can change that by passing a different
134
- # format as the first argument. Currently supports:
135
- # * :ant -- Map <code>@key@</code>.
136
- # * :maven -- Map <code>${key}</code> (default).
137
- # * :ruby -- Map <code>#{key}</code>.
138
- # * :erb -- Map <code><%= key %></code>.
139
- # * Regexp -- Maps the matched data (e.g. <code>/=(.*?)=/</code>
140
- #
141
- # For example:
142
- # filter.using 'version'=>'1.2'
143
- # Is the same as:
144
- # filter.using :maven, 'version'=>'1.2'
145
- #
146
- # You can also pass a proc or method. It will be called with the file name and content,
147
- # to return the mapped content.
148
- #
149
- # Without any mapping, all files are copied as is.
150
- #
151
- # To register new mapping type see the Mapper class.
152
- def using(*args, &block)
153
- @mapper.using(*args, &block)
154
- self
155
- end
156
-
157
- # :call-seq:
158
- # run => boolean
159
- #
160
- # Runs the filter.
161
- def run
162
- sources.each { |source| raise "Source directory #{source} doesn't exist" unless File.exist?(source.to_s) }
163
- raise 'No target directory specified, where am I going to copy the files to?' if target.nil?
164
-
165
- copy_map = sources.flatten.map(&:to_s).inject({}) do |map, source|
166
- files = Util.recursive_with_dot_files(source).
167
- map { |file| Util.relative_path(file, source) }.
168
- select { |file| @include.empty? || @include.any? { |pattern| File.fnmatch(pattern, file, File::FNM_PATHNAME) } }.
169
- reject { |file| @exclude.any? { |pattern| File.fnmatch(pattern, file, File::FNM_PATHNAME) } }
170
- files.each do |file|
171
- src, dest = File.expand_path(file, source), File.expand_path(file, target.to_s)
172
- map[file] = src if !File.exist?(dest) || File.stat(src).mtime >= File.stat(dest).mtime
173
- end
174
- map
175
- end
176
-
177
- mkpath target.to_s, :verbose=>Buildr.application.options.trace
178
- return false if copy_map.empty?
179
-
180
- verbose(Buildr.application.options.trace || false) do
181
- copy_map.each do |path, source|
182
- dest = File.expand_path(path, target.to_s)
183
- if File.directory?(source)
184
- mkpath dest, :verbose=>false
185
- else
186
- mkpath File.dirname(dest)
187
- if @mapper.mapper_type
188
- mapped = @mapper.transform(File.open(source, 'rb') { |file| file.read }, path)
189
- File.open(dest, 'wb') { |file| file.write mapped }
190
- else # no mapping
191
- cp source, dest
192
- File.chmod(0664, dest)
193
- end
194
- end
195
- end
196
- touch target.to_s
197
- end
198
- true
199
- end
200
-
201
- # Returns the target directory.
202
- def to_s
203
- @target.to_s
204
- end
205
-
206
- # This class implements content replacement logic for Filter.
207
- #
208
- # To register a new template engine @:foo@, extend this class with a method like:
209
- #
210
- # def foo_transform(content, path = nil)
211
- # # if this method yields a key, the value comes from the mapping hash
212
- # content.gsub(/world/) { |str| yield :bar }
213
- # end
214
- #
215
- # Then you can use :foo mapping type on a Filter
216
- #
217
- # filter.using :foo, :bar => :baz
218
- #
219
- # Or all by your own, simply
220
- #
221
- # Mapper.new(:foo, :bar => :baz).transform("Hello world") # => "Hello baz"
222
- #
223
- # You can handle configuration arguments by providing a @*_config@ method like:
224
- #
225
- # # The return value of this method is available with the :config accessor.
226
- # def moo_config(*args, &block)
227
- # raise ArgumentError, "Expected moo block" unless block_given?
228
- # { :moos => args, :callback => block }
229
- # end
230
- #
231
- # def moo_transform(content, path = nil)
232
- # content.gsub(/moo+/i) do |str|
233
- # moos = yield :moos # same than config[:moos]
234
- # moo = moos[str.size - 3] || str
235
- # config[:callback].call(moo)
236
- # end
237
- # end
238
- #
239
- # Usage for the @:moo@ mapper would be something like:
240
- #
241
- # mapper = Mapper.new(:moo, 'ooone', 'twoo') do |str|
242
- # i = nil; str.capitalize.gsub(/\w/) { |s| s.send( (i = !i) ? 'upcase' : 'downcase' ) }
243
- # end
244
- # mapper.transform('Moo cow, mooo cows singing mooooo') # => 'OoOnE cow, TwOo cows singing MoOoOo'
245
- class Mapper
246
-
247
- attr_reader :mapper_type, :config
248
-
249
- def initialize(*args, &block) #:nodoc:
250
- using(*args, &block)
251
- end
252
-
253
- def using(*args, &block)
254
- case args.first
255
- when Hash # Maven hash mapping
256
- using :maven, *args
257
- when Binding # Erb binding
258
- using :erb, *args
259
- when Symbol # Mapping from a method
260
- raise ArgumentError, "Unknown mapping type: #{args.first}" unless respond_to?("#{args.first}_transform", true)
261
- configure(*args, &block)
262
- when Regexp # Mapping using a regular expression
263
- raise ArgumentError, 'Expected regular expression followed by mapping hash' unless args.size == 2 && Hash === args[1]
264
- @mapper_type, @config = *args
265
- else
266
- unless args.empty? && block.nil?
267
- raise ArgumentError, 'Expected proc, method or a block' if args.size > 1 || (args.first && block)
268
- @mapper_type = :callback
269
- config = args.first || block
270
- raise ArgumentError, 'Expected proc, method or callable' unless config.respond_to?(:call)
271
- @config = config
272
- end
273
- end
274
- self
275
- end
276
-
277
- def transform(content, path = nil)
278
- type = Regexp === mapper_type ? :regexp : mapper_type
279
- raise ArgumentError, "Invalid mapper type: #{type.inspect}" unless respond_to?("#{type}_transform", true)
280
- self.__send__("#{type}_transform", content, path) { |key| config[key] || config[key.to_s.to_sym] }
281
- end
282
-
283
- private
284
- def configure(mapper_type, *args, &block)
285
- configurer = method("#{mapper_type}_config") rescue nil
286
- if configurer
287
- @config = configurer.call(*args, &block)
288
- else
289
- raise ArgumentError, "Missing hash argument after :#{mapper_type}" unless args.size == 1 && Hash === args[0]
290
- @config = *args
291
- end
292
- @mapper_type = mapper_type
293
- end
294
-
295
- def maven_transform(content, path = nil)
296
- content.gsub(/\$\{.*?\}/) { |str| yield(str[2..-2]) || str }
297
- end
298
-
299
- def ant_transform(content, path = nil)
300
- content.gsub(/@.*?@/) { |str| yield(str[1..-2]) || str }
301
- end
302
-
303
- def ruby_transform(content, path = nil)
304
- content.gsub(/#\{.*?\}/) { |str| yield(str[2..-2]) || str }
305
- end
306
-
307
- def regexp_transform(content, path = nil)
308
- content.gsub(mapper_type) { |str| yield(str.scan(mapper_type).join) || str }
309
- end
310
-
311
- def callback_transform(content, path = nil)
312
- config.call(path, content)
313
- end
314
-
315
- def erb_transform(content, path = nil)
316
- case config
317
- when Binding, Proc
318
- bnd = config
319
- when Method
320
- bnd = config.to_proc
321
- when Hash
322
- bnd = OpenStruct.new
323
- table = config.inject({}) { |h, e| h[e.first.to_sym] = e.last; h }
324
- bnd.instance_variable_set(:@table, table)
325
- bnd = bnd.instance_eval { binding }
326
- else
327
- bnd = config.instance_eval { binding }
328
- end
329
- require 'erb'
330
- ERB.new(content).result(bnd)
331
- end
332
-
333
- def erb_config(*args, &block)
334
- if block_given?
335
- raise ArgumentError, "Expected block or single argument, but both given." unless args.empty?
336
- block
337
- elsif args.size > 1
338
- raise ArgumentError, "Expected block or single argument."
339
- else
340
- args.first
341
- end
342
- end
343
-
344
- end # class Mapper
345
-
346
- end
347
-
348
- # :call-seq:
349
- # filter(*source) => Filter
350
- #
351
- # Creates a filter that will copy files from the source directory(ies) into the target directory.
352
- # You can extend the filter to modify files by mapping <tt>${key}</tt> into values in each
353
- # of the copied files, and by including or excluding specific files.
354
- #
355
- # A filter is not a task, you must call the Filter#run method to execute it.
356
- #
357
- # For example, to copy all files from one directory to another:
358
- # filter('src/files').into('target/classes').run
359
- # To include only the text files, and replace each instance of <tt>${build}</tt> with the current
360
- # date/time:
361
- # filter('src/files').into('target/classes').include('*.txt').using('build'=>Time.now).run
362
- def filter(*sources)
363
- Filter.new.from(*sources)
364
- end
365
-
366
- end