ksuid 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/ksuid.gemspec +1 -1
- data/lib/ksuid/activerecord/binary_type.rb +0 -8
- data/lib/ksuid/activerecord/type.rb +0 -8
- data/lib/ksuid/type.rb +30 -0
- data/lib/ksuid/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65b5bd73fb4864bb0df8cf57c1214622325afa077e031baffb2a1e73b2820f2c
|
4
|
+
data.tar.gz: 55245cb9fba9e57c9bf115f189fb954f2e1b08604e89ba8b5c9aeea73967e5ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af5cc8ed5f9d81616fd61e6f03690c841489e9f2c2d28d892137c1eb410ec88e61540cd3dd10d5ac0d0439f9b9ecd9afdc00cceae61276cca521d5436c159e29
|
7
|
+
data.tar.gz: 13479dc7d24cf9422c6bc3ca705c6c777abf121f5ade7a9f9c8124c7b9f8034844d8707b2f8265c18178b9b16b50be28a3c1894888d97fe7f42aa1e981d11a97
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
|
5
5
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## [0.4.0](https://github.com/michaelherold/ksuid/compare/v0.3.0...v0.4.0) - 2022-07-29
|
8
|
+
|
9
|
+
### Added
|
10
|
+
|
11
|
+
- `KSUID::Type` acts as a proper value object now, which means that you may use it as a Hash key or use it in ActiveRecord's `.includes`. `KSUID::Type#eql?`, `KSUID::Type#hash`, and `KSUID::Type#==` now work as expected. Note that `KSUID::Type#==` is more lax than `KSUID::Type#eql?` because it can also match any object that converts to a string matching its value. This means that you can use it to match against `String` KSUIDs.
|
12
|
+
|
13
|
+
### Fixed
|
14
|
+
|
15
|
+
- `ActiveRecord::QueryMethods#include` works as expected now due to the fix on the value object semantics of `KSUID::Type`.
|
16
|
+
- Binary KSUID primary and foreign keys work as expected on JRuby.
|
17
|
+
|
7
18
|
## [0.3.0](https://github.com/michaelherold/ksuid/compare/v0.2.0...v0.3.0) - 2021-10-07
|
8
19
|
|
9
20
|
### Added
|
data/ksuid.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
|
11
11
|
spec.summary = 'Ruby implementation of the K-Sortable Unique IDentifier'
|
12
12
|
spec.description = spec.summary
|
13
|
-
spec.homepage = 'https://github.com/michaelherold/ksuid'
|
13
|
+
spec.homepage = 'https://github.com/michaelherold/ksuid-ruby'
|
14
14
|
spec.license = 'MIT'
|
15
15
|
|
16
16
|
spec.files = %w[CHANGELOG.md CONTRIBUTING.md LICENSE.md README.md]
|
data/lib/ksuid/type.rb
CHANGED
@@ -63,6 +63,36 @@ module KSUID
|
|
63
63
|
other.to_s == to_s
|
64
64
|
end
|
65
65
|
|
66
|
+
# Checks whether this KSUID hashes to the same hash key as another
|
67
|
+
#
|
68
|
+
# @api semipublic
|
69
|
+
#
|
70
|
+
# @example Checks whether two KSUIDs hash to the same key
|
71
|
+
# KSUID.new.eql? KSUID.new
|
72
|
+
#
|
73
|
+
# @param other [KSUID::Type] the other KSUID to check against
|
74
|
+
# @return [Boolean]
|
75
|
+
def eql?(other)
|
76
|
+
hash == other.hash
|
77
|
+
end
|
78
|
+
|
79
|
+
# Generates the key to use when using a KSUID as a hash key
|
80
|
+
#
|
81
|
+
# @api semipublic
|
82
|
+
#
|
83
|
+
# @example Using a KSUID as a Hash key
|
84
|
+
# ksuid1 = KSUID.new
|
85
|
+
# ksuid2 = KSUID.from_base62(ksuid1.to_s)
|
86
|
+
# values_by_ksuid = {}
|
87
|
+
#
|
88
|
+
# values_by_ksuid[ksuid1] = "example"
|
89
|
+
# values_by_ksuid[ksuid2] #=> "example"
|
90
|
+
#
|
91
|
+
# @return [Integer]
|
92
|
+
def hash
|
93
|
+
@uid.hash
|
94
|
+
end
|
95
|
+
|
66
96
|
# Prints the KSUID for debugging within a console
|
67
97
|
#
|
68
98
|
# @api public
|
data/lib/ksuid/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ksuid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Herold
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -47,7 +47,7 @@ files:
|
|
47
47
|
- lib/ksuid/type.rb
|
48
48
|
- lib/ksuid/utils.rb
|
49
49
|
- lib/ksuid/version.rb
|
50
|
-
homepage: https://github.com/michaelherold/ksuid
|
50
|
+
homepage: https://github.com/michaelherold/ksuid-ruby
|
51
51
|
licenses:
|
52
52
|
- MIT
|
53
53
|
metadata: {}
|
@@ -66,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
66
66
|
- !ruby/object:Gem::Version
|
67
67
|
version: '0'
|
68
68
|
requirements: []
|
69
|
-
rubygems_version: 3.
|
69
|
+
rubygems_version: 3.1.6
|
70
70
|
signing_key:
|
71
71
|
specification_version: 4
|
72
72
|
summary: Ruby implementation of the K-Sortable Unique IDentifier
|