uuid_attribute 0.9.0 → 0.9.1

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: 47ad9521befd5c8fc61d64ac6ce670e55edcbc0d5833405c02a6552900834dd9
4
- data.tar.gz: 38b608ec56aec54bc152b36addadc3b7a173a35db2ed25ffdf84654e757114bf
3
+ metadata.gz: e716f18577f556aa807d4ad19aa1f6cd62900f7ea5faab4ea3f88fb4cc8e3d5a
4
+ data.tar.gz: 22161c78f0e24c4117306db0c6d70b27665f911385ade24748d09619acefc657
5
5
  SHA512:
6
- metadata.gz: cef667567fc3384b760385c7ce38e75ac43b33ca7a002988d5a799f3b62ddc19b053d49a44a3cd9e55b6a09d051cc92cf6b0f27d210cdc479b0f506c974f9623
7
- data.tar.gz: debb0b40b887e22cd37c82d211a7b00430abd4612b2d95efe8fccbef2af46e4ee51753d6917c13d4eb6476520405d05a74e1e04e66292d76d20fc45e71b27757
6
+ metadata.gz: 90698cabeeb889fc28c07ab0001e53575db198b611707dc0fb640348b32c2d9712f3c861ccfdbcfa3aceb56d8f85cb6255c3cae6a591697792b135140824ee7c
7
+ data.tar.gz: ef6d0daa754d19d805367b00646789b1813ea9db391bad35129ca9e06d67a165c3779047d1e227110b857a808b8a2499e767081316c381e92ff7e6e6befc5ce0
data/README.md CHANGED
@@ -12,13 +12,15 @@ If bundler is not being used to manage dependencies, install the gem by executin
12
12
 
13
13
  ## Usage
14
14
 
15
- TODO: Write usage instructions here
16
-
17
15
  ```
18
16
  class YourModel < ApplicationRecord
19
- attribute :id, :uuid, default: -> { SecureRandom.uuid }
20
17
  end
21
18
 
19
+ model = YourModel.create( ... )
20
+ YourModel:0x00007f85774135a8
21
+ id: "5iLEaLFZUeD6Dg8nnfSiCZ",
22
+ ... >
23
+
22
24
  Or if you want to disable auto detect of UUIDs
23
25
 
24
26
  UuidAttribute.setup do |config|
@@ -41,12 +43,6 @@ release a new version, update the version number in `version.rb`, and then run
41
43
  git commits and the created tag, and push the `.gem` file to
42
44
  [rubygems.org](https://rubygems.org).
43
45
 
44
- ## TODO
45
-
46
- Write tests for each supported rails versions. See examples at:
47
- https://github.com/rails/rails/tree/main/activerecord
48
- https://github.com/heartcombo/simple_form/tree/main/gemfiles
49
-
50
46
  ## Contributing
51
47
 
52
48
  Bug reports and pull requests are welcome on GitHub at
@@ -47,13 +47,20 @@ module UuidAttribute
47
47
 
48
48
  default = nil
49
49
  default = -> { SecureRandom.uuid } if att.eql? "id"
50
- model.define_attribute att, ::UuidAttribute::UUID.new, default: default
50
+ model.attribute att, ::UuidAttribute::UUID.new, default: default
51
51
  end
52
52
  end
53
+ rescue ActiveRecord::NoDatabaseError
54
+ puts "NO DATABASE"
55
+ false
56
+ else
57
+ puts "CONFIGURE BINARY"
58
+ true
53
59
  end
54
60
  end
55
61
 
56
62
  config.after_initialize do
63
+ puts "REGISTERING UUID"
57
64
  ActiveRecord::Type.register(:uuid, ::UuidAttribute::UUID)
58
65
 
59
66
  configure_binary_ids if UuidAttribute.auto_detect_binary_ids
@@ -5,7 +5,7 @@ module UuidAttribute
5
5
  class Utils
6
6
  class << self
7
7
  def normalize(uuid_string)
8
- uuid_string.gsub("-", "").upcase
8
+ uuid_string&.gsub("-", "")&.upcase
9
9
  end
10
10
 
11
11
  def hex_from_binary(bytes)
@@ -23,6 +23,8 @@ module UuidAttribute
23
23
  case str.length
24
24
  when 32
25
25
  format_uuid(str)
26
+ when 34
27
+ format_uuid(str)
26
28
  when 16
27
29
  format_uuid(hex_from_binary(str))
28
30
  when 22
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UuidAttribute
4
- VERSION = "0.9.0"
4
+ VERSION = "0.9.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uuid_attribute
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Negri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-23 00:00:00.000000000 Z
11
+ date: 2023-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel