Sha256: 276692821873d6164aba802726cb5019f14d019ad29a8356e463bde9a0c0c361

Contents?: true

Size: 1006 Bytes

Versions: 16

Compression:

Stored size: 1006 Bytes

Contents

module Buildr

  # 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.
  class ConcatTask < Rake::FileTask
    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
  end

  # :call-seq:
  #    concat(target=>files) => task
  #
  # Creates and returns a file task that concatenates all its prerequisites to create
  # a new file. See #ConcatTask.
  #
  # For example:
  #   concat("master.sql"=>["users.sql", "orders.sql", reports.sql"]
  def concat(args)
    file, deps = Rake.application.resolve_args(args)
    ConcatTask.define_task File.expand_path(file)=>deps
  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
buildr-1.0.0 lib/tasks/concat.rb
buildr-1.1.0 lib/tasks/concat.rb
buildr-1.1.1 lib/tasks/concat.rb
buildr-1.1.2 lib/tasks/concat.rb
buildr-1.1.3 lib/tasks/concat.rb
buildr-1.2.0 lib/tasks/concat.rb
buildr-1.2.1 lib/tasks/concat.rb
buildr-1.2.10 lib/tasks/concat.rb
buildr-1.2.2 lib/tasks/concat.rb
buildr-1.2.3 lib/tasks/concat.rb
buildr-1.2.4 lib/tasks/concat.rb
buildr-1.2.5 lib/tasks/concat.rb
buildr-1.2.6 lib/tasks/concat.rb
buildr-1.2.7 lib/tasks/concat.rb
buildr-1.2.8 lib/tasks/concat.rb
buildr-1.2.9 lib/tasks/concat.rb