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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1bb0072ff97d5e5cfa0fbc45bc12d7e62c05fac187e88df2020e8c084bdf6b4b
4
- data.tar.gz: a0274b8b83ea7cbdf008f3257f5423cebbbc6ce2bcd17e57f0dff62b78126902
3
+ metadata.gz: 485026a6d305008958423bb059e470b3d8c5561a6cecc1e0cb33c562df01e255
4
+ data.tar.gz: b9ff4d4852dbdc5a7d6356b7d4bc9691c2c3e38ba9bbd8220e1169a53b8100b7
5
5
  SHA512:
6
- metadata.gz: 15764e9e3ebdfb5857f6b66d634b4bdecfb0d17eea886c10b150628be4210bd9309c3ef831bb58eb4ea40879094e8a28bf20af74e6cd7ba99a29a30705f92c4f
7
- data.tar.gz: 43ee2d405325b327928dea45c0b4463e61878563525930f65c5efc17b8310a4e370cee6366b5d022a6126a47f9fce9f1b30ef7b66a1e6778de3e23f5e80823b7
6
+ metadata.gz: 29500b37adb16288fbd88e504f7b631a2137b36a0cf5a3b544662bef93f8272fdea9d7a16a637d5c9000e95f860b101149f3885185dfdf26a8e506a8763af4e3
7
+ data.tar.gz: 784199112df64433895f31b1a9dc0a9c73b0097d331be26fa3a1d112398e1cdc554d43bc9007b875e3e6d08f687c3e73e8e45323a48404ff59f869a04e5d19a8
@@ -86,43 +86,43 @@ module SemverDialects
86
86
  TILDE = /~/
87
87
  DIGIT = /([0-9]+)/
88
88
  COLON = /:/
89
- NON_ALPHANUMERIC_DASH_AND_TILDE = /[^a-zA-Z0-9~]+/
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
- if !stop_at_release_tag
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(NON_ALPHANUMERIC_DASH_AND_TILDE))
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SemverDialects
4
- VERSION = '3.2.0'
4
+ VERSION = '3.2.1'
5
5
  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.0
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-06-26 00:00:00.000000000 Z
13
+ date: 2024-07-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: pastel