friendly_uuid 0.3.1 → 0.3.2
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 +4 -4
- data/lib/friendly_uuid.rb +13 -17
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf8d5e72bcdfc392496d82ff2edb0f3bb16f5fbb390c4bfeee593e4a4f1d809a
|
4
|
+
data.tar.gz: ac2ca5df9575b956d6057faac4b061e9f4d5cbfc1bf8b678cc6f1f9249d949e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c030af33c0bad3efe7e7eba15b8ab9146883c4ce3bb1c2cdbe3a53964b34306d54c83749fc3ac814b04d08aaf8299dcc221ef4676bc2a838a9a8b4d55b897f1
|
7
|
+
data.tar.gz: 9772457ed4a6441ec49db31e42529fd400c33fb6caab0d73d5193c23c48477e858b14eaa63467b40e6b7ad466153d21e70a15b7322458bf915a5ca317a87ef3f
|
data/lib/friendly_uuid.rb
CHANGED
@@ -21,22 +21,21 @@ module FriendlyUUID
|
|
21
21
|
|
22
22
|
module Class
|
23
23
|
def find(*ids)
|
24
|
-
|
24
|
+
ids = self.expand(ids) if ids.flatten.any? { |id| id.present? }
|
25
|
+
|
26
|
+
super(ids)
|
25
27
|
end
|
26
28
|
|
27
29
|
def expand(short_uuids)
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
short_uuids.map do |uuid|
|
39
|
-
self.expand_to_record(uuid).id
|
30
|
+
if short_uuids.is_a?(String)
|
31
|
+
self.expand_to_record(short_uuids)&.id
|
32
|
+
elsif short_uuids[0].is_a?(String) && short_uuids.length == 1
|
33
|
+
self.expand_to_record(short_uuids.join)&.id
|
34
|
+
elsif short_uuids.is_a?(Array)
|
35
|
+
short_uuids.flatten!
|
36
|
+
short_uuids.map do |uuid|
|
37
|
+
self.expand_to_record(uuid.to_s)&.id
|
38
|
+
end
|
40
39
|
end
|
41
40
|
end
|
42
41
|
|
@@ -49,10 +48,7 @@ module FriendlyUUID
|
|
49
48
|
end
|
50
49
|
|
51
50
|
def expand_to_record(short_uuid)
|
52
|
-
|
53
|
-
record = self.possible_expansions(short_uuid).first
|
54
|
-
raise ActiveRecord::RecordNotFound unless record
|
55
|
-
record
|
51
|
+
self.possible_expansions(short_uuid).first
|
56
52
|
end
|
57
53
|
|
58
54
|
def possible_expansions(short_uuid)
|
metadata
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: friendly_uuid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Carlsson
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2020-10-11 00:00:00.000000000 Z
|
@@ -20,7 +20,7 @@ description: |2
|
|
20
20
|
FriendlyUUID URLs are exactly as unique as they need to be. The first record will be one character. Would-be collisions expand to two characters, and so on.
|
21
21
|
|
22
22
|
FriendlyUUID is inspired by friendly_id, but is focused on being lightweight and specific to models with UUID primary keys.
|
23
|
-
email:
|
23
|
+
email: ben@twos.dev
|
24
24
|
executables: []
|
25
25
|
extensions: []
|
26
26
|
extra_rdoc_files: []
|
@@ -28,17 +28,18 @@ files:
|
|
28
28
|
- lib/friendly_uuid.rb
|
29
29
|
homepage: https://github.com/glacials/friendly_uuid
|
30
30
|
licenses:
|
31
|
-
-
|
31
|
+
- CC-BY-NC-SA-4.0
|
32
|
+
- LicenseRef-Licenseland
|
32
33
|
metadata: {}
|
33
|
-
post_install_message:
|
34
|
+
post_install_message:
|
34
35
|
rdoc_options: []
|
35
36
|
require_paths:
|
36
37
|
- lib
|
37
38
|
required_ruby_version: !ruby/object:Gem::Requirement
|
38
39
|
requirements:
|
39
|
-
- -
|
40
|
+
- - '='
|
40
41
|
- !ruby/object:Gem::Version
|
41
|
-
version:
|
42
|
+
version: 2.7.2
|
42
43
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
43
44
|
requirements:
|
44
45
|
- - ">="
|
@@ -46,7 +47,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
46
47
|
version: '0'
|
47
48
|
requirements: []
|
48
49
|
rubygems_version: 3.1.4
|
49
|
-
signing_key:
|
50
|
+
signing_key:
|
50
51
|
specification_version: 4
|
51
52
|
summary: Make UUIDs pretty enough for use in URLs
|
52
53
|
test_files: []
|