dm-is-nested_set 0.9.9 → 0.9.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +8 -0
- data/lib/dm-is-nested_set.rb +2 -2
- data/lib/dm-is-nested_set/is/nested_set.rb +7 -3
- data/lib/dm-is-nested_set/is/version.rb +1 -1
- data/spec/integration/nested_set_spec.rb +3 -3
- data/tasks/spec.rb +1 -1
- metadata +4 -4
data/History.txt
CHANGED
data/lib/dm-is-nested_set.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'pathname'
|
2
2
|
require 'rubygems'
|
3
3
|
|
4
|
-
gem 'dm-core', '~>0.9.
|
4
|
+
gem 'dm-core', '~>0.9.10'
|
5
5
|
require 'dm-core'
|
6
6
|
|
7
|
-
#gem 'dm-adjust', '~>0.9.
|
7
|
+
#gem 'dm-adjust', '~>0.9.10'
|
8
8
|
require 'dm-adjust'
|
9
9
|
|
10
10
|
require Pathname(__FILE__).dirname.expand_path / 'dm-is-nested_set' / 'is' / 'nested_set'
|
@@ -199,7 +199,8 @@ module DataMapper
|
|
199
199
|
return false
|
200
200
|
end
|
201
201
|
|
202
|
-
|
202
|
+
|
203
|
+
DataMapper::Transaction.new(self.repository) do |transaction|
|
203
204
|
|
204
205
|
##
|
205
206
|
# if this node is already positioned we need to move it, and close the gap it leaves behind etc
|
@@ -210,23 +211,26 @@ module DataMapper
|
|
210
211
|
raise RecursiveNestingError if position > self.lft && position < self.rgt
|
211
212
|
# find out how wide this node is, as we need to make a gap large enough for it to fit in
|
212
213
|
gap = self.rgt - self.lft + 1
|
214
|
+
|
213
215
|
# make a gap at position, that is as wide as this node
|
214
216
|
self.model.base_model.adjust_gap!(nested_set,position-1,gap)
|
217
|
+
|
215
218
|
# offset this node (and all its descendants) to the right position
|
219
|
+
self.reload_attributes(:lft,:rgt)
|
216
220
|
old_position = self.lft
|
217
221
|
offset = position - old_position
|
222
|
+
|
218
223
|
nested_set.all(:rgt => self.lft..self.rgt).adjust!({:lft => offset, :rgt => offset},true)
|
219
224
|
# close the gap this movement left behind.
|
220
225
|
self.model.base_model.adjust_gap!(nested_set,old_position,-gap)
|
226
|
+
self.reload_attributes(:lft,:rgt)
|
221
227
|
else
|
222
228
|
# make a gap where the new node can be inserted
|
223
229
|
self.model.base_model.adjust_gap!(nested_set,position-1,2)
|
224
230
|
# set the position fields
|
225
231
|
self.lft, self.rgt = position, position + 1
|
226
232
|
end
|
227
|
-
|
228
233
|
self.parent = self.ancestor
|
229
|
-
|
230
234
|
end
|
231
235
|
end
|
232
236
|
|
@@ -30,7 +30,7 @@ if HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES
|
|
30
30
|
describe DataMapper::Is::NestedSet do
|
31
31
|
before do
|
32
32
|
Object.send(:remove_const, :User) if defined?(User)
|
33
|
-
class User
|
33
|
+
class ::User
|
34
34
|
include DataMapper::Resource
|
35
35
|
|
36
36
|
property :id, Serial
|
@@ -40,7 +40,7 @@ if HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES
|
|
40
40
|
end
|
41
41
|
|
42
42
|
Object.send(:remove_const, :Category) if defined?(Category)
|
43
|
-
class Category
|
43
|
+
class ::Category
|
44
44
|
include DataMapper::Resource
|
45
45
|
|
46
46
|
property :id, Integer, :serial => true
|
@@ -55,7 +55,7 @@ if HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES
|
|
55
55
|
end
|
56
56
|
|
57
57
|
Object.send(:remove_const, :CustomCategory) if defined?(CustomCategory)
|
58
|
-
class CustomCategory < Category; end
|
58
|
+
class ::CustomCategory < Category; end
|
59
59
|
|
60
60
|
DataMapper.auto_migrate!
|
61
61
|
|
data/tasks/spec.rb
CHANGED
@@ -8,7 +8,7 @@ begin
|
|
8
8
|
desc 'Run specifications'
|
9
9
|
Spec::Rake::SpecTask.new(:spec) do |t|
|
10
10
|
t.spec_opts << '--options' << 'spec/spec.opts' if File.exists?('spec/spec.opts')
|
11
|
-
t.spec_files = Pathname.glob((ROOT + 'spec/**/*_spec.rb').to_s)
|
11
|
+
t.spec_files = Pathname.glob((ROOT + 'spec/**/*_spec.rb').to_s).map { |f| f.to_s }
|
12
12
|
|
13
13
|
begin
|
14
14
|
gem 'rcov', '~>0.8'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dm-is-nested_set
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sindre Aarsaether
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-01-
|
12
|
+
date: 2009-01-19 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ~>
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0.9.
|
23
|
+
version: 0.9.10
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: dm-adjust
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.9.
|
33
|
+
version: 0.9.10
|
34
34
|
version:
|
35
35
|
description: DataMapper plugin allowing the creation of nested sets from data models
|
36
36
|
email:
|