typeid 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/typeid/version.rb +1 -1
- data/lib/typeid.rb +5 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c2971eed0f4cb54b1f89e253e78e092e4a8fd9a5895a5f04e9ff9701bf289bc
|
4
|
+
data.tar.gz: 469d897f849ac01ecfa60adbaa6aada3f4ce7b29182b1e33fc967f35294b2a96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf90dbde8bbcb004ca85c507bcc3d81922971eb9d31bc87d4ce2c2980fdf6be5548c69438b69bce4361eef1ef9ee65caef8b2e87370d0a13c45e201b758303ea
|
7
|
+
data.tar.gz: 516981aac6f786f452d28ada1b0e87fa17d31cf8eea1c07db10f15f9ebbd15f499cef4897321a6bd6a8920812b2f835c85f6a6df456239b6f19299f14b62f2b7
|
data/lib/typeid/version.rb
CHANGED
data/lib/typeid.rb
CHANGED
@@ -32,11 +32,11 @@ class TypeID < String
|
|
32
32
|
# @param string [String] string representation of a +TypeID+
|
33
33
|
# @return [TypeID]
|
34
34
|
def self.from_string(string)
|
35
|
-
case string.
|
36
|
-
in [suffix]
|
35
|
+
case string.rpartition("_")
|
36
|
+
in ["", "", suffix]
|
37
37
|
from("", suffix)
|
38
38
|
|
39
|
-
in [prefix, suffix]
|
39
|
+
in [prefix, "_", suffix]
|
40
40
|
raise Error, "prefix cannot be empty when there's a separator" if prefix.empty?
|
41
41
|
|
42
42
|
from(prefix, suffix)
|
@@ -83,7 +83,8 @@ class TypeID < String
|
|
83
83
|
suffix: TypeID::UUID.generate(timestamp: timestamp).base32
|
84
84
|
)
|
85
85
|
raise Error, "prefix length cannot be greater than #{MAX_PREFIX_LENGTH}" if prefix.length > MAX_PREFIX_LENGTH
|
86
|
-
raise Error, "prefix must be lowercase ASCII characters" unless prefix.match?(/^[a-
|
86
|
+
raise Error, "prefix must be lowercase ASCII characters" unless prefix.match?(/^[a-z_]*$/)
|
87
|
+
raise Error, "prefix cannot start or end with an underscore" if prefix.start_with?("_") || prefix.end_with?("_")
|
87
88
|
raise Error, "suffix must be #{TypeID::UUID::Base32::ENCODED_STRING_LENGTH} characters" unless suffix.length == TypeID::UUID::Base32::ENCODED_STRING_LENGTH
|
88
89
|
raise Error, "suffix must only contain the letters in '#{TypeID::UUID::Base32::ALPHABET}'" unless suffix.chars.all? { |char| TypeID::UUID::Base32::ALPHABET.include?(char) }
|
89
90
|
raise Error, "suffix must start with a 0-7 digit to avoid overflows" unless ("0".."7").cover?(suffix.chars.first)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: typeid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Booth
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: uuid7
|