Created
September 27, 2011 17:54
-
-
Save aboisvert/1245748 to your computer and use it in GitHub Desktop.
Monkey patching Buildr's Mapper class to avoid resource filtering of binary file s
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Buildr | |
| class Filter | |
| class Mapper | |
| alias_method :transform_old, :transform | |
| BINARY_FILES = [ '*.png', '*.gif' ] | |
| def is_binary?(content, path) | |
| BINARY_FILES.any? { |glob| File.fnmatch(glob, path) } | |
| end | |
| def transform(content, path = nil) | |
| return content if is_binary?(content, path) | |
| transform_old(content, path) | |
| end | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment