uuid_attribute 0.9.0 → 0.9.2

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: '044226208a5f82b69965d3614d69e8498d275ba54a8f74a2df5710bdaee8ed81'
4
+ data.tar.gz: b52bbb3dc7f2ba502e6ea59e9524903e0ffde4bddb57aec9f9fa2f1615ddd1bf
5
5
  SHA512:
6
- metadata.gz: cef667567fc3384b760385c7ce38e75ac43b33ca7a002988d5a799f3b62ddc19b053d49a44a3cd9e55b6a09d051cc92cf6b0f27d210cdc479b0f506c974f9623
7
- data.tar.gz: debb0b40b887e22cd37c82d211a7b00430abd4612b2d95efe8fccbef2af46e4ee51753d6917c13d4eb6476520405d05a74e1e04e66292d76d20fc45e71b27757
6
+ metadata.gz: 6ef05bd5a47da6b30efc5257914b18f7b48796f2f054635f522e83e269f7c3479bc38ebcaed0f929f47d87c489078be3a13a94fd52f14122a652c5cb86e74067
7
+ data.tar.gz: 839cfd50e258caf09be260ef060efafd57d27cdcf5a461f044173ddc0f1ced698d34cba136d3b2ec32c1ac6beddadd57f3a006db5f7fe0ab09a0025e0fcd7046
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,19 @@ 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
+ false
55
+ else
56
+ true
53
57
  end
54
58
  end
55
59
 
56
60
  config.after_initialize do
61
+ return if ARGV.include? "assets:precompile"
62
+
57
63
  ActiveRecord::Type.register(:uuid, ::UuidAttribute::UUID)
58
64
 
59
65
  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.2"
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.2
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