aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/extend/pathname.rb
diff options
context:
space:
mode:
authorJack Nagel2012-05-25 23:44:11 -0500
committerJack Nagel2012-05-30 22:32:48 -0500
commita7861783828182425c2dd7ec8dbc716843ff0f48 (patch)
tree83b4e046d0990b304ffa84067977d74955d07e4f /Library/Homebrew/extend/pathname.rb
parentb6e0dfed2385ee61f6c55907b407cbaefb411ea6 (diff)
downloadbrew-a7861783828182425c2dd7ec8dbc716843ff0f48.tar.bz2
Pathname: add Mach-O module
The MachO module contains methods for learning about Mach-O binaries, and can be used where one might normally shell out to file(1). Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Diffstat (limited to 'Library/Homebrew/extend/pathname.rb')
-rw-r--r--Library/Homebrew/extend/pathname.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb
index 98618be41..bd0e6154e 100644
--- a/Library/Homebrew/extend/pathname.rb
+++ b/Library/Homebrew/extend/pathname.rb
@@ -1,8 +1,11 @@
require 'pathname'
require 'bottles'
+require 'mach'
# we enhance pathname to make our code more readable
class Pathname
+ include MachO
+
def install *sources
results = []
sources.each do |src|
@@ -268,6 +271,10 @@ class Pathname
end
end
+ def text_executable?
+ %r[#!\s*(/.+)+] === open('r') { |f| f.readline }
+ end
+
def incremental_hash(hasher)
incr_hash = hasher.new
self.open('r') do |f|