dm-is-nested_set 1.1.0 → 1.2.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +8 -8
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/dm-is-nested_set.gemspec +22 -26
- data/lib/dm-is-nested_set/is/nested_set.rb +6 -7
- data/spec/integration/nested_set_spec.rb +28 -28
- metadata +65 -31
data/Gemfile
CHANGED
@@ -5,26 +5,26 @@ source 'http://rubygems.org'
|
|
5
5
|
SOURCE = ENV.fetch('SOURCE', :git).to_sym
|
6
6
|
REPO_POSTFIX = SOURCE == :path ? '' : '.git'
|
7
7
|
DATAMAPPER = SOURCE == :path ? Pathname(__FILE__).dirname.parent : 'http://github.com/datamapper'
|
8
|
-
DM_VERSION = '~> 1.
|
9
|
-
DO_VERSION = '~> 0.10.
|
8
|
+
DM_VERSION = '~> 1.2.0.rc1'
|
9
|
+
DO_VERSION = '~> 0.10.6'
|
10
10
|
DM_DO_ADAPTERS = %w[ sqlite postgres mysql oracle sqlserver ]
|
11
11
|
|
12
12
|
gem 'dm-adjust', DM_VERSION, SOURCE => "#{DATAMAPPER}/dm-adjust#{REPO_POSTFIX}"
|
13
13
|
|
14
14
|
group :development do
|
15
15
|
|
16
|
-
gem 'jeweler', '~> 1.
|
17
|
-
gem 'rake', '~> 0.
|
18
|
-
gem 'rspec', '~> 1.3.
|
16
|
+
gem 'jeweler', '~> 1.6.4'
|
17
|
+
gem 'rake', '~> 0.9.2'
|
18
|
+
gem 'rspec', '~> 1.3.2'
|
19
19
|
|
20
20
|
end
|
21
21
|
|
22
22
|
platforms :mri_18 do
|
23
23
|
group :quality do
|
24
24
|
|
25
|
-
gem 'rcov', '~> 0.9.
|
26
|
-
gem 'yard', '~> 0.
|
27
|
-
gem 'yardstick', '~> 0.
|
25
|
+
gem 'rcov', '~> 0.9.10'
|
26
|
+
gem 'yard', '~> 0.7.2'
|
27
|
+
gem 'yardstick', '~> 0.4'
|
28
28
|
|
29
29
|
end
|
30
30
|
end
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.2.0.rc1
|
data/dm-is-nested_set.gemspec
CHANGED
@@ -4,14 +4,14 @@
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "1.
|
7
|
+
s.name = "dm-is-nested_set"
|
8
|
+
s.version = "1.2.0.rc1"
|
9
9
|
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new("
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Sindre Aarsaether"]
|
12
|
-
s.date =
|
13
|
-
s.description =
|
14
|
-
s.email =
|
12
|
+
s.date = "2011-09-09"
|
13
|
+
s.description = "DataMapper plugin allowing the creation of nested sets from data models"
|
14
|
+
s.email = "sindre [a] identu [d] no"
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE",
|
17
17
|
"README.rdoc"
|
@@ -33,35 +33,31 @@ Gem::Specification.new do |s|
|
|
33
33
|
"tasks/yard.rake",
|
34
34
|
"tasks/yardstick.rake"
|
35
35
|
]
|
36
|
-
s.homepage =
|
36
|
+
s.homepage = "http://github.com/datamapper/dm-is-nested_set"
|
37
37
|
s.require_paths = ["lib"]
|
38
|
-
s.rubyforge_project =
|
39
|
-
s.rubygems_version =
|
40
|
-
s.summary =
|
41
|
-
s.test_files = [
|
42
|
-
"spec/integration/nested_set_spec.rb",
|
43
|
-
"spec/spec_helper.rb"
|
44
|
-
]
|
38
|
+
s.rubyforge_project = "datamapper"
|
39
|
+
s.rubygems_version = "1.8.10"
|
40
|
+
s.summary = "DataMapper plugin allowing the creation of nested sets from data models"
|
45
41
|
|
46
42
|
if s.respond_to? :specification_version then
|
47
43
|
s.specification_version = 3
|
48
44
|
|
49
45
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
50
|
-
s.add_runtime_dependency(%q<dm-adjust>, ["~> 1.
|
51
|
-
s.add_development_dependency(%q<jeweler>, ["~> 1.
|
52
|
-
s.add_development_dependency(%q<rake>, ["~> 0.
|
53
|
-
s.add_development_dependency(%q<rspec>, ["~> 1.3.
|
46
|
+
s.add_runtime_dependency(%q<dm-adjust>, ["~> 1.2.0.rc1"])
|
47
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
48
|
+
s.add_development_dependency(%q<rake>, ["~> 0.9.2"])
|
49
|
+
s.add_development_dependency(%q<rspec>, ["~> 1.3.2"])
|
54
50
|
else
|
55
|
-
s.add_dependency(%q<dm-adjust>, ["~> 1.
|
56
|
-
s.add_dependency(%q<jeweler>, ["~> 1.
|
57
|
-
s.add_dependency(%q<rake>, ["~> 0.
|
58
|
-
s.add_dependency(%q<rspec>, ["~> 1.3.
|
51
|
+
s.add_dependency(%q<dm-adjust>, ["~> 1.2.0.rc1"])
|
52
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
53
|
+
s.add_dependency(%q<rake>, ["~> 0.9.2"])
|
54
|
+
s.add_dependency(%q<rspec>, ["~> 1.3.2"])
|
59
55
|
end
|
60
56
|
else
|
61
|
-
s.add_dependency(%q<dm-adjust>, ["~> 1.
|
62
|
-
s.add_dependency(%q<jeweler>, ["~> 1.
|
63
|
-
s.add_dependency(%q<rake>, ["~> 0.
|
64
|
-
s.add_dependency(%q<rspec>, ["~> 1.3.
|
57
|
+
s.add_dependency(%q<dm-adjust>, ["~> 1.2.0.rc1"])
|
58
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
59
|
+
s.add_dependency(%q<rake>, ["~> 0.9.2"])
|
60
|
+
s.add_dependency(%q<rspec>, ["~> 1.3.2"])
|
65
61
|
end
|
66
62
|
end
|
67
63
|
|
@@ -70,7 +70,7 @@ module DataMapper
|
|
70
70
|
def root
|
71
71
|
# TODO scoping
|
72
72
|
# what should this return if there is a scope? always false, or node if there is only one?
|
73
|
-
args =
|
73
|
+
args = Hash[ nested_set_parent.zip([]) ]
|
74
74
|
roots.length > 1 ? false : first(args)
|
75
75
|
end
|
76
76
|
|
@@ -80,7 +80,7 @@ module DataMapper
|
|
80
80
|
def roots
|
81
81
|
# TODO scoping
|
82
82
|
# TODO supply filtering-option?
|
83
|
-
args =
|
83
|
+
args = Hash[ nested_set_parent.zip([]) ]
|
84
84
|
all(args)
|
85
85
|
end
|
86
86
|
|
@@ -117,8 +117,7 @@ module DataMapper
|
|
117
117
|
#
|
118
118
|
# @private
|
119
119
|
def nested_set_scope
|
120
|
-
|
121
|
-
DataMapper::Ext::Array.to_hash(pairs)
|
120
|
+
Hash[ model.base_model.nested_set_scope.map { |p| [ p, attribute_get(p) ] } ]
|
122
121
|
end
|
123
122
|
|
124
123
|
##
|
@@ -126,10 +125,10 @@ module DataMapper
|
|
126
125
|
# @private
|
127
126
|
def original_nested_set_scope
|
128
127
|
# TODO commit
|
129
|
-
pairs = model.base_model.nested_set_scope.map
|
128
|
+
pairs = model.base_model.nested_set_scope.map do |p|
|
130
129
|
[ p, (property = properties[p]) && original_attributes.key?(property) ? original_attributes[property] : attribute_get(p) ]
|
131
|
-
|
132
|
-
|
130
|
+
end
|
131
|
+
Hash[ pairs ]
|
133
132
|
end
|
134
133
|
|
135
134
|
##
|
@@ -72,7 +72,7 @@ describe DataMapper::Is::NestedSet do
|
|
72
72
|
describe 'Class#rebuild_tree_from_set' do
|
73
73
|
it 'should reset all parent_ids correctly' do
|
74
74
|
DataMapper.repository do
|
75
|
-
plasma = Category.
|
75
|
+
plasma = Category.first(:name => 'Plasma')
|
76
76
|
plasma.parent_id.should == 2
|
77
77
|
plasma.ancestor.id.should == 2
|
78
78
|
plasma.pos.should == [7,8]
|
@@ -104,8 +104,8 @@ describe DataMapper::Is::NestedSet do
|
|
104
104
|
describe '#ancestor, #ancestors and #self_and_ancestors' do
|
105
105
|
it 'should return ancestors in an array' do
|
106
106
|
DataMapper.repository do
|
107
|
-
c8 = Category.
|
108
|
-
c8.ancestor.should == Category.
|
107
|
+
c8 = Category.first(:name => 'Flash')
|
108
|
+
c8.ancestor.should == Category.first(:name => 'MP3 Players')
|
109
109
|
c8.ancestor.should == c8.parent
|
110
110
|
|
111
111
|
c8.ancestors.map{|a|a.name}.should == ['Electronics','Portable Electronics','MP3 Players']
|
@@ -131,7 +131,7 @@ describe DataMapper::Is::NestedSet do
|
|
131
131
|
describe '#descendants and #self_and_descendants' do
|
132
132
|
it 'should return all subnodes of node' do
|
133
133
|
DataMapper.repository do
|
134
|
-
r = Category.
|
134
|
+
r = Category.first(:name => 'Electronics')
|
135
135
|
r.self_and_descendants.length.should == 10
|
136
136
|
r.descendants.length.should == 9
|
137
137
|
r.name.should == 'Electronics'
|
@@ -176,30 +176,30 @@ describe DataMapper::Is::NestedSet do
|
|
176
176
|
it 'should move items correctly with :higher / :highest / :lower / :lowest' do
|
177
177
|
DataMapper.repository do
|
178
178
|
|
179
|
-
Category.
|
179
|
+
Category.first(:name => 'LCD').pos.should == [5,6]
|
180
180
|
|
181
|
-
Category.
|
182
|
-
Category.
|
181
|
+
Category.first(:name => 'LCD').move(:above => Category.first(:name => 'Tube'))
|
182
|
+
Category.first(:name => 'LCD').pos.should == [3,4]
|
183
183
|
|
184
|
-
Category.
|
185
|
-
Category.
|
186
|
-
Category.
|
187
|
-
Category.
|
184
|
+
Category.first(:name => 'LCD').move(:higher).should == false
|
185
|
+
Category.first(:name => 'LCD').pos.should == [3,4]
|
186
|
+
Category.first(:name => 'Tube').pos.should == [5,6]
|
187
|
+
Category.first(:name => 'LCD').right_sibling.should == Category.first(:name => 'Tube')
|
188
188
|
|
189
|
-
Category.
|
190
|
-
Category.
|
191
|
-
Category.
|
192
|
-
Category.
|
189
|
+
Category.first(:name => 'LCD').move(:lower)
|
190
|
+
Category.first(:name => 'LCD').pos.should == [5,6]
|
191
|
+
Category.first(:name => 'LCD').left_sibling.should == Category.first(:name => 'Tube')
|
192
|
+
Category.first(:name => 'LCD').right_sibling.should == Category.first(:name => 'Plasma')
|
193
193
|
|
194
|
-
Category.
|
195
|
-
Category.
|
196
|
-
Category.
|
194
|
+
Category.first(:name => 'LCD').move(:highest)
|
195
|
+
Category.first(:name => 'LCD').pos.should == [3,4]
|
196
|
+
Category.first(:name => 'LCD').move(:higher).should == false
|
197
197
|
|
198
|
-
Category.
|
199
|
-
Category.
|
200
|
-
Category.
|
198
|
+
Category.first(:name => 'LCD').move(:lowest)
|
199
|
+
Category.first(:name => 'LCD').pos.should == [7,8]
|
200
|
+
Category.first(:name => 'LCD').left_sibling.should == Category.first(:name => 'Plasma')
|
201
201
|
|
202
|
-
Category.
|
202
|
+
Category.first(:name => 'LCD').move(:higher) # should reset the tree to how it was
|
203
203
|
|
204
204
|
end
|
205
205
|
end
|
@@ -207,10 +207,10 @@ describe DataMapper::Is::NestedSet do
|
|
207
207
|
it 'should move items correctly with :indent / :outdent' do
|
208
208
|
DataMapper.repository do
|
209
209
|
|
210
|
-
mp3_players = Category.
|
210
|
+
mp3_players = Category.first(:name => 'MP3 Players')
|
211
211
|
|
212
|
-
portable_electronics = Category.
|
213
|
-
televisions = Category.
|
212
|
+
portable_electronics = Category.first(:name => 'Portable Electronics')
|
213
|
+
televisions = Category.first(:name => 'Televisions')
|
214
214
|
|
215
215
|
mp3_players.pos.should == [11,14]
|
216
216
|
#mp3_players.descendants.length.should == 1
|
@@ -287,7 +287,7 @@ describe DataMapper::Is::NestedSet do
|
|
287
287
|
describe 'scoping' do
|
288
288
|
it 'should detach from list when changing scope' do
|
289
289
|
DataMapper.repository do
|
290
|
-
plasma = Category.
|
290
|
+
plasma = Category.first(:name => 'Plasma')
|
291
291
|
plasma.pos.should == [7,8]
|
292
292
|
plasma.update(:user => @other)
|
293
293
|
plasma.pos.should == [1,2]
|
@@ -298,9 +298,9 @@ describe DataMapper::Is::NestedSet do
|
|
298
298
|
describe 'integrity' do
|
299
299
|
it 'should detach object from list when deleted' do
|
300
300
|
DataMapper.repository do
|
301
|
-
lcd = Category.
|
301
|
+
lcd = Category.first(:name => 'LCD')
|
302
302
|
lcd.pos.should == [5,6]
|
303
|
-
Category.
|
303
|
+
Category.first(:name => 'Tube').destroy
|
304
304
|
lcd.pos.should == [3,4]
|
305
305
|
end
|
306
306
|
end
|
metadata
CHANGED
@@ -1,8 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dm-is-nested_set
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
4
|
+
hash: 15424023
|
5
|
+
prerelease: 6
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
- rc
|
11
|
+
- 1
|
12
|
+
version: 1.2.0.rc1
|
6
13
|
platform: ruby
|
7
14
|
authors:
|
8
15
|
- Sindre Aarsaether
|
@@ -10,53 +17,74 @@ autorequire:
|
|
10
17
|
bindir: bin
|
11
18
|
cert_chain: []
|
12
19
|
|
13
|
-
date: 2011-
|
14
|
-
default_executable:
|
20
|
+
date: 2011-09-09 00:00:00 Z
|
15
21
|
dependencies:
|
16
22
|
- !ruby/object:Gem::Dependency
|
17
|
-
|
18
|
-
|
23
|
+
type: :runtime
|
24
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
19
25
|
none: false
|
20
26
|
requirements:
|
21
27
|
- - ~>
|
22
28
|
- !ruby/object:Gem::Version
|
23
|
-
|
24
|
-
|
29
|
+
hash: 15424023
|
30
|
+
segments:
|
31
|
+
- 1
|
32
|
+
- 2
|
33
|
+
- 0
|
34
|
+
- rc
|
35
|
+
- 1
|
36
|
+
version: 1.2.0.rc1
|
25
37
|
prerelease: false
|
26
|
-
|
38
|
+
requirement: *id001
|
39
|
+
name: dm-adjust
|
27
40
|
- !ruby/object:Gem::Dependency
|
28
|
-
|
29
|
-
|
41
|
+
type: :development
|
42
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
30
43
|
none: false
|
31
44
|
requirements:
|
32
45
|
- - ~>
|
33
46
|
- !ruby/object:Gem::Version
|
34
|
-
|
35
|
-
|
47
|
+
hash: 7
|
48
|
+
segments:
|
49
|
+
- 1
|
50
|
+
- 6
|
51
|
+
- 4
|
52
|
+
version: 1.6.4
|
36
53
|
prerelease: false
|
37
|
-
|
54
|
+
requirement: *id002
|
55
|
+
name: jeweler
|
38
56
|
- !ruby/object:Gem::Dependency
|
39
|
-
|
40
|
-
|
57
|
+
type: :development
|
58
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
41
59
|
none: false
|
42
60
|
requirements:
|
43
61
|
- - ~>
|
44
62
|
- !ruby/object:Gem::Version
|
45
|
-
|
46
|
-
|
63
|
+
hash: 63
|
64
|
+
segments:
|
65
|
+
- 0
|
66
|
+
- 9
|
67
|
+
- 2
|
68
|
+
version: 0.9.2
|
47
69
|
prerelease: false
|
48
|
-
|
70
|
+
requirement: *id003
|
71
|
+
name: rake
|
49
72
|
- !ruby/object:Gem::Dependency
|
50
|
-
|
51
|
-
|
73
|
+
type: :development
|
74
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
52
75
|
none: false
|
53
76
|
requirements:
|
54
77
|
- - ~>
|
55
78
|
- !ruby/object:Gem::Version
|
56
|
-
|
57
|
-
|
79
|
+
hash: 31
|
80
|
+
segments:
|
81
|
+
- 1
|
82
|
+
- 3
|
83
|
+
- 2
|
84
|
+
version: 1.3.2
|
58
85
|
prerelease: false
|
59
|
-
|
86
|
+
requirement: *id004
|
87
|
+
name: rspec
|
60
88
|
description: DataMapper plugin allowing the creation of nested sets from data models
|
61
89
|
email: sindre [a] identu [d] no
|
62
90
|
executables: []
|
@@ -82,7 +110,6 @@ files:
|
|
82
110
|
- tasks/spec.rake
|
83
111
|
- tasks/yard.rake
|
84
112
|
- tasks/yardstick.rake
|
85
|
-
has_rdoc: true
|
86
113
|
homepage: http://github.com/datamapper/dm-is-nested_set
|
87
114
|
licenses: []
|
88
115
|
|
@@ -96,20 +123,27 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
96
123
|
requirements:
|
97
124
|
- - ">="
|
98
125
|
- !ruby/object:Gem::Version
|
126
|
+
hash: 3
|
127
|
+
segments:
|
128
|
+
- 0
|
99
129
|
version: "0"
|
100
130
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
131
|
none: false
|
102
132
|
requirements:
|
103
|
-
- - "
|
133
|
+
- - ">"
|
104
134
|
- !ruby/object:Gem::Version
|
105
|
-
|
135
|
+
hash: 25
|
136
|
+
segments:
|
137
|
+
- 1
|
138
|
+
- 3
|
139
|
+
- 1
|
140
|
+
version: 1.3.1
|
106
141
|
requirements: []
|
107
142
|
|
108
143
|
rubyforge_project: datamapper
|
109
|
-
rubygems_version: 1.
|
144
|
+
rubygems_version: 1.8.10
|
110
145
|
signing_key:
|
111
146
|
specification_version: 3
|
112
147
|
summary: DataMapper plugin allowing the creation of nested sets from data models
|
113
|
-
test_files:
|
114
|
-
|
115
|
-
- spec/spec_helper.rb
|
148
|
+
test_files: []
|
149
|
+
|