lib/core/common.rb in buildr-0.21.0 vs lib/core/common.rb in buildr-0.22.0

- old
+ new

@@ -3,10 +3,27 @@ require "core/transports" module Buildr # :call-seq: + # struct(hash) => Struct + # + # Convenience method for creating an anonymous Struct. + # + # For example: + # COMMONS = struct( + # :collections =>"commons-collections:commons-collections:jar:3.1", + # :lang =>"commons-lang:commons-lang:jar:2.1", + # :logging =>"commons-logging:commons-logging:jar:1.0.3", + # ) + # + # compile.with COMMONS.logging + def struct(hash) + Struct.new(nil, *hash.keys).new(*hash.values) + end + + # :call-seq: # write(name, content) # write(name) { ... } # # Write the contents into a file. The second form calls the block and writes the result. # @@ -237,24 +254,23 @@ end end # :call-seq: - # filter(target=>source) => Filter + # filter(source) => Filter # # Creates a filter that will copy files from the source directory into the target directory. # You can extend the filter to modify files by mapping <tt>${key}</tt> into values in each # of the copied files, and by including or excluding specific files. # # A filter is not a task, you must call the Filter#run method to execute it. # # For example, to copy all files from one directory to another: - # filter("target/classes"=>"src/files") + # filter("src/files").into("target/classes").run # To include only the text files, and replace each instance of <tt>${build}</tt> with the current # date/time: - # filter("target/classes"=>"src/files").include("*.txt").using("build"=>Time.now) - def filter(args) - target, source = Rake.application.resolve_args(args) - Filter.new.into(target).tap { |filter| filter.from(source) if source } + # filter("src/files").into("target/classes").include("*.txt").using("build"=>Time.now).run + def filter(source) + Filter.new.from(source) end end