public_uid 1.3.1 → 2.0.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: 6eae2510dbf2fc8bb27deb0152a09c9a16c076200e11c9b59d3cc4d773dae188
4
- data.tar.gz: 7b63a89f445c5ac69c20173d61cdfe2cb951aa87454afdca21306ee605a403b3
3
+ metadata.gz: d8df1654181a314bd55f3b19088d5da0637a81e3a84837b9a9f544cab4bfcf4e
4
+ data.tar.gz: c1c7658bec15be557d28fb91080973a98817931441dbb5733fa89fa4685c3b03
5
5
  SHA512:
6
- metadata.gz: 4702fd22920d3386b9ad00aa89524fb3c48fd5d9be9424803f9dff4b869eca2672b448757ba4ab00d756778b43c93ea472653545189f2c27d42b90fa00c1a175
7
- data.tar.gz: ff06e39666089367fec172e0c3e4a3b07725ee7196715943590f7e0a5ef9b242ac1171578e816f36d592eeb078ac6433f9ecc82a50ac43a28e63c725cda82023
6
+ metadata.gz: 1a6dba79147370f0d36de14b9ae4d9de0fe58614f6a088cfd63dbf67674a6cafb477524514e7441060fad6bff1ed10092c1a8d08a2d9cbc83da4628dc987bff1
7
+ data.tar.gz: 5f4343c40e9575faa3f4bab8795b2025ac5bc44988aecfe7806059e28b02acbf9842023a509aabbd0b321c6c008ed5d55157f0b855a6b04b9c78259c0a6f2baf
data/.travis.yml CHANGED
@@ -1,9 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.0.0
4
- - 2.1.0
5
- - 2.1.1
6
- - 2.2.2
7
- - 2.3.0
8
- - 2.4.0
9
- - 2.5.1
3
+ - 2.3.8
4
+ - 2.4.5
5
+ - 2.5.3
6
+ - 2.6.5
7
+ before_install:
8
+ - gem install bundler
data/README.md CHANGED
@@ -311,3 +311,23 @@ In future gem version we will actually introduce this two generators.
311
311
  3. Commit your changes (`git commit -am 'Add some feature'`)
312
312
  4. Push to the branch (`git push origin my-new-feature`)
313
313
  5. Create new Pull Request
