Sha256: d291a83fe581a2f227e4d2acab5ae832350b2e22d942721158e08ad6fd7345ad

Contents?: true

Size: 1.63 KB

Versions: 14

Compression:

Stored size: 1.63 KB

Contents

module Distil
  
  # Mix in for concatenating products
  module Concatenated
    
    # files -> an enumerable collection of SourceFiles
    # join_string -> a string to use to join the files together
    # target -> the container of the files
    
    def before_files(f)
    end

    def after_files(f)
    end
    
    def before_externals(f)
    end
    
    def after_externals(f)
    end
    
    def before_file(f, file)
    end
    
    def after_file(f, file)
    end
    
    def filename
      concatenated_name
    end
    
    def external_files
      return @external_files if @external_files
      @external_files= []
      
      target.include_projects.each { |ext|
        @external_files << ext.product_name(:concatenated, File.extname(filename)[1..-1])
      }
      @external_files
    end
    
    def write_output
      return if up_to_date
      @up_to_date= true
      
      File.open(filename, "w") { |f|
        f.write(target.notice_text)

        f.write("\n\n")
        before_externals(f)
        f.write("\n\n")
        
        external_files.each { |ext|
          next if !File.exist?(ext)
          f.write(join_string)
          f.write(target.get_content_for_file(ext))
        }

        f.write("\n\n")
        after_externals(f)
        f.write("\n\n")

        f.write("\n\n")
        before_files(f)
        f.write("\n\n")

        files.each { |file|
          f.write(join_string)
          before_file(f, file)
          f.write(target.get_content_for_file(file))
          after_file(f, file)
        }
        
        f.write("\n\n")
        after_files(f)
        f.write("\n\n");
        
      }
    end

  end
  
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
distil-0.13.6 lib/distil/product/concatenated.rb
distil-0.13.5 lib/distil/product/concatenated.rb
distil-0.13.4 lib/distil/product/concatenated.rb
distil-0.13.3 lib/distil/product/concatenated.rb
distil-0.13.2 lib/distil/product/concatenated.rb
distil-0.13.1 lib/distil/product/concatenated.rb
distil-0.13.0 lib/distil/product/concatenated.rb
distil-0.12.6 lib/distil/product/concatenated.rb
distil-0.12.4 lib/distil/product/concatenated.rb
distil-0.12.3 lib/distil/product/concatenated.rb
distil-0.12.2 lib/distil/product/concatenated.rb
distil-0.12.1 lib/distil/product/concatenated.rb
distil-0.12.0 lib/distil/product/concatenated.rb
distil-0.11.8 lib/distil/product/concatenated.rb