uuid-ncname 0.4.0 → 0.4.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: 471f6d4d6e5124454b7bcc1a7ab46fc3f6fbf6951f4ba988c80a9b04f0051be1
4
- data.tar.gz: 03265d39a6f8b4c38ad9d86ddab9753563216c4ac3421a5cff9f38f1e536d4e1
3
+ metadata.gz: 95ef04d6f41f5d6b98fc5dbd814ef77d7b24e845b212a20fe73a79b2914d2cb0
4
+ data.tar.gz: ca0c34414228e1aba0b9d430d322bd8a62d533fcc93586a8735f7d64412aac24
5
5
  SHA512:
6
- metadata.gz: 311e0f9856467d875782d37ac759ec2479d74276ad2ec427588954ab22335e233d69f2d32e6ceaf20a24e91eba8a2cd780721f89f5a829c7acf346ab78b20401
7
- data.tar.gz: d9458bc9b998ac9fb0d5450e66a73d49bbc5bd546250d221045c4b17361cc9a02fa9a0c9b2dbf012686e4bc0c60336635b6946e7f531a8ba80900336e24affa9
6
+ metadata.gz: ba2311769361dc7646e354afdf58421e4b2e8f2f3e57780edb340dc9a45900958b793c5ac2bbe0fff124f364b922ff700a2867cbdd74108e7f31cc40255c431a
7
+ data.tar.gz: d0cfeb74e954dd45b0322771327f022040f8fbe22bebb47ef688b970e790b4d7966a8eb418c5fa8ee097b66d08fb73854355c71d255fb8c1c0d53fbc3b360f89
@@ -6,5 +6,5 @@ unless Module.const_defined? 'UUID'
6
6
  end
7
7
 
8
8
  module UUID::NCName
9
- VERSION = "0.4.0"
9
+ VERSION = "0.4.1"
10
10
  end
data/lib/uuid/ncname.rb CHANGED
@@ -212,7 +212,7 @@ module UUID::NCName
212
212
  # @param version [0, 1] An optional formatting version, where 0 is
213
213
  # the naïve original version and 1 moves the `variant` nybble out
214
214
  # to the end of the identifier. The default version is 1.
215
- #
215
+ #
216
216
  # @param align [true, false] Optional directive to treat the
217
217
  # terminating character as aligned to the numerical base of the
218
218
  # representation. Since the version nybble is removed from the
@@ -224,7 +224,7 @@ module UUID::NCName
224
224
  # and the terminating character is aligned, RFC4122-compliant UUIDs
225
225
  # will always terminate with `I`, `J`, `K`, or `L`. Defaults to
226
226
  # `true`.
227
- #
227
+ #
228
228
  # @return [String] The NCName-formatted UUID.
229
229
  #
230
230
  def self.to_ncname uuid, radix: 64, version: nil, align: true
@@ -244,7 +244,7 @@ module UUID::NCName
244
244
  if uuid.length == 16
245
245
  bin = uuid
246
246
  else
247
- uuid.gsub!(/\s+/, '')
247
+ uuid = uuid.gsub(/\s+/, '')
248
248
  if (m = /^(?:urn:uuid:)?([0-9A-Fa-f-]{32,})$/.match(uuid))
249
249
  bin = [m[1].tr('-', '')].pack 'H*'
250
250
  elsif (m = /^([0-9A-Za-z+\/_-]+=*)$/.match(uuid))
@@ -269,7 +269,7 @@ module UUID::NCName
269
269
  #
270
270
  # @param ncname [#to_s] an NCName-encoded UUID, either a
271
271
  # 22-character (Base64) variant, or a 26-character (Base32) variant.
272
- #
272
+ #
273
273
  # @param radix [nil, 32, 58, 64] Optional radix; will use a heuristic
274
274
  # if omitted.
275
275
  #
@@ -277,7 +277,7 @@ module UUID::NCName
277
277
  # parameter; defaults to `:str`, the canonical string representation.
278
278
  #
279
279
  # @param version [0, 1] See ::to_ncname. Defaults to 1.
280
- #
280
+ #
281
281
  # @param align [nil, true, false] See ::to_ncname for details.
282
282
  # Setting this parameter to `nil`, the default, will cause the
