Permalink
Browse files

patches.rb: Generalize File recognition

Extend patch case statements for files to objects inheriting from `IO`, which
includes `File`, or `StringIO` which is used by the external command
`brew-unpack` to store `DATA` sections loaded from Formula files.
  • Loading branch information...
1 parent b910c62 commit b01c5e00733ad1768ad1e09b5d47e2a87813a044 @Sharpie Sharpie committed Sep 12, 2012
Showing with 4 additions and 1 deletion.
  1. +4 −1 Library/Homebrew/patches.rb
@@ -1,3 +1,5 @@
+require 'stringio'
+
class Patches
include Enumerable
@@ -72,7 +74,8 @@ def initialize patch_p, filename, url
@compression = nil
@url = nil
- if url.kind_of? File # true when DATA is passed
+ if url.kind_of? IO or url.kind_of? StringIO
+ # File-like objects. Most common when DATA is passed.
write_data url
elsif looks_like_url(url)
@url = url # Save URL to mark this as an external patch

0 comments on commit b01c5e0

Please sign in to comment.