uuid-ncname 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/uuid/ncname.rb +23 -0
- data/lib/uuid/ncname/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e77f488ca6429c6b7799b8ae23f673c2d17ae2914abaebfb8411cd4408ce498
|
4
|
+
data.tar.gz: a744fad35027fd23aa64795baceeae5b940ef711d475a2e726f5c423df05997c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37652d6a314d6629164f0d616bafa99185cb3d044e9908492d91d5d77a87c13308f5ce894b1a3c05bb382ae9a1cb825e90aaf00152690816a1c2e737b7d20066
|
7
|
+
data.tar.gz: 5740a1c557cbee7efe37ec3af6f3145a83010222cb3f91159fa9500d161c45279e9208d4cb11141197995d7cb9410e2b28dc69e4bcd8d8e30e4c3f1636c2682e
|
data/lib/uuid/ncname.rb
CHANGED
@@ -327,4 +327,27 @@ module UUID::NCName
|
|
327
327
|
from_ncname ncname, radix: 32, format: format
|
328
328
|
end
|
329
329
|
|
330
|
+
# Test if the given token is a UUID NCName, with a hint to its version.
|
331
|
+
#
|
332
|
+
# @param token [#to_s] The token to test
|
333
|
+
#
|
334
|
+
# @return [false, 0, 1]
|
335
|
+
def self.valid? token
|
336
|
+
token = token.to_s
|
337
|
+
if /^[A-P](?:[0-9A-Za-z_-]{21}|[2-7A-Za-z]{25})$/.match token
|
338
|
+
# false is definitely version zero but true is only maybe version 1
|
339
|
+
version = /[IJKLijkl]$/.match(token) ? 1 : 0
|
340
|
+
|
341
|
+
if version == 1
|
342
|
+
uu = from_ncname token, version: 1
|
343
|
+
# lol even this isn't a guarantee
|
344
|
+
/[89ab]/.match(uu[19]) ? 1 : version
|
345
|
+
else
|
346
|
+
version
|
347
|
+
end
|
348
|
+
else
|
349
|
+
false
|
350
|
+
end
|
351
|
+
end
|
352
|
+
|
330
353
|
end
|
data/lib/uuid/ncname/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uuid-ncname
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dorian Taylor
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: base32
|
@@ -110,8 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
110
|
- !ruby/object:Gem::Version
|
111
111
|
version: '0'
|
112
112
|
requirements: []
|
113
|
-
|
114
|
-
rubygems_version: 2.7.6
|
113
|
+
rubygems_version: 3.0.3
|
115
114
|
signing_key:
|
116
115
|
specification_version: 4
|
117
116
|
summary: Format a UUID as a valid NCName.
|