based_uuid 0.6.1 → 0.6.3

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: 5499342189f8b46811d3d620d6074dbd6620bc3cbc8882f39261b428a5fbcc41
4
- data.tar.gz: 4ed71b83bf2f7271466256c5a215f217ba4c300665aeb895e6fa2da2b1308ea9
3
+ metadata.gz: 817a3f1cb146984cc60ce6b4d375c4aa99596a6625caa1634ffb4863a88c5fad
4
+ data.tar.gz: 609ed318d030cec9f2a1e798306aec767fff1ff76e79027f8de29c4421c71ebc
5
5
  SHA512:
6
- metadata.gz: edaf5ab4385cb65dff10739d12801b98c0085fb9d54d9841c480783c014ff47d2359b16acaf03b426a7a17049968f0bea1d54e0cc5063d4679105bb5813a9655
7
- data.tar.gz: c81d9c3aa7c122516c846cb0470b45d2352f2db8bcc051a22c6da6d5d7f9a33892dab095f719677512cfd9d29d8f891f971c1d084f212cbe4283ea76425a87c5
6
+ metadata.gz: 53b3687c2863bec696e6c01f72e7af31518039eb93d54b0cc19bc7f2eae08c73bcd64ddb62a17964dd51a8beba41e3b6adfc845af1d33ff736546f14344422f4
7
+ data.tar.gz: 686192a5aaee839a19c12125cbe02739dd4aafadef884bb1afc34f10742090eac587688ee1907c0d764f17fea1bf9bda07994427a0ec0567e0204b509fdfec8d
data/README.md CHANGED
@@ -1,9 +1,8 @@
1
1
  # BasedUUID: URL-friendly UUIDs for Rails models
2
2
 
3
- [![Build Status](https://github.com/pch/based_uuid/workflows/Tests/badge.svg)](https://github.com/pch/based_uuid/actions) [![Gem Version](https://badge.fury.io/rb/based_uuid.svg)](https://badge.fury.io/rb/based_uuid)
3
+ [![Build Status](https://github.com/pch/based_uuid/workflows/Tests/badge.svg)](https://github.com/pch/based_uuid/actions)
4
4
 
5
-
6
- Generate “double-clickable”, URL-friendly UUIDs with (optional) prefixes:
5
+ Generate “double-clickable”, URL-friendly UUIDs with optional prefixes:
7
6
 
8
7
  ```
9
8
  user_763j02ryxh8dbs56mgcjqrmmgt #=> e61c802c-7bb1-4357-929a-9064af8a521a
@@ -12,7 +11,7 @@ bpo_12dm1qresn83st62reqdw7f7cv #=> 226d037c-3b35-40f3-a30b-0ebb78779d9b
12
11
 
13
12
  This gem encodes UUID primary keys into 26-character lowercase strings using [Crockford’s base32](https://www.crockford.com/base32.html) encoding. The optional prefix helps you identify the model it represents.
14
13
 
15
- BasedUUID assumes that you have a [UUID primary key](https://guides.rubyonrails.org/v5.0/active_record_postgresql.html#uuid) (`id`) in your ActiveRecord model. It doesn’t affect how your primary key UUIDs are stored in the database. Prefixes and base32-encoded strings are only used for presentation.
14
+ By default, BasedUUID assumes that you have a [UUID primary key](https://guides.rubyonrails.org/v5.0/active_record_postgresql.html#uuid) (`id`) in your ActiveRecord model. It doesn’t affect how UUIDs are stored in the database. Prefixes and base32-encoded strings are only used for presentation.
16
15
 
17
16
  ## Installation
18
17
 
@@ -32,7 +31,7 @@ class BlogPost < ApplicationRecord
32
31
  end
33
32
 
34
33
  post = BlogPost.last
35
- post.based_uuid #=> bpo_12dm1qresn83st62reqdw7f7cv
34
+ post.based_uuid #=> bpo_12dm1qresn83st62reqdw7f7cv
36
35
  post.based_uuid(prefix: false) #=> 12dm1qresn83st62reqdw7f7cv
37
36
  ```
38
37
 
@@ -98,6 +97,7 @@ end
98
97
  BasedUUID can be used outside ActiveRecord, too. You can encode any UUID with it:
99
98
 
100
99
  ```ruby
100
+ BasedUUID.encode(uuid: "226d037c-3b35-40f3-a30b-0ebb78779d9b")
101
101
  BasedUUID.encode(uuid: "226d037c-3b35-40f3-a30b-0ebb78779d9b", prefix: :bpo)
102
102
  BasedUUID.decode("bpo_12dm1qresn83st62reqdw7f7cv")
103
103
  ```
@@ -1,5 +1,5 @@
1
1
  module BasedUUID
2
- module Base32UUID
2
+ class Base32UUID
3
3
  CROCKFORDS_ALPHABET = "0123456789abcdefghjkmnpqrstvwxyz".freeze
4
4
  CHARACTER_MAP = CROCKFORDS_ALPHABET.bytes.freeze
5
5
 
@@ -48,7 +48,7 @@ module BasedUUID
48
48
  end
49
49
 
50
50
  def based_uuid(prefix: true)
51
- raise ArgumentError, "UUID is empty" if _uuid_column_value.blank?
51
+ return nil if _uuid_column_value.blank?
52
52
 
53
53
  BasedUUID.encode(uuid: _uuid_column_value, prefix: prefix ? self.class._based_uuid_prefix : nil)
54
54
  end
@@ -1,3 +1,3 @@
1
1
  module BasedUUID
2
- VERSION = "0.6.1".freeze
2
+ VERSION = "0.6.3".freeze
3
3
  end
data/lib/based_uuid.rb CHANGED
@@ -30,7 +30,7 @@ module BasedUUID
30
30
  [prefix.presence, uuid_base32]
31
31
  end
32
32
 
33
- def encode(uuid:, prefix:)
33
+ def encode(uuid:, prefix: nil)
34
34
  uuid_base32 = Base32UUID.encode(uuid)
35
35
  return uuid_base32 unless prefix
36
36
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: based_uuid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Chmolowski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-07 00:00:00.000000000 Z
11
+ date: 2024-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport