lib/jammit/compressor.rb in jammit-0.5.4 vs lib/jammit/compressor.rb in jammit-0.6.0

- old
+ new

@@ -20,11 +20,11 @@ '.woff' => 'font/woff' } # Font extensions for which we allow embedding: EMBED_EXTS = EMBED_MIME_TYPES.keys - EMBED_FONTS = ['.ttf', '.otf'] + EMBED_FONTS = ['.ttf', '.otf', '.woff'] # (32k - padding) maximum length for data-uri assets (an IE8 limitation). MAX_IMAGE_SIZE = 32700 # CSS asset-embedding regexes for URL rewriting. @@ -126,11 +126,11 @@ # Determine the name of a JS template. If there's a common base path, use # the namespaced prefix. Otherwise, simply use the filename. def template_name(path, base_path) return File.basename(path, ".#{Jammit.template_extension}") unless base_path - path.gsub(/\A#{base_path}\/(.*)\.#{Jammit.template_extension}\Z/, '\1') + path.gsub(/\A#{Regexp.escape(base_path)}\/(.*)\.#{Jammit.template_extension}\Z/, '\1') end # In order to support embedded assets from relative paths, we need to # expand the paths before contatenating the CSS together and losing the # location of the original stylesheet path. Validate the assets while we're @@ -242,10 +242,10 @@ [paths].flatten.map {|p| read_binary_file(p) }.join("\n") end # `File.read`, but in "binary" mode. def read_binary_file(path) - File.open(path, 'r:binary') {|f| f.read } + File.open(path, 'rb') {|f| f.read } end end end