mongoid-auto_increment 2.3.0 → 2.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
- SHA1:
3
- metadata.gz: 687a8ef7997ca9fbb558945b41b32120b6ba6986
4
- data.tar.gz: a6b822dd2475482a9aa3d4a4c8922d32f53738f2
2
+ SHA256:
3
+ metadata.gz: 876e9c2048aae1ca83bdc4b3c1a403f0ea1e74403dcdd6b8ae6efa8d417f9dd2
4
+ data.tar.gz: 14120f367d8c585b892835914f77413b694c73875406d0bb2ae443283baa68a2
5
5
  SHA512:
6
- metadata.gz: 470c37ab9e31a796e79835cf0f7a2327bb5314af20523c7087e6e983b8a598feb3cb6eb8fd3dfb994d1f013ed186915cb3aa6f58be081356eff1903620020e10
7
- data.tar.gz: d5971cae6a1d84ffbc0c820ff4705cfc54283f1dbbdd96e4ce7766fef62080917431b5ff1cd0ced35242aeea79917cd9218dbdd4815a436bf8c1f188b84d1777
6
+ metadata.gz: dc7feb182e438f52ff399296fd1f61a2dbedad995a8b10c0c2a4f595892f32fcfb70d51c5e00700a1b4276f534b43022c35113b327b214609460fa86af133719
7
+ data.tar.gz: 101401b9fc451c7151c36132596c016624dfcfcff41c5cfb4a18ca0b04a9e80eed8450c67bac75cf4338147469419bfcdd8097ef1ac722d0accd0f7b60ab3d19
data/Rakefile CHANGED
@@ -1,15 +1,14 @@
1
1
  #!/usr/bin/env rake
2
- require 'bundler/gem_tasks'
3
- require 'rake/testtask'
2
+ require "bundler/gem_tasks"
3
+ require "rake/testtask"
4
4
 
5
- desc 'Default: run unit tests'
6
- task :default => :test
5
+ desc "Default: run unit tests"
6
+ task default: :test
7
7
 
8
- desc 'Run tests'
8
+ desc "Run tests"
9
9
  Rake::TestTask.new(:test) do |t|
10
- t.libs << 'lib'
11
- t.libs << 'test'
12
- t.pattern = 'test/**/*_test.rb'
13
- t.verbose = true
10
+ t.libs << "lib"
11
+ t.libs << "test"
12
+ t.pattern = "test/**/*_test.rb"
13
+ t.warning = false
14
14
  end
15
-
@@ -1,2 +1 @@
1
- require 'mongoid/auto_increment'
2
-
1
+ require "mongoid/auto_increment"
@@ -1,4 +1,4 @@
1
- require 'active_support/concern'
1
+ require "active_support/concern"
2
2
 
3
3
  module Mongoid
4
4
  module AutoIncrement
@@ -12,33 +12,33 @@ module Mongoid
12
12
  class_attribute :auto_increment_collection
13
13
  class_attribute :auto_increment_class_prefix
14
14
 
15
- self.auto_increment_value_field = 'value'
16
- self.auto_increment_class = self
17
- self.auto_incremented_fields = []
18
- self.auto_increment_classes = []
19
- self.auto_increment_collection = '__auto_increments'
20
- self.auto_increment_class_prefix = self.collection_name
15
+ self.auto_increment_value_field = "value"
16
+ self.auto_increment_class = self
17
+ self.auto_incremented_fields = []
18
+ self.auto_increment_classes = []
19
+ self.auto_increment_collection = "__auto_increments"
20
+ self.auto_increment_class_prefix = collection_name
21
21
 
22
22
  set_callback :create, :before, :auto_increment!, unless: :persisted?
23
23
 
24
- self.ancestors.each do |klass|
24
+ ancestors.each do |klass|
25
25
  if klass.respond_to?(:auto_incremented_fields)
26
- self.auto_increment_classes << klass
26
+ auto_increment_classes << klass
27
27
  end
28
28
  end
29
29
  end
30
30
 
31
31
  module ClassMethods
32
32
  def auto_incremented(name, opts = {})
33
- if self.auto_increment_class != self
34
- self.auto_increment_classes = self.auto_increment_classes + [self]
35
- self.auto_incremented_fields = self.auto_incremented_fields.dup
36
- if self.auto_increment_class.auto_increment_class_prefix == self.auto_increment_class_prefix
37
- self.auto_increment_class_prefix = self.collection_name
33
+ if auto_increment_class != self
34
+ self.auto_increment_classes = auto_increment_classes + [self]
35
+ self.auto_incremented_fields = auto_incremented_fields.dup
36
+ if auto_increment_class.auto_increment_class_prefix == auto_increment_class_prefix
37
+ self.auto_increment_class_prefix = collection_name
38
38
  end
39
39
  self.auto_increment_class = self
40
40
  end
