From a7861783828182425c2dd7ec8dbc716843ff0f48 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Fri, 25 May 2012 23:44:11 -0500 Subject: 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 --- Library/Homebrew/extend/pathname.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'Library/Homebrew/extend') 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| -- cgit v1.2.3