Class: Dependabot::Gradle::Requirement
- Inherits:
-
Gem::Requirement
- Object
- Gem::Requirement
- Dependabot::Gradle::Requirement
- Defined in:
- lib/dependabot/gradle/requirement.rb
Constant Summary collapse
- PATTERN_RAW =
"\\s*(#{quoted})?\\s*(#{Gradle::Version::VERSION_PATTERN})\\s*"
- PATTERN =
/\A#{PATTERN_RAW}\z/.freeze
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.
33 34 35 36 37 38 39 |
# File 'lib/dependabot/gradle/requirement.rb', line 33 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
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/dependabot/gradle/requirement.rb', line 14 def self.parse(obj) return ["=", Gradle::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] || "=", Gradle::Version.new(matches[2])] end |
.requirements_array(requirement_string) ⇒ Object
27 28 29 30 31 |
# File 'lib/dependabot/gradle/requirement.rb', line 27 def self.requirements_array(requirement_string) split_java_requirement(requirement_string).map do |str| new(str) end end |