41
- self.auto_incremented_fields << name
41
+ auto_incremented_fields << name
42
42
  field name, opts.merge({type: Integer})
43
43
  end
44
44
  end
@@ -47,15 +47,15 @@ module Mongoid
47
47
  client = self.class.mongo_client
48
48
  self.class.auto_increment_classes.each do |klass|
49
49
  klass.auto_incremented_fields.each do |name|
50
- if !self[name]
50
+ unless self[name]
51
51
  result = client.command({
52
52
  findAndModify: self.class.auto_increment_collection,
53
53
  query: {_id: "#{klass.auto_increment_class_prefix}_#{name}"},
54
- update: { '$inc' => { klass.auto_increment_value_field => 1 } },
54
+ update: {"$inc" => {klass.auto_increment_value_field => 1}},
55
55
  upsert: true,
56
56
  new: true,
57
57
  })
58
- self[name] = result.first['value'][klass.auto_increment_value_field]
58
+ self[name] = result.first["value"][klass.auto_increment_value_field]
59
59
  end
60
60
  end
61
61
  end
@@ -72,4 +72,3 @@ module Mongoid
72
72
  end
73
73
  end
74
74
  end
75
-
@@ -1,6 +1,5 @@
1
1
  module Mongoid
2
2
  module AutoIncrement
3
- VERSION = '2.3.0'
3
+ VERSION = "2.4.0"
4
4
  end
5
5
  end
6
-
@@ -1,7 +1,7 @@
1
- require 'test_helper'
1
+ require "test_helper"
2
2
 
3
3
  class ConsistencyTest < BaseTest
4
- test 'single auto increment consistency' do
4
+ test "single auto increment consistency" do
5
5
  n = 200
6
6
 
7
7
  n.times do
@@ -11,7 +11,7 @@ class ConsistencyTest < BaseTest
11
11
  assert_equal (1..n).to_a, FirstAutoIncrementedModel.only(:identifier).map(&:identifier).sort
12
12
  end
13
13
 
14
- test 'pre incrementing should not be overriden' do
14
+ test "pre incrementing should not be overriden" do
15
15
  n = 200
16
16
 
17
17
  n.times do
@@ -23,7 +23,7 @@ class ConsistencyTest < BaseTest
23
23
  assert_equal (1..n).to_a, FirstAutoIncrementedModel.only(:identifier).map(&:identifier).sort
24
24
  end
25
25
 
26
- test 'dup should create new identifier' do
26
+ test "dup should create new identifier" do
27
27
  n = 100
28
28
 
29
29
  n.times do
@@ -34,7 +34,7 @@ class ConsistencyTest < BaseTest
34
34
  assert_equal (1..(n * 2)).to_a, FirstAutoIncrementedModel.only(:identifier).map(&:identifier).sort
35
35
  end
36
36
 
37
- test 'double auto increment consistency' do
37
+ test "double auto increment consistency" do
38
38
  n = 100
39
39
 
40
40
  n.times do
@@ -46,4 +46,3 @@ class ConsistencyTest < BaseTest
46
46
  assert_equal (1..n).to_a, SecondAutoIncrementedModel.only(:identifier).map(&:identifier).sort
47
47
  end
48
48
  end
49
-
@@ -4,4 +4,3 @@ class FirstAutoIncrementedModel
4
4
 
5
5
  auto_incremented :identifier
6
6
  end
7
-
@@ -2,8 +2,7 @@ class SecondAutoIncrementedModel
2
2
  include Mongoid::Document
3
3
  include Mongoid::AutoIncrement
4
4
 
5
- self.auto_increment_value_field = 'seq'
5
+ self.auto_increment_value_field = "seq"
6
6
 
7
7
  auto_incremented :identifier
8
8
  end
9
-
@@ -1,4 +1,3 @@
1
1
  class SubclassModel < FirstAutoIncrementedModel
2
2
  auto_incremented :count
3
3
  end
4
-
@@ -1,7 +1,7 @@
1
- require 'test_helper'
1
+ require "test_helper"
2
2
 
3
3
  class SubclassTest < BaseTest
4
- test 'subclass auto increment' do
4
+ test "subclass auto increment" do
5
5
  n = 200
6
6
 
7
7
  n.times do
@@ -12,7 +12,7 @@ class SubclassTest < BaseTest
12
12
  assert_equal (1..n).to_a, SubclassModel.only(:count).map(&:count).sort
13
13
  end
14
14
 
15
- test 'subclass auto increment works with base' do
15
+ test "subclass auto increment works with base" do
16
16
  n = 100
17
17
 
18
18
  n.times do |i|
@@ -25,7 +25,7 @@ class SubclassTest < BaseTest
25
25
  assert_equal (1..n).to_a, SubclassModel.only(:count).map(&:count).sort
26
26
  end
27
27
 
