semver_dialects 3.2.0 → 3.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/semver_dialects/rpm.rb +18 -17
- data/lib/semver_dialects/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 485026a6d305008958423bb059e470b3d8c5561a6cecc1e0cb33c562df01e255
|
4
|
+
data.tar.gz: b9ff4d4852dbdc5a7d6356b7d4bc9691c2c3e38ba9bbd8220e1169a53b8100b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29500b37adb16288fbd88e504f7b631a2137b36a0cf5a3b544662bef93f8272fdea9d7a16a637d5c9000e95f860b101149f3885185dfdf26a8e506a8763af4e3
|
7
|
+
data.tar.gz: 784199112df64433895f31b1a9dc0a9c73b0097d331be26fa3a1d112398e1cdc554d43bc9007b875e3e6d08f687c3e73e8e45323a48404ff59f869a04e5d19a8
|
data/lib/semver_dialects/rpm.rb
CHANGED
@@ -86,43 +86,43 @@ module SemverDialects
|
|
86
86
|
TILDE = /~/
|
87
87
|
DIGIT = /([0-9]+)/
|
88
88
|
COLON = /:/
|
89
|
-
|
89
|
+
NON_ALPHANUMERIC_DASH_TILDE_AND_WHITESPACE = /[^a-zA-Z0-9~\s]+/
|
90
|
+
WHITE_SPACE = /\s/
|
90
91
|
|
91
92
|
def self.parse(input)
|
92
93
|
new(input).parse
|
93
94
|
end
|
94
|
-
|
95
|
+
|
95
96
|
def initialize(input)
|
97
|
+
@input = input
|
96
98
|
@scanner = StringScanner.new(input)
|
97
99
|
end
|
98
|
-
|
100
|
+
|
99
101
|
# parse splits the input string into epoch, version and release tag Eg: <epoch>:<version>-<release_tag>
|
100
102
|
# The version and release tag are split at the first `-` character if present
|
101
103
|
# With the segment before the first `-` being version while the other being release tag
|
102
104
|
# Subsequent `-` are disregarded
|
103
105
|
def parse
|
104
106
|
epoch = nil
|
105
|
-
if s = scanner.scan(/\d+:/)
|
107
|
+
if (s = scanner.scan(/\d+:/))
|
106
108
|
epoch = s[..-2].to_i
|
107
109
|
end
|
108
110
|
|
109
111
|
# parse tokens until we reach the release tag, if any
|
110
112
|
tokens = parse_tokens(false)
|
111
|
-
|
113
|
+
|
112
114
|
# parse release tag
|
113
115
|
release_tag = nil
|
114
|
-
if scanner.rest?
|
115
|
-
release_tag = ReleaseTag.new(parse_tokens(true))
|
116
|
-
end
|
116
|
+
release_tag = ReleaseTag.new(parse_tokens(true)) if scanner.rest?
|
117
117
|
|
118
118
|
raise IncompleteScanError, scanner.rest if scanner.rest?
|
119
|
-
|
119
|
+
|
120
120
|
Version.new(tokens, epoch: epoch, release_tag: release_tag)
|
121
121
|
end
|
122
|
-
|
122
|
+
|
123
123
|
private
|
124
|
-
|
125
|
-
attr_reader :scanner
|
124
|
+
|
125
|
+
attr_reader :scanner, :input
|
126
126
|
|
127
127
|
def parse_tokens(stop_at_release_tag)
|
128
128
|
tokens = []
|
@@ -130,9 +130,7 @@ module SemverDialects
|
|
130
130
|
until scanner.eos?
|
131
131
|
case
|
132
132
|
when (s = scanner.scan(DASH))
|
133
|
-
|
134
|
-
return tokens
|
135
|
-
end
|
133
|
+
return tokens unless stop_at_release_tag
|
136
134
|
# If release tag has been encountered, ignore subsequent dashes
|
137
135
|
when (s = scanner.scan(ALPHABET))
|
138
136
|
tokens << s
|
@@ -140,7 +138,11 @@ module SemverDialects
|
|
140
138
|
tokens << s
|
141
139
|
when (s = scanner.scan(DIGIT))
|
142
140
|
tokens << s.to_i
|
143
|
-
when (s = scanner.scan(
|
141
|
+
when (s = scanner.scan(WHITE_SPACE))
|
142
|
+
# Whitespace is not permitted
|
143
|
+
# https://github.com/rpm-software-management/rpm/blob/4d1b7401415003720ea9bef7bda248f7de4fa025/docs/manual/dependencies.md#versioning
|
144
|
+
raise SemverDialects::InvalidVersionError, input
|
145
|
+
when (s = scanner.scan(NON_ALPHANUMERIC_DASH_TILDE_AND_WHITESPACE))
|
144
146
|
# Non-ascii characters are considered equal
|
145
147
|
# so they are ignored when parsing versions
|
146
148
|
# https://github.com/rpm-software-management/rpm/blob/rpm-4.19.1.1-release/tests/rpmvercmp.at#L143
|
@@ -151,6 +153,5 @@ module SemverDialects
|
|
151
153
|
tokens
|
152
154
|
end
|
153
155
|
end
|
154
|
-
|
155
156
|
end
|
156
157
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: semver_dialects
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julian Thome
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2024-
|
13
|
+
date: 2024-07-02 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: pastel
|