Sha256: 0816929094be1ff8226e30e25226f4d38565640fb05cddca77b8d92226ddc30c

Contents?: true

Size: 1.78 KB

Versions: 2

Compression:

Stored size: 1.78 KB

Contents

require "#{$script_dir}/tasks/output-task.rb"

class SingleOutputTask < OutputTask

  def initialize(target, options)
    super(target, options)

    type= output_extension
    return if (!type)
    
    target_name= "#{target.target_name}".downcase
    prefix= "#{output_folder}/#{project_name}"
    
    if ("all"==target_name)
      target_name= ""
    else
      prefix= "#{prefix}-"
    end

    @name_concat= "#{prefix}#{target_name}-uncompressed.#{type}"
    @name_min= "#{prefix}#{target_name}.#{type}"
    @name_gz= "#{prefix}#{target_name}.#{type}.gz"
    @name_debug= "#{prefix}#{target_name}-debug.#{type}"

    @products= [@name_concat, @name_min, @name_gz, @name_debug]
    
    @concat = ""
    @debug = ""
  end

  def process_files
    destination= File.expand_path(remove_prefix||"")
    @included_files.each { |f|
      @concat << f.content_relative_to_destination(destination)
      @debug << f.debug_content_relative_to_destination(destination)
    }
  end

  def finish
    return if (!output_type)
    
    # Clear old files
    [@name_concat, @name_min, @name_gz, @name_debug].each { |file|
      next if (!File.exists?(file))
      File.delete(file)
    }

    return if (""==@concat)

    params= {
      "VERSION"=>@options.version
    }
    
    concat= replace_tokens(@concat, params)
    
    File.open(@name_concat, "w") { |f|
      f.write(notice_text)
      f.write(concat)
    }
    
    minified= minify(concat)

    File.open(@name_min, "w") { |f|
      f.write(notice_text)
      f.write(minified)
    }
    
    Zlib::GzipWriter.open(@name_gz) { |f|
      f.write(notice_text)
      f.write(minified)
    }

    return if (""==@debug)
    
    File.open(@name_debug, "w") { |f|
      f.write(notice_text)
      debug= replace_tokens(@debug, params)
      f.write(debug)
    }
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
distil-0.8.0 lib/tasks/single-output-task.rb
distil-0.7.0 lib/tasks/single-output-task.rb