File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed
lib/ronin/support/text/patterns Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,11 @@ module Patterns
31
31
#
32
32
# @since 1.0.0
33
33
VERSION_NUMBER = /\d +(?:\. \d +){1,3}(?:[-.]?[A-Za-z]+(?:[-.]?\d +)?)?/
34
+
35
+ # Regular expression for finding version constraints in text.
36
+ #
37
+ # @since 1.2.0
38
+ VERSION_CONSTRAINT = /(?:>=|>|<=|<|=)\s *#{ VERSION_NUMBER } /
34
39
end
35
40
end
36
41
end
Original file line number Diff line number Diff line change 864
864
expect ( version ) . to fully_match ( subject )
865
865
end
866
866
end
867
+
868
+ describe "VERSION_CONSTRAINT" do
869
+ subject { described_class ::VERSION_CONSTRAINT }
870
+
871
+ it "must match '>= X.Y.Z'" do
872
+ expect ( '>= 1.2.3' ) . to fully_match ( subject )
873
+ end
874
+
875
+ it "must match '> X.Y.Z'" do
876
+ expect ( '> 1.2.3' ) . to fully_match ( subject )
877
+ end
878
+
879
+ it "must match '<= X.Y.Z'" do
880
+ expect ( '<= 1.2.3' ) . to fully_match ( subject )
881
+ end
882
+
883
+ it "must match '< X.Y.Z'" do
884
+ expect ( '< 1.2.3' ) . to fully_match ( subject )
885
+ end
886
+
887
+ it "must match '= X.Y.Z'" do
888
+ expect ( '= 1.2.3' ) . to fully_match ( subject )
889
+ end
890
+
891
+ it "must match '>=X.Y.Z'" do
892
+ expect ( '>=1.2.3' ) . to fully_match ( subject )
893
+ end
894
+
895
+ it "must match '>X.Y.Z'" do
896
+ expect ( '>1.2.3' ) . to fully_match ( subject )
897
+ end
898
+
899
+ it "must match '<=X.Y.Z'" do
900
+ expect ( '<=1.2.3' ) . to fully_match ( subject )
901
+ end
902
+
903
+ it "must match '<X.Y.Z'" do
904
+ expect ( '<1.2.3' ) . to fully_match ( subject )
905
+ end
906
+
907
+ it "must match '=X.Y.Z'" do
908
+ expect ( '=1.2.3' ) . to fully_match ( subject )
909
+ end
910
+ end
867
911
end
You can’t perform that action at this time.
0 commit comments