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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c40b900f91a97e6ffd7bed9026c186c07985a87ff4fd94f438002a813218a91b
4
- data.tar.gz: 80a0fb1fb4845b7f85e5279797835ef3afdebb3e82601ef1ed7823d6f48b252a
3
+ metadata.gz: 4e77f488ca6429c6b7799b8ae23f673c2d17ae2914abaebfb8411cd4408ce498
4
+ data.tar.gz: a744fad35027fd23aa64795baceeae5b940ef711d475a2e726f5c423df05997c
5
5
  SHA512:
6
- metadata.gz: c73f9374cdadee8a324b017571886a25f625f1b22a78aeaf8294d53b254ebfd8d768029f05b86110d626d0e23410b017359e0af87b5a81d997b0ca8ae5e5f970
7
- data.tar.gz: 4cf117345543d68a4254d5f74a13fdbcdcead2bf0ef9a09712aa4f176be96a7cdec21d4d10db49aa559153142accb1ec7d3c88cec507d03c0530028bf7732671
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
@@ -3,5 +3,5 @@ unless Module.const_defined? 'UUID'
3
3
  end
4
4
 
5
5
  module UUID::NCName
6
- VERSION = "0.2.2"
6
+ VERSION = "0.2.3"
7
7
  end
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.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: 2018-08-25 00:00:00.000000000 Z
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
- rubyforge_project:
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.