aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJack Nagel2012-12-23 19:44:15 -0600
committerJack Nagel2012-12-26 14:37:02 -0600
commitf8d253950fe9c711a3743266d09effb37cdc5bd3 (patch)
tree1a8b753390ea98f58e188cc47cdd3ce8d0cfefb9 /Library
parenta358bee8e2ae3823dae03cd54bf1edd0d32cefe6 (diff)
downloadbrew-f8d253950fe9c711a3743266d09effb37cdc5bd3.tar.bz2
Add a small DSL for setting requirement options
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/dependencies.rb10
-rw-r--r--Library/Homebrew/requirements.rb27
2 files changed, 21 insertions, 16 deletions
diff --git a/Library/Homebrew/dependencies.rb b/Library/Homebrew/dependencies.rb
index e12cfb22a..be6e0cf9d 100644
--- a/Library/Homebrew/dependencies.rb
+++ b/Library/Homebrew/dependencies.rb
@@ -159,7 +159,9 @@ class Requirement
# Should return true if this requirement is met.
def satisfied?; false; end
# Should return true if not meeting this requirement should fail the build.
- def fatal?; false; end
+ def fatal?
+ self.class.fatal || false
+ end
# The message to show when the requirement is not met.
def message; ""; end
@@ -174,6 +176,12 @@ class Requirement
def hash
message.hash
end
+
+ class << self
+ def fatal(val=nil)
+ val.nil? ? @fatal : @fatal = val
+ end
+ end
end
require 'requirements'
diff --git a/Library/Homebrew/requirements.rb b/Library/Homebrew/requirements.rb
index 84c2ba6d1..dcf9afcd7 100644
--- a/Library/Homebrew/requirements.rb
+++ b/Library/Homebrew/requirements.rb
@@ -1,13 +1,13 @@
# A dependency on a language-specific module.
class LanguageModuleDependency < Requirement
+ fatal true
+
def initialize language, module_name, import_name=nil
@language = language
@module_name = module_name
@import_name = import_name || module_name
end
- def fatal?; true; end
-
def satisfied?
quiet_system(*the_test)
end
@@ -53,14 +53,14 @@ class X11Dependency < Requirement
include Comparable
attr_reader :min_version
+ fatal true
+
def initialize(*tags)
tags.flatten!
@min_version = tags.shift if /(\d\.)+\d/ === tags.first
super
end
- def fatal?; true; end
-
def satisfied?
MacOS::XQuartz.installed? and (@min_version.nil? or @min_version <= MacOS::XQuartz.version)
end
@@ -100,14 +100,14 @@ class MPIDependency < Requirement
attr_reader :lang_list
+ fatal true
+
def initialize *lang_list
@lang_list = lang_list
@non_functional = []
@unknown_langs = []
end
- def fatal?; true; end
-
def mpi_wrapper_works? compiler
compiler = which compiler
return false if compiler.nil? or not compiler.executable?
@@ -170,13 +170,15 @@ class MPIDependency < Requirement
EOS
end
end
-
end
# This requirement added by the `conflicts_with` DSL method.
class ConflictRequirement < Requirement
attr_reader :formula
+ # The user can chose to force installation even in the face of conflicts.
+ fatal !ARGV.force?
+
def initialize formula, name, opts={}
@formula = formula
@name = name
@@ -199,15 +201,10 @@ class ConflictRequirement < Requirement
keg = Formula.factory(@formula).prefix
not keg.exist? && Keg.new(keg).linked?
end
-
- # The user can chose to force installation even in the face of conflicts.
- def fatal?
- not ARGV.force?
- end
end
class XcodeDependency < Requirement
- def fatal?; true; end
+ fatal true
def satisfied?
MacOS::Xcode.installed?
@@ -221,7 +218,7 @@ class XcodeDependency < Requirement
end
class MysqlInstalled < Requirement
- def fatal?; true; end
+ fatal true
def satisfied?
which 'mysql_config'
@@ -244,7 +241,7 @@ class MysqlInstalled < Requirement
end
class PostgresqlInstalled < Requirement
- def fatal?; true; end
+ fatal true
def satisfied?
which 'pg_config'