Class: Buildr::ConcatTask

Inherits:
Rake::FileTask show all
Defined in:
lib/buildr/core/common.rb

Overview

A file task that concatenates all its prerequisites to create a new file.

For example:

concat("master.sql"=>["users.sql", "orders.sql", reports.sql"]

See also Buildr#concat.

Instance Method Summary collapse

Methods inherited from Rake::FileTask

#contain?, #empty?, #exist?

Constructor Details

#initialize(*args) ⇒ ConcatTask

:nodoc:



125
126
127
128
129
130
131
132
133
134
# File 'lib/buildr/core/common.rb', line 125

def initialize(*args) #:nodoc:
  super
  enhance do |task|
    content = prerequisites.inject("") do |content, prereq|
      content << File.read(prereq.to_s) if File.exists?(prereq) && !File.directory?(prereq)
      content
    end
    File.open(task.name, "wb") { |file| file.write content }
  end
end