lib/autobuild/utility.rb in autobuild-1.8.3 vs lib/autobuild/utility.rb in autobuild-1.9.0.b1
- old
+ new
@@ -12,12 +12,15 @@
attr_accessor :source_ref_dir
def initialize(name, package)
@name = name
@package = package
- @enabled = true
+ @available = true
+ @enabled = true
@source_ref_dir = nil
+ @source_dir = nil
+ @target_dir = nil
end
# Directory in which the utility will generate some files The
# interpretation of relative directories is package-specific. The
# default implementation interpret them as relative to the source
@@ -106,22 +109,31 @@
# True if this utility would do something, and false otherwise
#
# This will return true only if a task has been by calling {task} _and_
# the utility has not been explicitly disabled by setting the {enabled}
# attribute to false
+ #
+ # @return [Boolean]
+ def available?
+ @available && (source_dir && @task)
+ end
+
+ # True if this utility should be executed
+ #
+ # @return [Boolean]
def enabled?
- if !@enabled
- return false
- else
- return source_dir && @task
- end
+ @enabled && available?
end
- # Allows to force {enabled?} to return false, regardless of whether
- # {task} has been called or not
+ # Allows to override the utility's availability (i.e. whether this
+ # utility is available on the underlying package) regardless of whether
+ # {task} got called or not
#
- # This is mainly used for package types that have an e.g. documentation
- # task by default, so that some packages can disable it.
+ # This is mainly used to fine-tune packages whose base type enables the
+ # utility (e.g. testing) but the actual package does not have it
+ attr_writer :available
+
+ # Allows to disable the utility regardless of the value of {available?}
attr_writer :enabled
def install
if !File.directory?(source_dir)
raise "#{source_dir} was expected to be a directory, but it is not. Check the package's #{name} generation. The generated #{name} products should be in #{source_dir}"