cuid2 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: abf9155d7edfc94b9696e7748c4b1a34abd31904d7caebde99eea9f1ccb29fc0
4
- data.tar.gz: 71fadc184e73e10ef95fd0e98875c53b02838f10305d01bb3249ebd3a6953eda
3
+ metadata.gz: bd089934aa9c92e1a739506370ddd051a7ac547ce4f0d146384aba1441161653
4
+ data.tar.gz: b79970213bb1c370211bb8138dd61e863905ff32abaf8d2b844b21659bbc10db
5
5
  SHA512:
6
- metadata.gz: e6ebadaaf263c633c372e7450a452146c06231870b5423bcb9f97bb130654ef7de366fb35529184892225522c10d1233b7ceef2df28b41f729ea6d6077f8f21c
7
- data.tar.gz: 0ccdbd78a19f4f601f0a989da3c29110f3bafd83558718d6e2fdf01f786870f3caaa30eb46e49ec94fe857f1b8fc72339e648fe8d85ec9c1f0855bab71c41b08
6
+ metadata.gz: 26d91b851afeaddcb9dcc0b81cba723083fa419f0c6cfe4fb3193f4b6967a22eecde8cde2dfcc4cbea8308b42bd9a7c380d22677b86d6c1dc5820df5d821bd1f
7
+ data.tar.gz: f59aee5706e5b33b7787670e8816a7b773ade28322de2b8a75bc93716aefb7417f423a1cd9ce1ada56fc2f1ebb681f7eeb5b5c49aca109c81ae9cbce5f8771b2
data/CHANGELOG.md CHANGED
@@ -3,3 +3,16 @@
3
3
  ## [0.1.0] - 2023-02-18
4
4
 
5
5
  - Initial release
6
+
7
+ ## [1.0.1] - 2024-03-26
8
+
9
+ #### *Add random first character to CUID*
10
+
11
+ This commit introduces a change to the CUID generation process. Now, each
12
+ CUID starts with a random letter from 'a' to 'z'. This change is intended
13
+ to increase the uniqueness of each CUID and reduce the likelihood of
14
+ collisions.
15
+
16
+ The tests have been updated to reflect this change. A new test has been
17
+ added to ensure that the first character of the CUID is not always the
18
+ same.
data/lib/cuid2/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cuid2
4
- VERSION = '1.0.0'
4
+ VERSION = '1.0.1'
5
5
  end
data/lib/cuid2.rb CHANGED
@@ -42,6 +42,7 @@ module Cuid2
42
42
 
43
43
  class << self
44
44
  def call(length = DEFAULT_LENGTH)
45
+ random_letter = ('a'..'z').to_a[(rand * 26).floor]
45
46
  hash_input = (time + Entropy.create(length) + count + fingerprint).to_s
46
47
 
47
48
  "#{random_letter}#{Cuid2::Hash.create(hash_input, length)[2..length]}"
@@ -67,10 +68,6 @@ module Cuid2
67
68
  (rand + 1) * 2057
68
69
  end
69
70
 
70
- def random_letter
71
- ('a'..'z').to_a[(random * 26).floor]
72
- end
73
-
74
71
  def fingerprint
75
72
  Cuid2::Hash.create("#{((random + 1) * 2063).floor} #{Object.constants.map(&:to_s)}")
76
73
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cuid2
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rubens Stulzer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-02-18 00:00:00.000000000 Z
11
+ date: 2024-03-31 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Secure, collision-resistant ids optimized for horizontal scaling and
14
14
  performance.Next generation UUIDs. Need unique ids in your app? Forget UUIDs which
@@ -51,7 +51,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
51
51
  - !ruby/object:Gem::Version
52
52
  version: '0'
53
53
  requirements: []
54
- rubygems_version: 3.4.6
54
+ rubygems_version: 3.4.21
55
55
  signing_key:
56
56
  specification_version: 4
57
57
  summary: Cuid2 is a Ruby implementation of the Cuid2 algorithm by Eric Elliott.