<commit_before>module Jammit

  # Uses the YUI Compressor to compress JavaScript and CSS. Also knows how to
  # create a concatenated JST file.
  class Compressor

    MIME_TYPE_MAP = {
      '.png'  => 'image/png',
      '.jpg'  => 'image/jpeg',
      '.jpeg' => 'image/jpeg',
      '.gif'  => 'image/gif',
      '.tif'  => 'image/tiff',
      '.tiff' => 'image/tiff'
    }

    URL_DETECTOR = /url\(['"]?([^\s)]+)['"]?\)/

    JST_NAMER = /\/(\w+)\.jst\Z/

    def initialize
      @yui_js  = YUI::JavaScriptCompressor.new(:munge => true)
      @yui_css = YUI::CssCompressor.new
    end

    # Delegates to the YUI compressor.
    def compress_js(paths)
      @yui_js.compress(concatenate(paths))
    end

    # Delegates to the YUI compressor.
    def compress_css(paths, variant)
      compressed_css = @yui_css.compress(concatenate(paths))
      case variant
      when nil      then compressed_css
      when :datauri then with_data_uris(compressed_css)<commit_msg>only embedding images that live in images/embed<commit_after>module Jammit

  # Uses the YUI Compressor to compress JavaScript and CSS. Also knows how to
  # create a concatenated JST file.
  class Compressor

    MIME_TYPE_MAP = {
      '.png'  => 'image/png',
      '.jpg'  => 'image/jpeg',
      '.jpeg' => 'image/jpeg',
      '.gif'  => 'image/gif',
      '.tif'  => 'image/tiff',
      '.tiff' => 'image/tiff'
    }

    URL_DETECTOR = /url\(['"]?(\/images\/embed\/[^\s)]+)['"]?\)/

    JST_NAMER = /\/(\w+)\.jst\Z/

    def initialize
      @yui_js  = YUI::JavaScriptCompressor.new(:munge => true)
      @yui_css = YUI::CssCompressor.new
    end

    # Delegates to the YUI compressor.
    def compress_js(paths)
      @yui_js.compress(concatenate(paths))
    end

    # Delegates to the YUI compressor.
    def compress_css(paths, variant)
      compressed_css = @yui_css.compress(concatenate(paths))
      case variant
      when nil      then compressed_css
      when :datauri then with_data_uris(compressed_css)
{'fraction_non_alphanumeric': 0.1440040140491721, 'fraction_numerical': 0.0, 'mean_word_length': 2.5734767025089607, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4789523', 'n_tokens_mistral': 739, 'n_tokens_neox': 693, 'n_words': 157}