cuid2 0.1.0 → 1.0.0

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: d073902862a8146e76858ff1e28d218f9c61bc86b44b91827b6bacaa25361823
4
- data.tar.gz: 070ed76bfff065d1dd51149096e88c7b9fe593adcd462d219c99ce3f4ef264d4
3
+ metadata.gz: abf9155d7edfc94b9696e7748c4b1a34abd31904d7caebde99eea9f1ccb29fc0
4
+ data.tar.gz: 71fadc184e73e10ef95fd0e98875c53b02838f10305d01bb3249ebd3a6953eda
5
5
  SHA512:
6
- metadata.gz: 4fb0a7e863fb5097090493e0a1ff64238a0523255224f7cf5728ff264d781c2a2c04041041a7e539c556e49c812b63134844608e3e656d2c1eb98149c46056fe
7
- data.tar.gz: 2f45bd473652443707359b676a6340719b268743e832e6224a7cbb6404521206040daca4f3d9f5db963e5296db2a12b88078cf673399e7c7fb767027d164db13
6
+ metadata.gz: e6ebadaaf263c633c372e7450a452146c06231870b5423bcb9f97bb130654ef7de366fb35529184892225522c10d1233b7ceef2df28b41f729ea6d6077f8f21c
7
+ data.tar.gz: 0ccdbd78a19f4f601f0a989da3c29110f3bafd83558718d6e2fdf01f786870f3caaa30eb46e49ec94fe857f1b8fc72339e648fe8d85ec9c1f0855bab71c41b08
data/.rubocop.yml CHANGED
@@ -1,6 +1,5 @@
1
1
  AllCops:
2
- Enabled: true
3
- TargetRubyVersion: 2.6
2
+ TargetRubyVersion: 3.2
4
3
 
5
4
  Style/StringLiterals:
6
5
  Enabled: true
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Rubens Stulzer
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -16,6 +16,25 @@ If bundler is not being used to manage dependencies, install the gem by executin
16
16
 
17
17
  $ gem install cuid2
18
18
 
19
+ ## Usage
20
+
21
+ First require it.
22
+
23
+ ```ruby
24
+ require 'cuid2'
25
+ ```
26
+
27
+ Generate a Cuid2 with call.
28
+
29
+ ```
30
+ Cuid2.generate
31
+ => "zw881lkfxx644yknviucss31"
32
+ Cuid2.call
33
+ => "yra4dr2qteivp6kkur89gd11"
34
+ Cuid2.()
35
+ => "cr6x94qpqagcgbay780xifun"
36
+ ```
37
+
19
38
  ## Contributing
20
39
 
21
40
  Bug reports and pull requests are welcome on GitHub at https://github.com/stulzer/cuid2. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/stulzer/cuid2/blob/main/CODE_OF_CONDUCT.md).
data/lib/cuid2/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cuid2
4
- VERSION = '0.1.0'
4
+ VERSION = '1.0.0'
5
5
  end
data/lib/cuid2.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  require_relative 'cuid2/version'
4
4
  require 'digest'
5
5
 
6
+ # CUID2 is a Ruby implementation of the CUID2 algorithm.
6
7
  module Cuid2
7
8
  # Entropy is a class that generates a random string of characters
8
9
  class Entropy
@@ -37,20 +38,17 @@ module Cuid2
37
38
  end
38
39
  end
39
40
 
40
- # Generate is a class that generates a Cuid2
41
- class Generate
42
- DEFAULT_LENGTH = 24
41
+ DEFAULT_LENGTH = 24
43
42
 
44
- def self.call
45
- new.generate
46
- end
47
-
48
- def generate(length = DEFAULT_LENGTH)
43
+ class << self
44
+ def call(length = DEFAULT_LENGTH)
49
45
  hash_input = (time + Entropy.create(length) + count + fingerprint).to_s
50
46
 
51
47
  "#{random_letter}#{Cuid2::Hash.create(hash_input, length)[2..length]}"
52
48
  end
53
49
 
50
+ alias generate call
51
+
54
52
  private
55
53
 
56
54
  def time
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cuid2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rubens Stulzer
@@ -10,10 +10,9 @@ bindir: exe
10
10
  cert_chain: []
11
11
  date: 2023-02-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: |-
14
- Secure, collision-resistant ids optimized for horizontal scaling and performance.\
15
- Next generation UUIDs. Need unique ids in your app? Forget UUIDs which often collide in large apps.\
16
- Use Cuid2, instead.
13
+ description: Secure, collision-resistant ids optimized for horizontal scaling and
14
+ performance.Next generation UUIDs. Need unique ids in your app? Forget UUIDs which
15
+ often collide in large apps.Use Cuid2, instead.
17
16
  email:
18
17
  - rubens.stulzer@gmail.com
19
18
  executables: []
@@ -24,7 +23,7 @@ files:
24
23
  - CHANGELOG.md
25
24
  - CODE_OF_CONDUCT.md
26
25
  - Gemfile
27
- - Gemfile.lock
26
+ - LICENSE
28
27
  - README.md
29
28
  - Rakefile
30
29
  - lib/cuid2.rb
@@ -45,7 +44,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
45
44
  requirements:
46
45
  - - ">="
47
46
  - !ruby/object:Gem::Version
48
- version: 2.6.0
47
+ version: 3.2.0
49
48
  required_rubygems_version: !ruby/object:Gem::Requirement
50
49
  requirements:
51
50
  - - ">="
data/Gemfile.lock DELETED
@@ -1,57 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- cuid2 (0.1.0)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- ast (2.4.2)
10
- diff-lcs (1.5.0)
11
- json (2.6.3)
12
- parallel (1.22.1)
13
- parser (3.2.1.0)
14
- ast (~> 2.4.1)
15
- rainbow (3.1.1)
16
- rake (13.0.6)
17
- regexp_parser (2.7.0)
18
- rexml (3.2.5)
19
- rspec (3.12.0)
20
- rspec-core (~> 3.12.0)
21
- rspec-expectations (~> 3.12.0)
22
- rspec-mocks (~> 3.12.0)
23
- rspec-core (3.12.1)
24
- rspec-support (~> 3.12.0)
25
- rspec-expectations (3.12.2)
26
- diff-lcs (>= 1.2.0, < 2.0)
27
- rspec-support (~> 3.12.0)
28
- rspec-mocks (3.12.3)
29
- diff-lcs (>= 1.2.0, < 2.0)
30
- rspec-support (~> 3.12.0)
31
- rspec-support (3.12.0)
32
- rubocop (1.45.1)
33
- json (~> 2.3)
34
- parallel (~> 1.10)
35
- parser (>= 3.2.0.0)
36
- rainbow (>= 2.2.2, < 4.0)
37
- regexp_parser (>= 1.8, < 3.0)
38
- rexml (>= 3.2.5, < 4.0)
39
- rubocop-ast (>= 1.24.1, < 2.0)
40
- ruby-progressbar (~> 1.7)
41
- unicode-display_width (>= 2.4.0, < 3.0)
42
- rubocop-ast (1.26.0)
43
- parser (>= 3.2.1.0)
44
- ruby-progressbar (1.11.0)
45
- unicode-display_width (2.4.2)
46
-
47
- PLATFORMS
48
- arm64-darwin-22
49
-
50
- DEPENDENCIES
51
- cuid2!
52
- rake (~> 13.0)
53
- rspec (~> 3.0)
54
- rubocop (~> 1.21)
55
-
56
- BUNDLED WITH
57
- 2.4.6