Skip to content

Commit

Permalink
Added Text::Patterns::VERSION_RANGE (closes #556).
Browse files Browse the repository at this point in the history
  • Loading branch information
postmodern committed Dec 12, 2024
1 parent 5ac0a70 commit 119769c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/ronin/support/text/patterns/software.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ module Patterns
#
# @since 1.2.0
VERSION_CONSTRAINT = /(?:>=|>|<=|<|=)\s*#{VERSION_NUMBER}/

# Regular expression for finding version ranges in text.
#
# @since 1.2.0
VERSION_RANGE = /#{VERSION_CONSTRAINT}(?:(?:,\s*|\s+)#{VERSION_CONSTRAINT})?/
end
end
end
Expand Down
20 changes: 20 additions & 0 deletions spec/text/patterns/software_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -908,4 +908,24 @@
expect('=1.2.3').to fully_match(subject)
end
end

describe "VERSION_RANGE" do
subject { described_class::VERSION_RANGE }

it "must match '>= X.Y.Z, < A.B.C'" do
expect('>= 1.2.3, < 2.0.0').to fully_match(subject)
end

it "must match '>=X.Y.Z,<A.B.C'" do
expect('>=1.2.3,<2.0.0').to fully_match(subject)
end

it "must match '>= X.Y.Z < A.B.C'" do
expect('>= 1.2.3 < 2.0.0').to fully_match(subject)
end

it "must match '>=X.Y.Z <A.B.C'" do
expect('>=1.2.3 <2.0.0').to fully_match(subject)
end
end
end

0 comments on commit 119769c

Please sign in to comment.