b0VIM 7.3QKLIbradsystem76~brad/techpines/asset-rack/lib/rack.coffeeutf-8 3210#"! Utpead=eZ4$O e P  i H  s V U C   v Y X ?  x T A 8  B/_0c \A,kFE&VUC&r?> return asset.specificUrl if url is asse return asset.sp return asset.specificUrl if url is ass return asset.specificUrl if url is return asset.specificUrl if url is asset.url for asset in @assets url: (url) -> throw new Error "No asset found for url: #{url}" return asset.tag() if asset.url is url for asset in @assets tag: (url) -> @emit 's3-upload-complete' , => request.end buffer @emit 'error', error request.on 'error', (error) => @emit 'error', new Error message message = "#{asset.url}: Bad S3 status code response #{response.statusCode}" else next() if response.statusCode is 200 response.setEncoding 'utf8' request.on 'response', (response) => } 'x-amz-acl': 'public-read' 'Cache-Control': "public, max-age=#{asset.maxAge}" 'Content-Type': asset.mimetype 'Content-Length': buffer.length request = client.put url, { url = asset.specificUrl.slice 1, asset.specificUrl.length client = knox.createClient options buffer = new Buffer asset.contents async.forEachSeries @assets, (asset, next) => pushS3: (options) -> else @once 'complete', handle handle() if @completed next() return asset.respond request, response if check check = asset.checkUrl request.url for asset in @assets handle = => response.locals assets: this handle: (request, response, next) -> next() @assets.push clientRack clientRack.on 'complete', => clientRack = @createClientRack() addClientRack: (next) -> clientRack clientRack.rack = this clientRack = new ClientRack createClientRack: -> hash: asset.hash maxAge: asset.maxAge mimetype: asset.mimetype specificUrl: asset.specificUrl md5: asset.md5 url: asset.url config = for asset in @assets getConfig: -> @emit 'complete' return @emit 'error', error if error? , (error) => asset.emit 'start' asset.rack = this next() @assets = @assets.concat asset.assets if asset.assets? @assets.push asset if asset.contents? asset.on 'complete', => next error asset.on 'error', (error) => async.forEachSeries assets, (asset, next) => @assets = [] asset.rack = this for asset in assets throw error if @listeners('error').length is 1 @on 'error', (error) => listener() if event is 'complete' and @completed is true @on 'newListener', (event, listener) => @completed = true @on 'complete', => @allowNoHashCache = options.allowNoHashCache @maxAge = options.maxAge options ?= {} super() constructor: (assets, options) ->class exports.AssetRack extends EventEmitter{EventEmitter} = require 'events'ClientRack = require('./.').ClientRackknox = require 'knox'async = require 'async'