glebtv-mongoid_nested_set 0.5.2 → 0.5.3

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
  SHA1:
3
- metadata.gz: 6d3ae4fb0473cf7cef052ee941ef62e4d0f642ef
4
- data.tar.gz: ed8aef4a4d36c0936bbd8e0397fba3c84fb2907c
3
+ metadata.gz: e4bbc837da8191ec439a50dac4aada31c25a3108
4
+ data.tar.gz: 2b8bcbccc169e543ddd1c9bd4bb6534a05f0cdf2
5
5
  SHA512:
6
- metadata.gz: a9f0a5179fb255f08f64f78be3dc517e80acc04200e61b63b01372a9efd488817df9c8bfa1b458b18f12a2308e3d603fa4074328a98ff1595f5ed811ce079be9
7
- data.tar.gz: 20079c928fae0fbf0633c73f8d4d7ddff0b81b92125658be59fee61627fbaf68ebd279d7a4ab96cc45a35570904039be3cbc3815701f01137348049ead99c631
6
+ metadata.gz: 594c32953884950e05426f8ddf4aa1abd6095259303a9a5a7be9119992f602181579f92d922e52befb84b60aed92224b8ece7d10644c6d06f0c830cb0f5a6a85
7
+ data.tar.gz: ae0ae8f2280e304b43e9bba7333a6e754b519597abac0c296eba52a0f4dac6f39ef15c4dc55aacea69192cd55a03c272c6e6f8cf272133c30984595c55775318
@@ -1,5 +1,5 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem "mongoid", "~> 4.0.0.beta1"
3
+ gem "mongoid", "~> 4.0.0"
4
4
 
5
5
  gemspec path: "../"
@@ -0,0 +1,84 @@
1
+ PATH
2
+ remote: ../
3
+ specs:
4
+ glebtv-mongoid_nested_set (0.5.2)
5
+ mongoid (>= 4.0.0, < 6.1)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ activemodel (4.2.6)
11
+ activesupport (= 4.2.6)
12
+ builder (~> 3.1)
13
+ activesupport (4.2.6)
14
+ i18n (~> 0.7)
15
+ json (~> 1.7, >= 1.7.7)
16
+ minitest (~> 5.1)
17
+ thread_safe (~> 0.3, >= 0.3.4)
18
+ tzinfo (~> 1.1)
19
+ bson (3.2.6)
20
+ builder (3.2.2)
21
+ connection_pool (2.2.0)
22
+ database_cleaner (1.5.3)
23
+ diff-lcs (1.2.5)
24
+ docile (1.1.5)
25
+ i18n (0.7.0)
26
+ json (1.8.3)
27
+ minitest (5.9.0)
28
+ mongoid (4.0.2)
29
+ activemodel (~> 4.0)
30
+ moped (~> 2.0.0)
31
+ origin (~> 2.1)
32
+ tzinfo (>= 0.3.37)
33
+ mongoid-rspec (2.2.0)
34
+ mongoid (~> 4.0.0)
35
+ rake
36
+ rspec (~> 3.1)
37
+ moped (2.0.7)
38
+ bson (~> 3.0)
39
+ connection_pool (~> 2.0)
40
+ optionable (~> 0.2.0)
41
+ optionable (0.2.0)
42
+ origin (2.2.0)
43
+ rake (11.2.2)
44
+ rspec (3.5.0)
45
+ rspec-core (~> 3.5.0)
46
+ rspec-expectations (~> 3.5.0)
47
+ rspec-mocks (~> 3.5.0)
48
+ rspec-core (3.5.0)
49
+ rspec-support (~> 3.5.0)
50
+ rspec-expectations (3.5.0)
51
+ diff-lcs (>= 1.2.0, < 2.0)
52
+ rspec-support (~> 3.5.0)
53
+ rspec-mocks (3.5.0)
54
+ diff-lcs (>= 1.2.0, < 2.0)
55
+ rspec-support (~> 3.5.0)
56
+ rspec-support (3.5.0)
57
+ simplecov (0.11.2)
58
+ docile (~> 1.1.0)
59
+ json (~> 1.8)
60
+ simplecov-html (~> 0.10.0)
61
+ simplecov-html (0.10.0)
62
+ simplecov-rcov (0.2.3)
63
+ simplecov (>= 0.4.1)
64
+ thread_safe (0.3.5)
65
+ tzinfo (1.2.2)
66
+ thread_safe (~> 0.1)
67
+
68
+ PLATFORMS
69
+ ruby
70
+
71
+ DEPENDENCIES
72
+ bundler
73
+ database_cleaner
74
+ glebtv-mongoid_nested_set!
75
+ mongoid (~> 4.0.0)
76
+ mongoid-rspec
77
+ rake
78
+ rspec
79
+ rspec-expectations
80
+ simplecov
81
+ simplecov-rcov
82
+
83
+ BUNDLED WITH
84
+ 1.12.5
@@ -28,5 +28,5 @@ Gem::Specification.new do |s|
28
28
  s.add_development_dependency 'simplecov-rcov'