28
- test 'mixed auto increment uniqueness' do
28
+ test "mixed auto increment uniqueness" do
29
29
  n = 100
30
30
 
31
31
  n.times do
@@ -36,7 +36,7 @@ class SubclassTest < BaseTest
36
36
  assert_equal n * 2, FirstAutoIncrementedModel.all.uniq.size
37
37
  end
38
38
 
39
- test 'mixed auto increment consistency' do
39
+ test "mixed auto increment consistency" do
40
40
  n = 100
41
41
 
42
42
  n.times do
@@ -47,4 +47,3 @@ class SubclassTest < BaseTest
47
47
  assert_equal (1..(n * 2)).to_a, FirstAutoIncrementedModel.only(:identifier).map(&:identifier).sort
48
48
  end
49
49
  end
50
-
@@ -1,28 +1,29 @@
1
- require 'bundler/setup'
2
- require 'simplecov'
1
+ require "bundler/setup"
2
+ require "simplecov"
3
3
  SimpleCov.configure do
4
- add_filter '/test/'
4
+ add_filter "/test/"
5
5
  end
6
- SimpleCov.start if ENV['COVERAGE']
6
+ SimpleCov.start if ENV["COVERAGE"]
7
7
 
8
- require 'minitest/autorun'
9
- require 'mongoid'
8
+ require "minitest/autorun"
9
+ require "mongoid"
10
10
 
11
- Mongo::Logger.logger = Logger.new(File.open(File.expand_path('../../log/test.log', __FILE__), 'a+'))
11
+ Mongo::Logger.logger = Logger.new(File.open(File.expand_path("../../log/test.log", __FILE__), "a+"))
12
12
 
13
13
  require File.expand_path("../../lib/mongoid-auto_increment", __FILE__)
14
14
 
15
15
  Mongoid.load!("#{File.dirname(__FILE__)}/mongoid.yml", "test")
16
16
 
17
- require_relative 'models/first_auto_incremented_model'
18
- require_relative 'models/second_auto_incremented_model'
19
- require_relative 'models/subclass_model'
17
+ require_relative "models/first_auto_incremented_model"
18
+ require_relative "models/second_auto_incremented_model"
19
+ require_relative "models/subclass_model"
20
20
 
21
21
  ActiveSupport::TestCase.test_order = :random
22
22
 
23
23
  class BaseTest < ActiveSupport::TestCase
24
24
  def teardown
25
- Mongoid.default_client.use('mongoid_auto_increment_test').database.drop
25
+ Mongoid.default_client.use("mongoid_auto_increment_test").database.drop
26
26
  end
27
27
  end
28
28
 
29
+ puts "Testing against mongoid: #{Mongoid::VERSION}"
@@ -1,7 +1,7 @@
1
- require 'test_helper'
1
+ require "test_helper"
2
2
 
3
3
  class UniquenessTest < BaseTest
4
- test 'single auto increment uniqueness' do
4
+ test "single auto increment uniqueness" do
5
5
  n = 200
6
6
 
7
7
  n.times do
@@ -11,7 +11,7 @@ class UniquenessTest < BaseTest
11
11
  assert_equal n, FirstAutoIncrementedModel.all.uniq.size
12
12
  end
13
13
 
14
- test 'double auto increment uniqueness' do
14
+ test "double auto increment uniqueness" do
15
15
  n = 100
16
16
 
17
17
  n.times do
@@ -23,4 +23,3 @@ class UniquenessTest < BaseTest
23
23
  assert_equal n, SecondAutoIncrementedModel.all.uniq.size
24
24
  end
25
25
  end
26
-
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-auto_increment
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geoffroy Planquart
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-21 00:00:00.000000000 Z
11
+ date: 2019-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: 5.0.0
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: 6.3.0
22
+ version: 7.1.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: 5.0.0
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: 6.3.0
32
+ version: 7.1.0
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: activesupport
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -90,17 +90,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
90
  - !ruby/object:Gem::Version
91
91
  version: '0'
92
92
  requirements: []
93
- rubyforge_project:
94
- rubygems_version: 2.6.13
93
+ rubygems_version: 3.0.6
95
94
  signing_key:
96
95
  specification_version: 4
97
96
  summary: Auto-incremented field for Mongoid
98
97
  test_files:
99
- - test/subclass_test.rb
100
- - test/models/second_auto_incremented_model.rb
98
+ - test/mongoid.yml
99
+ - test/consistency_test.rb
101
100
  - test/models/subclass_model.rb
102
101
  - test/models/first_auto_incremented_model.rb
103
- - test/consistency_test.rb
104
- - test/test_helper.rb
102
+ - test/models/second_auto_incremented_model.rb
105
103
  - test/uniqueness_test.rb
106
- - test/mongoid.yml
104
+ - test/test_helper.rb
105
+ - test/subclass_test.rb