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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f717bc154ecc3919542742b7c927f62c924a8d4f73ec81be31f3ac3239d2b76b
4
- data.tar.gz: e64581c8cd8cb4097fc0cd8fe869f3900cc61de735bb0ac36947143ae87fe611
3
+ metadata.gz: 65b5bd73fb4864bb0df8cf57c1214622325afa077e031baffb2a1e73b2820f2c
4
+ data.tar.gz: 55245cb9fba9e57c9bf115f189fb954f2e1b08604e89ba8b5c9aeea73967e5ba
5
5
  SHA512:
6
- metadata.gz: dfa9df01eb24b3ce510d38d673726e0bd6e0bda87e5716cdbff2bdd4cdeec129a1cc1a95c60c221e91202837e8a70ff3ec90421bc9a026b5af98038de10d6b06
7
- data.tar.gz: ed5c2932989a25b83ef0b3004a546cd0b3b465a208cf374e46daeeb34080eaac626908b846af74b6183fe1b896c4aeec8ee38628b87b9c1d805ef1dc2b1d5c3a
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]
@@ -51,14 +51,6 @@ module KSUID
51
51
 
52
52
  super(KSUID.call(value).to_bytes)
53
53
  end
54
-
55
- # The identifier to use within ActiveRecord's type registry
56
- #
57
- # @api private
58
- # @return [Symbol]
59
- def type
60
- :ksuid_binary
61
- end
62
54
  end
63
55
  end
64
56
  end
@@ -50,14 +50,6 @@ module KSUID
50
50
 
51
51
  KSUID.call(value).to_s
52
52
  end
53
-
54
- # The identifier to use within ActiveRecord's type registry
55
- #
56
- # @api private
57
- # @return [Symbol]
58
- def type
59
- :ksuid
60
- end
61
53
  end
62
54
  end
63
55
  end
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
@@ -4,5 +4,5 @@ module KSUID
4
4
  # The version of the KSUID gem
5
5
  #
6
6
  # @return [String]
7
- VERSION = '0.3.0'
7
+ VERSION = '0.4.0'
8
8
  end
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.3.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: 2021-10-08 00:00:00.000000000 Z
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.0.6
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