uniq_identifier 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -2
- data/Gemfile +2 -2
- data/README.md +1 -2
- data/Rakefile +4 -3
- data/lib/uniq_identifier/hook.rb +7 -7
- data/lib/uniq_identifier/version.rb +1 -1
- data/lib/uniq_identifier.rb +2 -2
- data/spec/uniq_identifier/uniq_identifier_spec.rb +48 -6
- data/uniq_identifier.gemspec +4 -7
- metadata +20 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a239d021344adf722c7a7ee611be695672c346d3
|
4
|
+
data.tar.gz: 417b2dbc4c43505f2cdaea2f6db29298b885e607
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 461c221c17a4c4e68016185820cca009f7340e490800ab4c3c59474d5ff90ca7f157781b652c2e53a1185462afc95ffe9efe21bd877a5014c3de784d27c9c4d1
|
7
|
+
data.tar.gz: 4ccef7de5a3846ae561f26c877cfc86a5890e8fc53abff63fe8b3233be63427b08378f2c100607bcbd7bc74c9223154cdc52c4d103ed7699d836a31c0333013b
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,14 @@
|
|
1
|
+
### VERSION 0.0.6
|
2
|
+
|
3
|
+
* Enhancements
|
4
|
+
* Lazy assignation of UUID
|
5
|
+
* UUID always available, not only after validation
|
6
|
+
|
1
7
|
### VERSION 0.0.5
|
2
8
|
|
3
9
|
* Enhancements
|
4
10
|
* decrease time of migration for big table
|
5
|
-
* change after initialize to before validation for avoid loading this hook each time we have an instance (iteration case)
|
11
|
+
* change after initialize to before validation for avoid loading this hook each time we have an instance (iteration case)
|
6
12
|
|
7
13
|
### VERSION 0.0.4
|
8
14
|
|
@@ -18,7 +24,7 @@
|
|
18
24
|
### VERSION 0.0.2
|
19
25
|
|
20
26
|
* Enhancements
|
21
|
-
*
|
27
|
+
* Little enhancement
|
22
28
|
|
23
29
|
### VERSION 0.0.1
|
24
30
|
|
data/Gemfile
CHANGED
@@ -7,7 +7,7 @@ group :test do
|
|
7
7
|
case ENV['ADAPTER']
|
8
8
|
when nil, 'active_record'
|
9
9
|
gem 'sqlite3', platform: 'ruby'
|
10
|
-
gem 'activerecord'
|
10
|
+
gem 'activerecord', '4.2.0'
|
11
11
|
when 'mongoid'
|
12
12
|
gem 'mongoid'
|
13
13
|
else
|
@@ -15,5 +15,5 @@ group :test do
|
|
15
15
|
end
|
16
16
|
gem 'coveralls', require: false
|
17
17
|
gem 'pry'
|
18
|
-
gem 'ammeter'
|
18
|
+
# gem 'ammeter'
|
19
19
|
end
|
data/README.md
CHANGED
@@ -39,14 +39,13 @@ end
|
|
39
39
|
```ruby
|
40
40
|
foo = Foo.new
|
41
41
|
foo.id # => nil
|
42
|
-
foo.uuid # => nil
|
43
|
-
foo.valid?
|
44
42
|
foo.uuid # => "0c6bbc03-a269-44e2-8075-f442e1aac0c8"
|
45
43
|
```
|
46
44
|
|
47
45
|
```ruby
|
48
46
|
foo.create!
|
49
47
|
foo.id # => 1
|
48
|
+
foo.uuid # => "0c6bbc03-a269-44e2-8075-f442e1aac0c8"
|
50
49
|
```
|
51
50
|
|
52
51
|
```ruby
|
data/Rakefile
CHANGED
@@ -13,13 +13,14 @@ task :default => [ :spec ]
|
|
13
13
|
|
14
14
|
desc 'Run all specs'
|
15
15
|
task 'spec' do
|
16
|
-
Rake::Task['generators'].invoke
|
17
|
-
return_code1 = $?.exitstatus
|
16
|
+
# Rake::Task['generators'].invoke
|
17
|
+
# return_code1 = $?.exitstatus
|
18
18
|
|
19
19
|
Rake::Task['uniq_identifier'].invoke
|
20
20
|
return_code2 = $?.exitstatus
|
21
21
|
|
22
|
-
fail if return_code1 != 0 || return_code2 != 0
|
22
|
+
# fail if return_code1 != 0 || return_code2 != 0
|
23
|
+
fail if return_code2 != 0
|
23
24
|
end
|
24
25
|
|
25
26
|
desc 'Run specs for all adapters'
|
data/lib/uniq_identifier/hook.rb
CHANGED
@@ -3,16 +3,16 @@ require 'securerandom'
|
|
3
3
|
module UniqIdentifier
|
4
4
|
module Hook
|
5
5
|
|
6
|
-
def
|
7
|
-
|
6
|
+
def uuid(*args, &block)
|
7
|
+
if super(*args).nil?
|
8
|
+
self.send(:uuid=, UniqIdentifier.configuration.generator.uuid)
|
9
|
+
end
|
10
|
+
|
11
|
+
super(*args)
|
8
12
|
end
|
9
13
|
|
10
14
|
def set_uniq_identifier
|
11
|
-
|
12
|
-
unless self.uuid?
|
13
|
-
self.send(:uuid=, UniqIdentifier.configuration.generator.uuid)
|
14
|
-
end
|
15
|
-
end
|
15
|
+
self.uuid # Just call lazy loading
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
data/lib/uniq_identifier.rb
CHANGED
@@ -3,21 +3,63 @@ require 'spec_helper'
|
|
3
3
|
describe UniqIdentifier do
|
4
4
|
let(:user) { User.new }
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
specify 'lazy load' do
|
7
|
+
expect {
|
8
|
+
expect(user.uuid).to eql('0c6bbc03-a269-44e2-8075-f442e1aac0c8')
|
9
|
+
}.to change {
|
10
|
+
user.attributes['uuid']
|
11
|
+
}.from(nil).to('0c6bbc03-a269-44e2-8075-f442e1aac0c8')
|
8
12
|
end
|
9
13
|
|
10
14
|
specify do
|
11
|
-
expect
|
15
|
+
expect {
|
16
|
+
user.save!
|
17
|
+
}.to change {
|
18
|
+
user.attributes['uuid']
|
19
|
+
}.from(nil).to('0c6bbc03-a269-44e2-8075-f442e1aac0c8')
|
12
20
|
end
|
13
21
|
|
14
22
|
context 'persistence' do
|
15
23
|
let(:user_id) { user.id }
|
16
24
|
|
17
|
-
|
25
|
+
context 'set uuid on save' do
|
26
|
+
before { user.save! }
|
18
27
|
|
19
|
-
|
20
|
-
|
28
|
+
specify do
|
29
|
+
expect(User.find(user_id).uuid).to eql('0c6bbc03-a269-44e2-8075-f442e1aac0c8')
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'keep given uuid on save' do
|
34
|
+
before do
|
35
|
+
user.uuid = 'What Ever Uuid'
|
36
|
+
user.save!
|
37
|
+
end
|
38
|
+
|
39
|
+
specify do
|
40
|
+
expect(User.find(user_id).uuid).to eql('What Ever Uuid')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'keep given uuid on save' do
|
45
|
+
before do
|
46
|
+
user.attributes = { uuid: 'What Ever Uuid' }
|
47
|
+
user.save!
|
48
|
+
end
|
49
|
+
|
50
|
+
specify do
|
51
|
+
expect(User.find(user_id).uuid).to eql('What Ever Uuid')
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'keep given uuid on save' do
|
56
|
+
let(:user) { User.new({ uuid: 'What Ever Uuid' }) }
|
57
|
+
|
58
|
+
before { user.save! }
|
59
|
+
|
60
|
+
specify do
|
61
|
+
expect(User.find(user_id).uuid).to eql('What Ever Uuid')
|
62
|
+
end
|
21
63
|
end
|
22
64
|
end
|
23
65
|
end
|
data/uniq_identifier.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.email = ['joel.azemar@gmail.com']
|
8
8
|
spec.summary = %q{Add an uniq identifier}
|
9
9
|
spec.description = %q{Add an uniq identifier on your models}
|
10
|
-
spec.homepage = ''
|
10
|
+
spec.homepage = 'https://github.com/joel/uniq_identifier'
|
11
11
|
spec.license = 'MIT'
|
12
12
|
|
13
13
|
spec.files = `git ls-files -z`.split("\x0")
|
@@ -15,9 +15,6 @@ Gem::Specification.new do |spec|
|
|
15
15
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
16
16
|
spec.require_paths = ['lib']
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
# spec.required_ruby_version = '~> 2.2'
|
23
|
-
end
|
18
|
+
spec.add_development_dependency 'rspec', '~> 3.2'
|
19
|
+
spec.add_development_dependency 'rake', '~> 10.4'
|
20
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uniq_identifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joel AZEMAR
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -16,14 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '3.
|
19
|
+
version: '3.2'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '3.
|
26
|
+
version: '3.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.4'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.4'
|
27
41
|
description: Add an uniq identifier on your models
|
28
42
|
email:
|
29
43
|
- joel.azemar@gmail.com
|
@@ -65,7 +79,7 @@ files:
|
|
65
79
|
- spec/uniq_identifier/configuration_spec.rb
|
66
80
|
- spec/uniq_identifier/uniq_identifier_spec.rb
|
67
81
|
- uniq_identifier.gemspec
|
68
|
-
homepage:
|
82
|
+
homepage: https://github.com/joel/uniq_identifier
|
69
83
|
licenses:
|
70
84
|
- MIT
|
71
85
|
metadata: {}
|
@@ -85,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
99
|
version: '0'
|
86
100
|
requirements: []
|
87
101
|
rubyforge_project:
|
88
|
-
rubygems_version: 2.
|
102
|
+
rubygems_version: 2.6.6
|
89
103
|
signing_key:
|
90
104
|
specification_version: 4
|
91
105
|
summary: Add an uniq identifier
|