283
283
  # decoder to detect the alignment state from the identifier.
@@ -335,9 +335,9 @@ module UUID::NCName
335
335
  # Shorthand for conversion to the Base64 version
336
336
  #
337
337
  # @param uuid [#to_s] The UUID
338
- #
338
+ #
339
339
  # @param version [0, 1] See ::to_ncname.
340
- #
340
+ #
341
341
  # @param align [true, false] See ::to_ncname.
342
342
  #
343
343
  # @return [String] The Base64-encoded NCName
@@ -351,9 +351,9 @@ module UUID::NCName
351
351
  # @param ncname [#to_s] The Base64 variant of the NCName-encoded UUID
352
352
  #
353
353
  # @param format [:str, :hex, :b64, :bin] The format
354
- #
354
+ #
355
355
  # @param version [0, 1] See ::to_ncname.
356
- #
356
+ #
357
357
  # @param align [true, false] See ::to_ncname.
358
358
  #
359
359
  # @return [String, nil] The corresponding UUID or nil if the input
@@ -367,9 +367,9 @@ module UUID::NCName
367
367
  # Shorthand for conversion to the Base58 version
368
368
  #
369
369
  # @param uuid [#to_s] The UUID
370
- #
370
+ #
371
371
  # @param version [0, 1] See ::to_ncname.
372
- #
372
+ #
373
373
  # @param align [true, false] See ::to_ncname.
374
374
  #
375
375
  # @return [String] The Base58-encoded NCName
@@ -383,9 +383,9 @@ module UUID::NCName
383
383
  # @param ncname [#to_s] The Base58 variant of the NCName-encoded UUID
384
384
  #
385
385
  # @param format [:str, :hex, :b64, :bin] The format
386
- #
386
+ #
387
387
  # @param version [0, 1] See ::to_ncname.
388
- #
388
+ #
389
389
  # @param align [true, false] See ::to_ncname.
390
390
  #
391
391
  # @return [String, nil] The corresponding UUID or nil if the input
@@ -399,9 +399,9 @@ module UUID::NCName
399
399
  # Shorthand for conversion to the Base32 version
400
400
  #
401
401
  # @param uuid [#to_s] The UUID
402
- #
402
+ #
403
403
  # @param version [0, 1] See ::to_ncname.
404
- #
404
+ #
405
405
  # @param align [true, false] See ::to_ncname.
406
406
  #
407
407
  # @return [String] The Base32-encoded NCName
@@ -415,9 +415,9 @@ module UUID::NCName
415
415
  # @param ncname [#to_s] The Base32 variant of the NCName-encoded UUID
416
416
  #
417
417
  # @param format [:str, :hex, :b64, :bin] The format
418
- #
418
+ #
419
419
  # @param version [0, 1] See ::to_ncname.
420
- #
420
+ #
421
421
  # @param align [true, false] See ::to_ncname.
422
422
  #
423
423
  # @return [String, nil] The corresponding UUID or nil if the input
@@ -451,7 +451,7 @@ module UUID::NCName
451
451
  # false is definitely version zero but true is only maybe version 1
452
452
  version = /^(?:.{21}[I-L]|.{25}[I-Li-l])$/.match(token) ? 1 : 0
453
453
 
454
- # try decoding with validation on
454
+ # try decoding with validation on
455
455
  uu = from_ncname token, version: version, validate: true
456
456
 
457
457
  # note that version 1 will always return something because the
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'uuid-ncname'
4
+ require 'csv'
5
+ require 'pathname'
6
+ require 'uuidtools'
7
+
8
+ out = Pathname(ARGV.first).expand_path
9
+
10
+ CSV.open(out, 'wb') do |csv|
11
+ uuids = []
12
+ 1000.times { uuids << UUIDTools::UUID.random_create }
13
+
14
+ # do the version first
15
+ (0..1).each do |v|
16
+ # then he radices
17
+ uuids.each do |u|
18
+ row = [v, u.to_s]
19
+
20
+ [32, 58, 64].each do |r|
21
+ row << UUID::NCName.to_ncname(u, radix: r, version: v)
22
+ end
23
+
24
+ csv << row
25
+ end
26
+ end
27
+ end
28
+