29
29
  s.add_development_dependency 'database_cleaner'
30
30
  s.add_development_dependency 'rspec-expectations'
31
- s.add_development_dependency 'mongoid-rspec', '3.0.0'
31
+ s.add_development_dependency 'mongoid-rspec'
32
32
  end
@@ -22,9 +22,13 @@ module Mongoid::Acts::NestedSet
22
22
  # set right
23
23
  right = (indices[scope.call(node)] += 1)
24
24
 
25
- node.class.collection.find(:_id => node.id).update_one(
26
- {"$set" => {left_field_name => left, right_field_name => right}},
27
- )
25
+ q = node.class.collection.find(:_id => node.id)
26
+ set = {"$set" => {left_field_name => left, right_field_name => right}}
27
+ if q.respond_to?(:update_one)
28
+ q.update_one(set)
29
+ else
30
+ q.update(set)
31
+ end
28
32
  end
29
33
 
30
34
  # scope rebuild for specified node
@@ -129,27 +129,27 @@ module Mongoid::Acts::NestedSet
129
129
  scope = nested_set_scope.remove_order_by
130
130
 
131
131
  # allocate space for new move
132
- collection.find(
132
+ update_many(collection.find(
133
133
  scope.gte(left_field_name => bound).selector
134
- ).update_many("$inc" => { left_field_name => width })
134
+ ), "$inc" => { left_field_name => width })
135
135
 
136
- collection.find(
136
+ update_many(collection.find(
137
137
  scope.gte(right_field_name => bound).selector
138
- ).update_many("$inc" => { right_field_name => width })
138
+ ), "$inc" => { right_field_name => width })
139
139
 
140
140
  # move the nodes
141
- collection.find(
141
+ update_many(collection.find(
142
142
  scope.and(left_field_name => {"$gte" => left}, right_field_name => {"$lt" => left + width}).selector
143
- ).update_many("$inc" => { left_field_name => distance, right_field_name => distance })
143
+ ), "$inc" => { left_field_name => distance, right_field_name => distance })
144
144
 
145
145
  # remove the hole
146
- collection.find(
146
+ update_many(collection.find(
147
147
  scope.gt(left_field_name => right).selector
148
- ).update_many("$inc" => { left_field_name => -width })
148
+ ), "$inc" => { left_field_name => -width })
149
149
 
150
- collection.find(
150
+ update_many(collection.find(
151
151
  scope.gt(right_field_name => right).selector
152
- ).update_many("$inc" => { right_field_name => -width })
152
+ ), "$inc" => { right_field_name => -width })
153
153
 
154
154
  self.mongoid_set(parent_field_name, new_parent)
155
155
  self.reload_nested_set
@@ -172,6 +172,13 @@ module Mongoid::Acts::NestedSet
172
172
  self
173
173
  end
174
174
 
175
+ def update_many(q, set)
176
+ if q.respond_to?(:update_all)
177
+ q.update_all(set)
178
+ else
179
+ q.update_many(set)
180
+ end
181
+ end
175
182
 
176
183
  # Update cached level attribute
177
184
  def update_depth
@@ -1,3 +1,3 @@
1
1
  module MongoidNestedSet
2
- VERSION = "0.5.2"
2
+ VERSION = "0.5.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glebtv-mongoid_nested_set
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - GlebTV
@@ -133,16 +133,16 @@ dependencies:
133
133
  name: mongoid-rspec
134
134
  requirement: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - '='
136
+ - - ">="
137
137
  - !ruby/object:Gem::Version
138
- version: 3.0.0
138
+ version: '0'
139
139
  type: :development
140
140
  prerelease: false
141
141
  version_requirements: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - '='
143
+ - - ">="
144
144
  - !ruby/object:Gem::Version
145
- version: 3.0.0
145
+ version: '0'
146
146
  description: Fully featured tree implementation for Mongoid using the nested set model
147
147
  email:
148
148
  - bt@brandonturner.net
@@ -163,6 +163,7 @@ files:
163
163
  - gemfiles/am-4.1.gemfile
164
164
  - gemfiles/mongoid-3.1.gemfile
165
165
  - gemfiles/mongoid-4.0.gemfile
166
+ - gemfiles/mongoid-4.0.gemfile.lock
166
167
  - glebtv-mongoid_nested_set.gemspec
167
168
  - lib/glebtv-mongoid_nested_set.rb
168
169
  - lib/mongoid_nested_set.rb