aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cask/lib/hbc/container/executable.rb
diff options
context:
space:
mode:
authorVítor Galvão2017-03-30 15:40:20 +0100
committerGitHub2017-03-30 15:40:20 +0100
commit0882e9ddbc2b4507038d87e21233ce29031b995b (patch)
treeeb9c1b90b2df0d1a19abe3b45f88fe7189582e11 /Library/Homebrew/cask/lib/hbc/container/executable.rb
parentc69e4ee2f6b7cd01d1e0731ce214d26607d1427d (diff)
parent1be120f4c1d7f0be24ead200a6cb0925acc90129 (diff)
downloadbrew-0882e9ddbc2b4507038d87e21233ce29031b995b.tar.bz2
Merge pull request #2410 from reitermarkus/container-exectuable
Add `Container::Executable`.
Diffstat (limited to 'Library/Homebrew/cask/lib/hbc/container/executable.rb')
-rw-r--r--Library/Homebrew/cask/lib/hbc/container/executable.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/container/executable.rb b/Library/Homebrew/cask/lib/hbc/container/executable.rb
new file mode 100644
index 000000000..848f6d4be
--- /dev/null
+++ b/Library/Homebrew/cask/lib/hbc/container/executable.rb
@@ -0,0 +1,18 @@
+require "hbc/container/naked"
+require "vendor/macho/macho"
+
+module Hbc
+ class Container
+ class Executable < Naked
+ def self.me?(criteria)
+ return true if criteria.magic_number(/^#!\s*\S+/)
+
+ begin
+ MachO.open(criteria.path).header.executable?
+ rescue MachO::MagicError
+ false
+ end
+ end
+ end
+ end
+end