314
+
315
+ ## Changelog
316
+
317
+ ##### 2019-11-29
318
+
319
+ Version 2.0.0 released
320
+
321
+ Till version [public_uid 1.3.1](https://github.com/equivalent/public_uid/tree/version-1.3.1) gem used [orm_adapter](https://github.com/ianwhite/orm_adapter) which mean
322
+ that you could use ActiveRecord or any other data mapping adapter (e.g. Mongoid) supported by orm adapter.
323
+
324
+ Problem is that orm_adapter is not maintained for 6 years now and cause some
325
+ gem conflicts with latest ActiveRecord development environment. That's
326
+ why I've decided to remove the ORM adapter ([commit](https://github.com/equivalent/public_uid/commit/e66b5dbf659fcdddc6b284b3eb2051a9b8a31968))
327
+ and use `ActiveRecord::Base` directly.
328
+
329
+ That means any Rails application using `public_uid` gem ActiveRecord will **not** be affected by the 2.0 release.
330
+ If anyone want to see public_uid v 2.0 to support other data mappers (e.g. mongo) please open an issue or create PR with the fix.
331
+
332
+ Sorry for any inconvenience
333
+
data/lib/public_uid.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'orm_adapter'
1
+ require 'active_record'
2
2
  require "public_uid/version"
3
3
  require "public_uid/set_public_uid"
4
4
  require "public_uid/model"
@@ -8,4 +8,4 @@ require "public_uid/generators/number_secure_random"
8
8
  require "public_uid/generators/hex_string_secure_random"
9
9
  require 'public_uid/tasks' if defined?(Rails)
10
10
 
11
- require 'orm/active_record' if defined?(ActiveRecord::Base)
11
+ ActiveRecord::Base.send(:include, PublicUid::Model)
@@ -3,7 +3,7 @@ require 'rake'
3
3
  namespace :public_uid do
4
4
  desc "Generate public_uid on Models that have public_uid column on records that have nil value"
5
5
  task :generate => :environment do
6
- Rails.application.eager_load!
6
+ Rails.application.eager_load! if defined?(Rails)
7
7
  ActiveRecord::Base.descendants.each do |model|
8
8
  model.connection # establish conection
9
9
 
@@ -15,7 +15,7 @@ namespace :public_uid do
15
15
  .tap { |scope| puts " * generating #{scope.count} #{uid_column_name}(s) for #{model.table_name}" }
16
16
  .find_each do |record_without_public_uid|
17
17
  record_without_public_uid.generate_uid
18
- record_without_public_uid.save!
18
+ record_without_public_uid.save!(validate: false)
19
19
  end
20
20
  puts ''
21
21
  end
@@ -1,3 +1,3 @@
1
1
  module PublicUid
2
- VERSION = "1.3.1"
2
+ VERSION = "2.0.0"
3
3
  end
data/public_uid.gemspec CHANGED
@@ -18,11 +18,10 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "orm_adapter", "~> 0.5"
22
- spec.add_development_dependency "bundler", "~> 1.3"
21
+ spec.add_dependency "activerecord", '> 4.2' # ensures compatibility for ruby 2.0.0+ to head
22
+ spec.add_development_dependency "bundler"
23
23
  spec.add_development_dependency "rake"
24
24
  spec.add_development_dependency "minitest", "~> 5"
25
25
  spec.add_development_dependency "rr", "~> 1.1.2"
26
- spec.add_development_dependency "sqlite3"
27
- spec.add_development_dependency "activerecord", '~> 4.2' # ensures compatibility for ruby 2.0.0+ to head
26
+ spec.add_development_dependency "sqlite3", "~> 1.4.1"
28
27
  end
@@ -8,26 +8,26 @@ describe 'HexStringSecureRandom' do
8
8
  context 'by default' do
9
9
  let(:instance){ PublicUid::Generators::HexStringSecureRandom.new }
10
10
  it 'generates 8 chars hexa string' do
11
- subject.length.must_equal 8
12
- subject.must_be_kind_of String
11
+ expect(subject.length).must_equal 8
12
+ expect(subject).must_be_kind_of String
13
13
  end
14
14
 
15
15
  it 'generates hexadecimal chars' do
16
- subject.must_match(/^[a-f0-9]*$/)
16
+ expect(subject).must_match(/^[a-f0-9]*$/)
17
17
  end
18
18
  end
19
19
 
20
20
  context 'when 10 hexa chars' do
21
21
  let(:instance){ PublicUid::Generators::HexStringSecureRandom.new(10) }
22
22
  it 'generates 10 chars string' do
23
- subject.length.must_equal 10
23
+ expect(subject.length).must_equal 10
24
24
  end
25
25
  end
26
26
 
27
27
  context 'when 11 hexa chars' do
28
28
  let(:instance){ PublicUid::Generators::HexStringSecureRandom.new(11) }
29
29
  it 'generates 11 chars string' do
30
- subject.length.must_equal 11
30
+ expect(subject.length).must_equal 11
31
31
  end
32
32
  end
33
33
  end
@@ -8,20 +8,20 @@ describe 'NumberRandom' do
8
8
  context 'by default' do
9
9
  let(:instance){ PublicUid::Generators::NumberRandom.new }
10
10
  it 'generates 7 digits' do
11
- subject.to_i.to_s.length.must_equal 7
12
- subject.must_be_kind_of Integer
11
+ expect(subject.to_i.to_s.length).must_equal 7
12
+ expect(subject).must_be_kind_of Integer
13
13
  end
14
14
  end
15
15
 
16
16
  context 'when specifying number between 20 - 21' do
17
17
  let(:instance){ PublicUid::Generators::NumberRandom.new(20..21) }
18
18
  it 'generates 2 digits' do
19
- subject.to_i.to_s.length.must_equal 2
20
- subject.must_be_kind_of Integer
19
+ expect(subject.to_i.to_s.length).must_equal 2
20
+ expect(subject).must_be_kind_of Integer
21
21
  end
22
22
 
23
23
  it 'generates integer has to be 20 or 21' do
24
- [20, 21].must_include subject
24
+ expect([20, 21]).must_include subject
25
25
  end
26
26
  end
27
27
  end
@@ -8,32 +8,32 @@ describe 'NumberSecureRandom' do
8
8
  context 'by default' do
9
9
  let(:instance){ PublicUid::Generators::NumberSecureRandom.new }
10
10
  it 'generates 7 digits' do
11
- subject.to_i.to_s.length.must_equal 7
12
- subject.must_be_kind_of Integer
11
+ expect(subject.to_i.to_s.length).must_equal 7
12
+ expect(subject).must_be_kind_of Integer
13
13
  end
14
14
  end
15
15
 
16
16
  context 'when specifying number between 20 - 21' do
17
17
  let(:instance){ PublicUid::Generators::NumberSecureRandom.new(20..21) }
18
18
  it 'generates 2 digits' do
19
- subject.to_i.to_s.length.must_equal 2
20
- subject.must_be_kind_of Integer
19
+ expect(subject.to_i.to_s.length).must_equal 2
20
+ expect(subject).must_be_kind_of Integer
21
21
  end
22
22
 
23
23
  it 'generates integer has to be 20 or 21' do
24
- [20, 21].must_include subject
24
+ expect([20, 21]).must_include subject
25
25
  end
26
26
  end
27
27
 
28
28
  context 'when specifying number between 1000 - 9999' do
29
29
  let(:instance){ PublicUid::Generators::NumberSecureRandom.new(1000..9999) }
30
30
  it 'generates 4 digits' do
31
- subject.to_i.to_s.length.must_equal 4
32
- subject.must_be_kind_of Integer
31
+ expect(subject.to_i.to_s.length).must_equal 4
32
+ expect(subject).must_be_kind_of Integer
33
33
  end
34
34
 
35
35
  it 'generates integer has to be between 1000 and 9999' do
36
- (1000..9999).must_include subject
36
+ expect((1000..9999)).must_include subject
37
37
  end
38
38
  end
39
39
  end
@@ -8,23 +8,23 @@ describe 'RangeString' do
8
8
  context 'by default' do
9
9
  let(:instance){ PublicUid::Generators::RangeString.new }
10
10
  it 'generates 8 chars string' do
11
- subject.length.must_equal 8
12
- subject.must_be_kind_of String
11
+ expect(subject.length).must_equal 8
12
+ expect(subject).must_be_kind_of String
13
13
  end
14
14
 
15
15
  it 'generates downcase chars' do
16
- subject.must_match(/^[a-z]*$/)
16
+ expect(subject).must_match(/^[a-z]*$/)
17
17
  end
18
18
  end
19
19
 
20
20
  context 'when 10 chars x-y' do
21
21
  let(:instance){ PublicUid::Generators::RangeString.new(3, ('x'..'z')) }
22
22
  it 'generates 10 chars string' do
23
- subject.length.must_equal 3
23
+ expect(subject.length).must_equal 3
24
24
  end
25
25
 
26
26
  it 'generates string containing chars x,y,z' do
27
- subject.must_match(/^[x-z]*$/)
27
+ expect(subject).must_match(/^[x-z]*$/)
28
28
  end
29
29
  end
30
30
  end
@@ -26,12 +26,20 @@ TestConf.orm_modules.each do |orm_module|
26
26
  describe 'initialization' do
27
27
  context 'when column not specified' do
28
28
  let(:options) { { record: record } }
29
- it{ ->{ instance } .must_raise(PublicUid::SetPublicUid::NoPublicUidColumnSpecified) }
29
+ it do
30
+ assert_raises PublicUid::SetPublicUid::NoPublicUidColumnSpecified do
31
+ instance
32
+ end
33
+ end
30
34
  end
31
35
 
32
36
  context 'when record not specified' do
33
37
  let(:options) { {column: :foo} }
34
- it{ ->{ instance } .must_raise(PublicUid::SetPublicUid::NoRecordSpecified) }
38
+ it do
39
+ assert_raises PublicUid::SetPublicUid::NoRecordSpecified do
40
+ instance
41
+ end
42
+ end
35
43
  end
36
44
  end
37
45
 
@@ -40,7 +48,7 @@ TestConf.orm_modules.each do |orm_module|
40
48
 
41
49
  it "should ask generator to generate random string" do
42
50
  instance.generate(DummyGenerator.new)
43
- subject.must_equal 'first try'
51
+ expect(subject).must_equal 'first try'
44
52
  end
45
53
 
46
54
  context 'when record match random' do
@@ -49,7 +57,7 @@ TestConf.orm_modules.each do |orm_module|
49
57
 
50
58
  it "should generate string once again" do
51
59
  instance.generate(DummyGenerator.new)
52
- subject.must_equal 'second try'
60
+ expect(subject).must_equal 'second try'
53
61
  end
54
62
  end
55
63
  end
@@ -58,7 +66,11 @@ TestConf.orm_modules.each do |orm_module|
58
66
  subject { instance.new_uid }
59
67
 
60
68
  context 'when @new id is not set' do
61
- it{ ->{ instance.set }.must_raise(PublicUid::SetPublicUid::NewUidNotSetYet) }
69
+ it do
70
+ assert_raises PublicUid::SetPublicUid::NewUidNotSetYet do
71
+ instance.set
72
+ end
73
+ end
62
74
  end
63
75
 
64
76
  context 'when @new id is set' do
@@ -66,7 +78,7 @@ TestConf.orm_modules.each do |orm_module|
66
78
 
67
79
  it 'must set new_uid for record pubilc_uid column' do
68
80
  instance.set
69
- subject.must_equal '123'
81
+ expect(subject).must_equal '123'
70
82
  end
71
83
  end
72
84
  end
@@ -84,7 +96,7 @@ TestConf.orm_modules.each do |orm_module|
84
96
  count_mock = stub(record_class).count { 10 }
85
97
  stub(record_class).where( { public_uid: 567 } ) { count_mock }
86
98
 
87
- trigger.must_equal true
99
+ expect(trigger).must_equal true
88
100
  end
89
101
  end
90
102
  end
@@ -29,23 +29,20 @@ describe 'Generate' do
29
29
  initial_uid = user.send(uid_column)
30
30
 
31
31
  # simulate an existing record with no uid value
32
- user.update_attribute(uid_column, nil).must_equal true
33
- user.send(uid_column).must_be_nil
32
+ expect(user.update_attribute(uid_column, nil)).must_equal true
33
+ expect(user.send(uid_column)).must_be_nil
34
34
 
35
35
  # run the rake task
36
36
  run_generate_task
37
37
 
38
38
  user.reload
39
- user.send(uid_column).must_be_kind_of String
40
- user.send(uid_column).wont_be_empty
41
- user.send(uid_column).wont_be_same_as initial_uid
39
+ expect(user.send(uid_column)).must_be_kind_of String
40
+ expect(user.send(uid_column)).wont_be_empty
41
+ expect(user.send(uid_column)).wont_be_same_as initial_uid
42
42
  end
43
43
  end
44
44
  end
45
-
46
45
  end
47
-
48
46
  end
49
47
  end
50
-
51
48
  end
@@ -9,14 +9,14 @@ TestConf.orm_modules.each do |orm_module|
9
9
  subject{ user.custom_uid }
10
10
 
11
11
  context 'in new record' do
12
- it{ subject.must_be_nil }
12
+ it{ expect(subject).must_be_nil }
13
13
 
14
14
  describe '#generate_uid' do
15
15
  before do
16
16
  user.generate_uid
17
17
  end
18
18
 
19
- it { subject.wont_be_nil }
19
+ it { expect(subject).wont_be_nil }
20
20
  end
21
21
  end
22
22
 
@@ -27,8 +27,8 @@ TestConf.orm_modules.each do |orm_module|
27
27
  user.reload
28
28
  end
29
29
 
30
- it{ subject.must_be_kind_of(String) }
31
- it{ subject.length.must_equal(8) }
30
+ it{ expect(subject).must_be_kind_of(String) }
31
+ it{ expect(subject.length).must_equal(8) }
32
32
  end
33
33
  end
34
34
  end
@@ -9,7 +9,7 @@ TestConf.orm_modules.each do |orm_module|
9
9
  end
10
10
 
11
11
  it 'model should not expose :generate_uid public instance method' do
12
- model.instance_methods.wont_include :generate_uid
12
+ expect(model.instance_methods).wont_include :generate_uid
13
13
  end
14
14
  end
15
15
 
@@ -19,7 +19,7 @@ TestConf.orm_modules.each do |orm_module|
19
19
  end
20
20
 
21
21
  it 'model should expose :generate_uid public instance method' do
22
- model.instance_methods.must_include :generate_uid
22
+ expect(model.instance_methods).must_include :generate_uid
23
23
  end
24
24
  end
25
25
  end
@@ -9,14 +9,14 @@ TestConf.orm_modules.each do |orm_module|
9
9
  subject{ user.public_uid }
10
10
 
11
11
  context 'in new record' do
12
- it{ subject.must_be_nil }
12
+ it{ expect(subject).must_be_nil }
13
13
 
14
14
  describe '#generate_uid' do
15
15
  before do
16
16
  user.generate_uid
17
17
  end
18
18
 
19
- it { subject.wont_be_nil }
19
+ it { expect(subject).wont_be_nil }
20
20
  end
21
21
  end
22
22
 
@@ -27,12 +27,12 @@ TestConf.orm_modules.each do |orm_module|
27
27
  end
28
28
 
29
29
  it 'should generate 10 chars' do
30
- subject.must_be_kind_of String
31
- subject.length.must_equal(10)
30
+ expect(subject).must_be_kind_of String
31
+ expect(subject.length).must_equal(10)
32
32
  end
33
33
 
34
34
  it 'string including up & down case' do
35
- subject.must_match(/^[a-zA-Z]+$/)
35
+ expect(subject).must_match(/^[a-zA-Z]+$/)
36
36
  end
37
37
  end
38
38
  end
@@ -9,14 +9,14 @@ TestConf.orm_modules.each do |orm_module|
9
9
  subject{ user.public_uid }
10
10
 
11
11
  context 'in new record' do
12
- it{ subject.must_be_nil }
12
+ it{ expect(subject).must_be_nil }
13
13
 
14
14
  describe '#generate_uid' do
15
15
  before do
16
16
  user.generate_uid
17
17
  end
18
18
 
19
- it { subject.wont_be_nil }
19
+ it { expect(subject).wont_be_nil }
20
20
  end
21
21
  end
22
22
 
@@ -27,8 +27,8 @@ TestConf.orm_modules.each do |orm_module|
27
27
  user.reload
28
28
  end
29
29
 
30
- it{ subject.must_be_kind_of(String) }
31
- it{ subject.length.must_equal(8) }
30
+ it{ expect(subject).must_be_kind_of(String) }
31
+ it{ expect(subject.length).must_equal(8) }
32
32
  end
33
33
  end
34
34
  end
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: public_uid
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Valent
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-25 00:00:00.000000000 Z
11
+ date: 2019-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: orm_adapter
14
+ name: activerecord
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.5'
19
+ version: '4.2'
20
20
  type: :runtime
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: '0.5'
26
+ version: '4.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '1.3'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '1.3'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -82,32 +82,18 @@ dependencies:
82
82
  version: 1.1.2
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: sqlite3
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: activerecord
99
85
  requirement: !ruby/object:Gem::Requirement
100
86
  requirements:
101
87
  - - "~>"
102
88
  - !ruby/object:Gem::Version
103
- version: '4.2'
89
+ version: 1.4.1
104
90
  type: :development
105
91
  prerelease: false
106
92
  version_requirements: !ruby/object:Gem::Requirement
107
93
  requirements:
108
94
  - - "~>"
109
95
  - !ruby/object:Gem::Version
110
- version: '4.2'
96
+ version: 1.4.1
111
97
  description: Automatic generates public unique identifier for model
112
98
  email:
113
99
  - equivalent@eq8.eu
@@ -121,7 +107,6 @@ files:
121
107
  - LICENSE.txt
122
108
  - README.md
123
109
  - Rakefile
124
- - lib/orm/active_record.rb
125
110
  - lib/public_uid.rb
126
111
  - lib/public_uid/generators/hex_string_secure_random.rb
127
112
  - lib/public_uid/generators/number_random.rb
@@ -1,2 +0,0 @@
1
- require 'orm_adapter/adapters/active_record'
2
- ActiveRecord::Base.send(:include, PublicUid::Model)