module Buildr::ArtifactSearch
Search best artifact version from remote repositories
Public Instance Methods
best_version(spec, *methods)
click to toggle source
TODO: return the url for best matching repo
# File lib/buildr/packaging/artifact_search.rb, line 33 def best_version(spec, *methods) spec = Artifact.to_hash(spec) spec[:version] = requirement = VersionRequirement.create(spec[:version]) select = lambda do |candidates| candidates.find { |candidate| requirement.satisfied_by?(candidate) } end result = nil methods = search_methods if methods.empty? if requirement.composed? until result || methods.empty? method = methods.shift type = method.keys.first from = method[type] if (include.empty? || !(include & [:all, type, from]).empty?) && (exclude & [:all, type, from]).empty? if from.respond_to?(:call) versions = from.call(spec.dup) else versions = send("#{type}_versions", spec.dup, *from) end result = select[versions] end end end result ||= requirement.default raise "Could not find #{Artifact.to_spec(spec)}" + "\n You may need to use an specific version instead of a requirement" unless result spec.merge :version => result end
exclude(method = nil)
click to toggle source
# File lib/buildr/packaging/artifact_search.rb, line 28 def exclude(method = nil) (@excludes ||= []).tap { push method if method } end
include(method = nil)
click to toggle source
# File lib/buildr/packaging/artifact_search.rb, line 24 def include(method = nil) (@includes ||= []).tap { push method if method } end
requirement?(spec)
click to toggle source
# File lib/buildr/packaging/artifact_search.rb, line 63 def requirement?(spec) VersionRequirement.requirement?(spec[:version]) end