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 +(?:(?!\. (?:tar|tgz|tbz|zip|rar|txt|htm|xml))[._-][A-Za-z0-9]+)*/
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 931
931
end
932
932
end
933
933
end
934
+
935
+ describe "VERSION_CONSTRAINT" do
936
+ subject { described_class ::VERSION_CONSTRAINT }
937
+
938
+ it "must match '>= X.Y.Z'" do
939
+ expect ( '>= 1.2.3' ) . to fully_match ( subject )
940
+ end
941
+
942
+ it "must match '> X.Y.Z'" do
943
+ expect ( '> 1.2.3' ) . to fully_match ( subject )
944
+ end
945
+
946
+ it "must match '<= X.Y.Z'" do
947
+ expect ( '<= 1.2.3' ) . to fully_match ( subject )
948
+ end
949
+
950
+ it "must match '< X.Y.Z'" do
951
+ expect ( '< 1.2.3' ) . to fully_match ( subject )
952
+ end
953
+
954
+ it "must match '= X.Y.Z'" do
955
+ expect ( '= 1.2.3' ) . to fully_match ( subject )
956
+ end
957
+
958
+ it "must match '>=X.Y.Z'" do
959
+ expect ( '>=1.2.3' ) . to fully_match ( subject )
960
+ end
961
+
962
+ it "must match '>X.Y.Z'" do
963
+ expect ( '>1.2.3' ) . to fully_match ( subject )
964
+ end
965
+
966
+ it "must match '<=X.Y.Z'" do
967
+ expect ( '<=1.2.3' ) . to fully_match ( subject )
968
+ end
969
+
970
+ it "must match '<X.Y.Z'" do
971
+ expect ( '<1.2.3' ) . to fully_match ( subject )
972
+ end
973
+
974
+ it "must match '=X.Y.Z'" do
975
+ expect ( '=1.2.3' ) . to fully_match ( subject )
976
+ end
977
+ end
934
978
end
You can’t perform that action at this time.
0 commit comments