Class: Dependabot::Maven::Requirement
- Inherits:
-
Requirement
- Object
- Requirement
- Dependabot::Maven::Requirement
- Extended by:
- T::Sig
- Defined in:
- lib/dependabot/maven/requirement.rb
Constant Summary collapse
- OR_SYNTAX =
/(?<=\]|\)),/
- PATTERN_RAW =
"\\s*(#{quoted})?\\s*(#{Maven::Version::VERSION_PATTERN})\\s*".freeze
- PATTERN =
/\A#{PATTERN_RAW}\z/
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*requirements) ⇒ Requirement
constructor
A new instance of Requirement.
- #satisfied_by?(version) ⇒ Boolean
Constructor Details
#initialize(*requirements) ⇒ Requirement
Returns a new instance of Requirement.
40 41 42 43 44 45 46 |
# File 'lib/dependabot/maven/requirement.rb', line 40 def initialize(*requirements) requirements = requirements.flatten.flat_map do |req_string| convert_java_constraint_to_ruby_constraint(req_string) end super(requirements) end |
Class Method Details
.parse(obj) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/dependabot/maven/requirement.rb', line 20 def self.parse(obj) return ["=", Maven::Version.new(obj.to_s)] if obj.is_a?(Gem::Version) unless (matches = PATTERN.match(obj.to_s)) msg = "Illformed requirement [#{obj.inspect}]" raise BadRequirementError, msg end return DefaultRequirement if matches[1] == ">=" && matches[2] == "0" [matches[1] || "=", Maven::Version.new(T.must(matches[2]))] end |
.requirements_array(requirement_string) ⇒ Object
34 35 36 37 38 |
# File 'lib/dependabot/maven/requirement.rb', line 34 def self.requirements_array(requirement_string) split_java_requirement(requirement_string).map do |str| new(str) end end |