lib/sprockets/processing.rb in sprockets-3.0.0.beta.3 vs lib/sprockets/processing.rb in sprockets-3.0.0.beta.4

- old
+ new

@@ -154,74 +154,30 @@ processors.delete(klass) processors end end - # Internal: Run processors on filename and data. - # - # Returns Hash. - def process(processors, uri, filename, load_path, name, content_type) - data, metadata = nil, {} - - input = { - environment: self, - cache: cache, - uri: uri, - filename: filename, - load_path: load_path, - name: name, - content_type: content_type, - metadata: metadata - } - - processors.each do |processor| - begin - result = processor.call(input.merge(data: data, metadata: metadata)) - case result - when NilClass - # noop - when Hash - data = result[:data] if result.key?(:data) - metadata = metadata.merge(result) - metadata.delete(:data) - when String - data = result - else - raise Error, "invalid processor return type: #{result.class}" - end - end - end - - { - source: data, - charset: data.encoding.name.downcase, - length: data.bytesize, - digest: digest(data), - metadata: metadata - } - end - # Internal: Two dimensional Hash of reducer functions for a given mime type # and asset metadata key. attr_reader :bundle_reducers - # Public: Register bundle reducer function. + # Public: Register bundle metadata reducer function. # # Examples # - # Sprockets.register_bundle_reducer 'application/javascript', :jshint_errors, [], :+ + # Sprockets.register_bundle_metadata_reducer 'application/javascript', :jshint_errors, [], :+ # - # Sprockets.register_bundle_reducer 'text/css', :selector_count, 0 { |total, count| + # Sprockets.register_bundle_metadata_reducer 'text/css', :selector_count, 0 { |total, count| # total + count # } # # mime_type - String MIME Type. Use '*/*' applies to all types. # key - Symbol metadata key # initial - Initial memo to pass to the reduce funciton (default: nil) # block - Proc accepting the memo accumulator and current value # # Returns nothing. - def register_bundle_reducer(mime_type, key, *args, &block) + def register_bundle_metadata_reducer(mime_type, key, *args, &block) case args.size when 0 reducer = block when 1 if block_given?