compress_command

in src/_plugins/asset_bundler.rb [327:377]


    def compress_command()
      temp_path = cache_dir()
      command = String.new(@config['compress'][@type])
      infile = false
      outfile = false
      used_files = []

      if command =~ /:infile/
        File.open(File.join(temp_path, "infile.#{@filename_hash}.#{@type}"), mode="w") {|f|
          f.write(@content)
          used_files.push( f.path )
          infile = f.path
        }
        command.sub!( /:infile/, "\"#{infile.gsub(File::SEPARATOR,
                               File::ALT_SEPARATOR || File::SEPARATOR)}\"")
      end
      if command =~ /:outfile/
        outfile = File.join(temp_path, "outfile.#{@filename_hash}.#{@type}")
        used_files.push( outfile )
        command.sub!( /:outfile/, "\"#{outfile.gsub(File::SEPARATOR,
                               File::ALT_SEPARATOR || File::SEPARATOR)}\"")
      end

      if infile and outfile
        `
      else
        mode = "r"
        mode = "r+" if !infile
        IO.popen(command, mode) {|i|
          if !infile
            i.puts(@content)
            i.close_write()
          end
          if !outfile
            @content = ""
            i.each {|line|
              @content << line
            }
          end
        }
      end

      if outfile
        @content = File.read( outfile )
      end

      used_files.each {|f|
        File.unlink( f )
      }
    end