dm-is-nested_set 0.10.2 → 1.0.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +36 -0
- data/Gemfile +143 -0
- data/Rakefile +4 -4
- data/VERSION +1 -1
- data/dm-is-nested_set.gemspec +25 -18
- data/lib/dm-is-nested_set/is/nested_set.rb +10 -3
- data/lib/dm-is-nested_set.rb +2 -0
- data/spec/integration/nested_set_spec.rb +69 -67
- data/spec/spec_helper.rb +5 -31
- data/tasks/local_gemfile.rake +18 -0
- data/tasks/spec.rake +0 -3
- metadata +76 -31
data/.gitignore
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
## MAC OS
|
2
|
+
.DS_Store
|
3
|
+
|
4
|
+
## TEXTMATE
|
5
|
+
*.tmproj
|
6
|
+
tmtags
|
7
|
+
|
8
|
+
## EMACS
|
9
|
+
*~
|
10
|
+
\#*
|
11
|
+
.\#*
|
12
|
+
|
13
|
+
## VIM
|
14
|
+
*.swp
|
15
|
+
|
16
|
+
## Rubinius
|
17
|
+
*.rbc
|
18
|
+
|
19
|
+
## PROJECT::GENERAL
|
20
|
+
*.gem
|
21
|
+
coverage
|
22
|
+
rdoc
|
23
|
+
pkg
|
24
|
+
tmp
|
25
|
+
doc
|
26
|
+
log
|
27
|
+
.yardoc
|
28
|
+
measurements
|
29
|
+
|
30
|
+
## BUNDLER
|
31
|
+
.bundle
|
32
|
+
Gemfile.local
|
33
|
+
Gemfile.lock
|
34
|
+
|
35
|
+
## PROJECT::SPECIFIC
|
36
|
+
spec/db/
|
data/Gemfile
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
# If you're working on more than one datamapper gem at a time, then it's
|
2
|
+
# recommended to create a local Gemfile and use this instead of the git
|
3
|
+
# sources. This will make sure that you are developing against your
|
4
|
+
# other local datamapper sources that you currently work on. Gemfile.local
|
5
|
+
# will behave identically to the standard Gemfile apart from the fact that
|
6
|
+
# it fetches the datamapper gems from local paths. This means that you can use
|
7
|
+
# the same environment variables, like ADAPTER(S) or PLUGIN(S) when running
|
8
|
+
# bundle commands. Gemfile.local is added to .gitignore, so you don't need to
|
9
|
+
# worry about accidentally checking local development paths into git.
|
10
|
+
# In order to create a local Gemfile, all you need to do is run:
|
11
|
+
#
|
12
|
+
# bundle exec rake local_gemfile
|
13
|
+
#
|
14
|
+
# This will give you a Gemfile.local file that points to your local clones of
|
15
|
+
# the various datamapper gems. It's assumed that all datamapper repo clones
|
16
|
+
# reside in the same directory. You can use the Gemfile.local like so for
|
17
|
+
# running any bundle command:
|
18
|
+
#
|
19
|
+
# BUNDLE_GEMFILE=Gemfile.local bundle foo
|
20
|
+
#
|
21
|
+
# You can also specify which adapter(s) should be part of the bundle by setting
|
22
|
+
# an environment variable. This of course also works when using the Gemfile.local
|
23
|
+
#
|
24
|
+
# bundle foo # dm-sqlite-adapter
|
25
|
+
# ADAPTER=mysql bundle foo # dm-mysql-adapter
|
26
|
+
# ADAPTERS=sqlite,mysql bundle foo # dm-sqlite-adapter and dm-mysql-adapter
|
27
|
+
#
|
28
|
+
# Of course you can also use the ADAPTER(S) variable when using the Gemfile.local
|
29
|
+
# and running specs against selected adapters.
|
30
|
+
#
|
31
|
+
# For easily working with adapters supported on your machine, it's recommended
|
32
|
+
# that you first install all adapters that you are planning to use or work on
|
33
|
+
# by doing something like
|
34
|
+
#
|
35
|
+
# ADAPTERS=sqlite,mysql,postgres bundle install
|
36
|
+
#
|
37
|
+
# This will clone the various repositories and make them available to bundler.
|
38
|
+
# Once you have them installed you can easily switch between adapters for the
|
39
|
+
# various development tasks. Running something like
|
40
|
+
#
|
41
|
+
# ADAPTER=mysql bundle exec rake spec
|
42
|
+
#
|
43
|
+
# will make sure that the dm-mysql-adapter is part of the bundle, and will be used
|
44
|
+
# when running the specs.
|
45
|
+
#
|
46
|
+
# You can also specify which plugin(s) should be part of the bundle by setting
|
47
|
+
# an environment variable. This also works when using the Gemfile.local
|
48
|
+
#
|
49
|
+
# bundle foo # dm-migrations
|
50
|
+
# PLUGINS=dm-validations bundle foo # dm-migrations and dm-validations
|
51
|
+
# PLUGINS=dm-validations,dm-types bundle foo # dm-migrations, dm-validations and dm-types
|
52
|
+
#
|
53
|
+
# Of course you can combine the PLUGIN(S) and ADAPTER(S) env vars to run specs
|
54
|
+
# for certain adapter/plugin combinations.
|
55
|
+
#
|
56
|
+
# Finally, to speed up running specs and other tasks, it's recommended to run
|
57
|
+
#
|
58
|
+
# bundle lock
|
59
|
+
#
|
60
|
+
# after running 'bundle install' for the first time. This will make 'bundle exec' run
|
61
|
+
# a lot faster compared to the unlocked version. With an unlocked bundle you would
|
62
|
+
# typically just run 'bundle install' from time to time to fetch the latest sources from
|
63
|
+
# upstream. When you locked your bundle, you need to run
|
64
|
+
#
|
65
|
+
# bundle install --relock
|
66
|
+
#
|
67
|
+
# to make sure to fetch the latest updates and then lock the bundle again. Gemfile.lock
|
68
|
+
# is added to the .gitignore file, so you don't need to worry about accidentally checking
|
69
|
+
# it into version control.
|
70
|
+
|
71
|
+
source 'http://rubygems.org'
|
72
|
+
|
73
|
+
DATAMAPPER = 'git://github.com/datamapper'
|
74
|
+
DM_VERSION = '~> 1.0.0.rc2'
|
75
|
+
|
76
|
+
group :runtime do # Runtime dependencies (as in the gemspec)
|
77
|
+
|
78
|
+
if ENV['EXTLIB']
|
79
|
+
gem 'extlib', '~> 0.9.15', :git => "#{DATAMAPPER}/extlib.git"
|
80
|
+
else
|
81
|
+
gem 'activesupport', '~> 3.0.0.beta3', :git => 'git://github.com/rails/rails.git', :require => nil
|
82
|
+
end
|
83
|
+
|
84
|
+
gem 'dm-core', DM_VERSION, :git => "#{DATAMAPPER}/dm-core.git"
|
85
|
+
gem 'dm-adjust', DM_VERSION, :git => "#{DATAMAPPER}/dm-adjust.git"
|
86
|
+
gem 'dm-transactions', DM_VERSION, :git => "#{DATAMAPPER}/dm-transactions.git"
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
group(:development) do # Development dependencies (as in the gemspec)
|
91
|
+
|
92
|
+
gem 'rake', '~> 0.8.7'
|
93
|
+
gem 'rspec', '~> 1.3'
|
94
|
+
gem 'jeweler', '~> 1.4'
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
group :quality do # These gems contain rake tasks that check the quality of the source code
|
99
|
+
|
100
|
+
gem 'metric_fu', '~> 1.3'
|
101
|
+
gem 'rcov', '~> 0.9.8'
|
102
|
+
gem 'reek', '~> 1.2.8'
|
103
|
+
gem 'roodi', '~> 2.1'
|
104
|
+
gem 'yard', '~> 0.5'
|
105
|
+
gem 'yardstick', '~> 0.1'
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
group :datamapper do # We need this because we want to pin these dependencies to their git master sources
|
110
|
+
|
111
|
+
adapters = ENV['ADAPTER'] || ENV['ADAPTERS']
|
112
|
+
adapters = adapters.to_s.gsub(',',' ').split(' ') - ['in_memory']
|
113
|
+
|
114
|
+
unless adapters.empty?
|
115
|
+
|
116
|
+
DO_VERSION = '~> 0.10.3'
|
117
|
+
DM_DO_ADAPTERS = %w[sqlite postgres mysql oracle sqlserver]
|
118
|
+
|
119
|
+
gem 'data_objects', DO_VERSION, :git => "#{DATAMAPPER}/do.git"
|
120
|
+
|
121
|
+
adapters.each do |adapter|
|
122
|
+
if DM_DO_ADAPTERS.any? { |dm_do_adapter| dm_do_adapter =~ /#{adapter}/ }
|
123
|
+
adapter = 'sqlite3' if adapter == 'sqlite'
|
124
|
+
gem "do_#{adapter}", DO_VERSION, :git => "#{DATAMAPPER}/do.git"
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
gem 'dm-do-adapter', DM_VERSION, :git => "#{DATAMAPPER}/dm-do-adapter.git"
|
129
|
+
|
130
|
+
adapters.each do |adapter|
|
131
|
+
gem "dm-#{adapter}-adapter", DM_VERSION, :git => "#{DATAMAPPER}/dm-#{adapter}-adapter.git"
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|
135
|
+
|
136
|
+
plugins = ENV['PLUGINS'] || ENV['PLUGIN']
|
137
|
+
plugins = (plugins.to_s.gsub(',',' ').split(' ') + ['dm-migrations']).uniq
|
138
|
+
|
139
|
+
plugins.each do |plugin|
|
140
|
+
gem plugin, DM_VERSION, :git => "#{DATAMAPPER}/#{plugin}.git"
|
141
|
+
end
|
142
|
+
|
143
|
+
end
|
data/Rakefile
CHANGED
@@ -15,11 +15,11 @@ begin
|
|
15
15
|
|
16
16
|
gem.rubyforge_project = 'datamapper'
|
17
17
|
|
18
|
-
gem.add_dependency 'dm-core',
|
19
|
-
gem.add_dependency 'dm-adjust',
|
18
|
+
gem.add_dependency 'dm-core', '~> 1.0.0.rc2'
|
19
|
+
gem.add_dependency 'dm-adjust', '~> 1.0.0.rc2'
|
20
|
+
gem.add_dependency 'dm-transactions', '~> 1.0.0.rc2'
|
20
21
|
|
21
|
-
gem.add_development_dependency 'rspec', '~> 1.
|
22
|
-
gem.add_development_dependency 'yard', '~> 0.4.0'
|
22
|
+
gem.add_development_dependency 'rspec', '~> 1.3'
|
23
23
|
end
|
24
24
|
|
25
25
|
Jeweler::GemcutterTasks.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
1.0.0.rc2
|
data/dm-is-nested_set.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{dm-is-nested_set}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "1.0.0.rc2"
|
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 = %q{
|
12
|
+
s.date = %q{2010-05-19}
|
13
13
|
s.description = %q{DataMapper plugin allowing the creation of nested sets from data models}
|
14
14
|
s.email = %q{sindre [a] identu [d] no}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -17,7 +17,9 @@ Gem::Specification.new do |s|
|
|
17
17
|
"README.rdoc"
|
18
18
|
]
|
19
19
|
s.files = [
|
20
|
-
"
|
20
|
+
".gitignore",
|
21
|
+
"Gemfile",
|
22
|
+
"LICENSE",
|
21
23
|
"README.rdoc",
|
22
24
|
"Rakefile",
|
23
25
|
"VERSION",
|
@@ -29,6 +31,7 @@ Gem::Specification.new do |s|
|
|
29
31
|
"spec/spec.opts",
|
30
32
|
"spec/spec_helper.rb",
|
31
33
|
"tasks/ci.rake",
|
34
|
+
"tasks/local_gemfile.rake",
|
32
35
|
"tasks/metrics.rake",
|
33
36
|
"tasks/spec.rake",
|
34
37
|
"tasks/yard.rake",
|
@@ -38,29 +41,33 @@ Gem::Specification.new do |s|
|
|
38
41
|
s.rdoc_options = ["--charset=UTF-8"]
|
39
42
|
s.require_paths = ["lib"]
|
40
43
|
s.rubyforge_project = %q{datamapper}
|
41
|
-
s.rubygems_version = %q{1.3.
|
44
|
+
s.rubygems_version = %q{1.3.7}
|
42
45
|
s.summary = %q{DataMapper plugin allowing the creation of nested sets from data models}
|
46
|
+
s.test_files = [
|
47
|
+
"spec/integration/nested_set_spec.rb",
|
48
|
+
"spec/spec_helper.rb"
|
49
|
+
]
|
43
50
|
|
44
51
|
if s.respond_to? :specification_version then
|
45
52
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
46
53
|
s.specification_version = 3
|
47
54
|
|
48
|
-
if Gem::Version.new(Gem::
|
49
|
-
s.add_runtime_dependency(%q<dm-core>, ["~> 0.
|
50
|
-
s.add_runtime_dependency(%q<dm-adjust>, ["~> 0.
|
51
|
-
s.
|
52
|
-
s.add_development_dependency(%q<
|
55
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
56
|
+
s.add_runtime_dependency(%q<dm-core>, ["~> 1.0.0.rc2"])
|
57
|
+
s.add_runtime_dependency(%q<dm-adjust>, ["~> 1.0.0.rc2"])
|
58
|
+
s.add_runtime_dependency(%q<dm-transactions>, ["~> 1.0.0.rc2"])
|
59
|
+
s.add_development_dependency(%q<rspec>, ["~> 1.3"])
|
53
60
|
else
|
54
|
-
s.add_dependency(%q<dm-core>, ["~> 0.
|
55
|
-
s.add_dependency(%q<dm-adjust>, ["~> 0.
|
56
|
-
s.add_dependency(%q<
|
57
|
-
s.add_dependency(%q<
|
61
|
+
s.add_dependency(%q<dm-core>, ["~> 1.0.0.rc2"])
|
62
|
+
s.add_dependency(%q<dm-adjust>, ["~> 1.0.0.rc2"])
|
63
|
+
s.add_dependency(%q<dm-transactions>, ["~> 1.0.0.rc2"])
|
64
|
+
s.add_dependency(%q<rspec>, ["~> 1.3"])
|
58
65
|
end
|
59
66
|
else
|
60
|
-
s.add_dependency(%q<dm-core>, ["~> 0.
|
61
|
-
s.add_dependency(%q<dm-adjust>, ["~> 0.
|
62
|
-
s.add_dependency(%q<
|
63
|
-
s.add_dependency(%q<
|
67
|
+
s.add_dependency(%q<dm-core>, ["~> 1.0.0.rc2"])
|
68
|
+
s.add_dependency(%q<dm-adjust>, ["~> 1.0.0.rc2"])
|
69
|
+
s.add_dependency(%q<dm-transactions>, ["~> 1.0.0.rc2"])
|
70
|
+
s.add_dependency(%q<rspec>, ["~> 1.3"])
|
64
71
|
end
|
65
72
|
end
|
66
73
|
|
@@ -203,7 +203,7 @@ module DataMapper
|
|
203
203
|
return false
|
204
204
|
end
|
205
205
|
|
206
|
-
|
206
|
+
transaction do
|
207
207
|
|
208
208
|
##
|
209
209
|
# if this node is already positioned we need to move it, and close the gap it leaves behind etc
|
@@ -218,8 +218,12 @@ module DataMapper
|
|
218
218
|
# make a gap at position, that is as wide as this node
|
219
219
|
model.base_model.adjust_gap!(nested_set, position - 1, gap)
|
220
220
|
|
221
|
+
eager_props = model.properties.values_at(:lft, :rgt)
|
222
|
+
|
223
|
+
# FIXME don't use @api private
|
221
224
|
# offset this node (and all its descendants) to the right position
|
222
|
-
eager_load(
|
225
|
+
eager_load(eager_props)
|
226
|
+
|
223
227
|
old_position = lft
|
224
228
|
offset = position - old_position
|
225
229
|
|
@@ -227,7 +231,10 @@ module DataMapper
|
|
227
231
|
|
228
232
|
# close the gap this movement left behind.
|
229
233
|
model.base_model.adjust_gap!(nested_set, old_position, -gap)
|
230
|
-
|
234
|
+
|
235
|
+
# FIXME don't use @api private
|
236
|
+
eager_load(eager_props)
|
237
|
+
|
231
238
|
else
|
232
239
|
# make a gap where the new node can be inserted
|
233
240
|
model.base_model.adjust_gap!(nested_set, position - 1, 2)
|
data/lib/dm-is-nested_set.rb
CHANGED
@@ -1,79 +1,79 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
has n, :categories
|
39
|
-
end
|
3
|
+
# id | lft| rgt| title
|
4
|
+
#========================================
|
5
|
+
# 1 | 1 | 20 | - Electronics
|
6
|
+
# 2 | 2 | 9 | - Televisions
|
7
|
+
# 3 | 3 | 4 | - Tube
|
8
|
+
# 4 | 5 | 6 | - LCD
|
9
|
+
# 5 | 7 | 8 | - Plasma
|
10
|
+
# 6 | 10 | 19 | - Portable Electronics
|
11
|
+
# 7 | 11 | 14 | - MP3 Players
|
12
|
+
# 8 | 12 | 13 | - Flash
|
13
|
+
# 9 | 15 | 16 | - CD Players
|
14
|
+
# 10 | 17 | 18 | - 2 Way Radios
|
15
|
+
|
16
|
+
# | | | | | | | | | | | | | | | | | | | |
|
17
|
+
# 1 2 3 4 5 6 7 8 9 10 11 12 Flash 13 14 15 16 17 18 19 20
|
18
|
+
# | | | Tube | | LCD | | Plasma | | | | |___________| | | CD Players | | 2 Way Radios | | |
|
19
|
+
# | | |______| |_____| |________| | | | | |____________| |______________| | |
|
20
|
+
# | | | | | MP3 Players | | |
|
21
|
+
# | | Televisions | | |_________________| Portable Electronics | |
|
22
|
+
# | |_________________________________| |_________________________________________________________| |
|
23
|
+
# | |
|
24
|
+
# | Electronics |
|
25
|
+
# |____________________________________________________________________________________________________|
|
26
|
+
|
27
|
+
describe DataMapper::Is::NestedSet do
|
28
|
+
before do
|
29
|
+
Object.send(:remove_const, :User) if defined?(User)
|
30
|
+
class ::User
|
31
|
+
include DataMapper::Resource
|
32
|
+
|
33
|
+
property :id, Serial
|
34
|
+
property :name, String
|
35
|
+
|
36
|
+
has n, :categories
|
37
|
+
end
|
40
38
|
|
41
|
-
|
42
|
-
|
43
|
-
|
39
|
+
Object.send(:remove_const, :Category) if defined?(Category)
|
40
|
+
class ::Category
|
41
|
+
include DataMapper::Resource
|
44
42
|
|
45
|
-
|
46
|
-
|
47
|
-
|
43
|
+
property :id, Serial
|
44
|
+
property :name, String
|
45
|
+
property :class_name, Discriminator
|
48
46
|
|
49
|
-
|
47
|
+
belongs_to :user
|
50
48
|
|
51
|
-
|
49
|
+
is :nested_set, :scope => [:user_id]
|
52
50
|
|
53
|
-
|
54
|
-
|
51
|
+
def pos; [lft,rgt] end # convenience method only for speccing.
|
52
|
+
end
|
55
53
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
end
|
54
|
+
Object.send(:remove_const, :CustomCategory) if defined?(CustomCategory)
|
55
|
+
class ::CustomCategory < Category; end
|
56
|
+
|
57
|
+
DataMapper.auto_migrate!
|
58
|
+
|
59
|
+
DataMapper.repository do
|
60
|
+
@user = User.create(:name => 'paul')
|
61
|
+
@other = User.create(:name => 'john')
|
62
|
+
|
63
|
+
electronics = @user.categories.create( :name => 'Electronics')
|
64
|
+
televisions = @user.categories.create(:parent => electronics, :name => 'Televisions')
|
65
|
+
tube = @user.categories.create(:parent => televisions, :name => 'Tube')
|
66
|
+
lcd = @user.categories.create(:parent => televisions, :name => 'LCD')
|
67
|
+
plasma = @user.categories.create(:parent => televisions, :name => 'Plasma')
|
68
|
+
portable_electronics = @user.categories.create(:parent => electronics, :name => 'Portable Electronics')
|
69
|
+
mp3_players = @user.categories.create(:parent => portable_electronics, :name => 'MP3 Players')
|
70
|
+
flash = @user.categories.create(:parent => mp3_players, :name => 'Flash')
|
71
|
+
cd_players = @user.categories.create(:parent => portable_electronics, :name => 'CD Players')
|
72
|
+
two_way_radios = @user.categories.create(:parent => portable_electronics, :name => '2 Way Radios')
|
76
73
|
end
|
74
|
+
end
|
75
|
+
|
76
|
+
supported_by :sqlite, :mysql, :postgres do
|
77
77
|
|
78
78
|
describe 'Class#rebuild_tree_from_set' do
|
79
79
|
it 'should reset all parent_ids correctly' do
|
@@ -311,5 +311,7 @@ if HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES
|
|
311
311
|
end
|
312
312
|
end
|
313
313
|
end
|
314
|
+
|
314
315
|
end
|
316
|
+
|
315
317
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,35 +1,9 @@
|
|
1
|
-
require '
|
2
|
-
|
3
|
-
# use local dm-core if running from a typical dev checkout.
|
4
|
-
lib = File.join('..', '..', 'dm-core', 'lib')
|
5
|
-
$LOAD_PATH.unshift(lib) if File.directory?(lib)
|
6
|
-
require 'dm-core'
|
7
|
-
|
8
|
-
# use local dm-adjust if running from a typical dev checkout.
|
9
|
-
lib = File.join('..', 'dm-adjust', 'lib')
|
10
|
-
$LOAD_PATH.unshift(lib) if File.directory?(lib)
|
11
|
-
require 'dm-adjust'
|
12
|
-
|
13
|
-
# Support running specs with 'rake spec' and 'spec'
|
14
|
-
$LOAD_PATH.unshift('lib') unless $LOAD_PATH.include?('lib')
|
1
|
+
require 'dm-core/spec/setup'
|
2
|
+
require 'dm-core/spec/lib/adapter_helpers'
|
15
3
|
|
16
4
|
require 'dm-is-nested_set'
|
5
|
+
require 'dm-migrations'
|
17
6
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
begin
|
22
|
-
DataMapper.setup(name, ENV["#{name.to_s.upcase}_SPEC_URI"] || default_uri)
|
23
|
-
DataMapper::Repository.adapters[:default] = DataMapper::Repository.adapters[name]
|
24
|
-
true
|
25
|
-
rescue LoadError => e
|
26
|
-
warn "Could not load do_#{name}: #{e}"
|
27
|
-
false
|
28
|
-
end
|
7
|
+
Spec::Runner.configure do |config|
|
8
|
+
config.extend(DataMapper::Spec::Adapters::Helpers)
|
29
9
|
end
|
30
|
-
|
31
|
-
ENV['ADAPTER'] ||= 'sqlite3'
|
32
|
-
|
33
|
-
HAS_SQLITE3 = load_driver(:sqlite3, 'sqlite3::memory:')
|
34
|
-
HAS_MYSQL = load_driver(:mysql, 'mysql://localhost/dm_core_test')
|
35
|
-
HAS_POSTGRES = load_driver(:postgres, 'postgres://postgres@localhost/dm_core_test')
|
@@ -0,0 +1,18 @@
|
|
1
|
+
desc "Support bundling from local source code (allows BUNDLE_GEMFILE=Gemfile.local bundle foo)"
|
2
|
+
task :local_gemfile do |t|
|
3
|
+
|
4
|
+
root = Pathname(__FILE__).dirname.parent
|
5
|
+
datamapper = root.parent
|
6
|
+
|
7
|
+
source_regex = /DATAMAPPER = 'git:\/\/github.com\/datamapper'/
|
8
|
+
gem_source_regex = /:git => \"#\{DATAMAPPER\}\/(.+?)(?:\.git)?\"/
|
9
|
+
|
10
|
+
root.join('Gemfile.local').open('w') do |f|
|
11
|
+
root.join('Gemfile').open.each do |line|
|
12
|
+
line.sub!(source_regex, "DATAMAPPER = '#{datamapper}'")
|
13
|
+
line.sub!(gem_source_regex, ':path => "#{DATAMAPPER}/\1"')
|
14
|
+
f.puts line
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
data/tasks/spec.rake
CHANGED
metadata
CHANGED
@@ -1,7 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dm-is-nested_set
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 977940575
|
5
|
+
prerelease: true
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
- rc2
|
11
|
+
version: 1.0.0.rc2
|
5
12
|
platform: ruby
|
6
13
|
authors:
|
7
14
|
- Sindre Aarsaether
|
@@ -9,49 +16,75 @@ autorequire:
|
|
9
16
|
bindir: bin
|
10
17
|
cert_chain: []
|
11
18
|
|
12
|
-
date:
|
19
|
+
date: 2010-05-19 00:00:00 -07:00
|
13
20
|
default_executable:
|
14
21
|
dependencies:
|
15
22
|
- !ruby/object:Gem::Dependency
|
16
23
|
name: dm-core
|
17
|
-
|
18
|
-
|
19
|
-
|
24
|
+
prerelease: false
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
20
27
|
requirements:
|
21
28
|
- - ~>
|
22
29
|
- !ruby/object:Gem::Version
|
23
|
-
|
24
|
-
|
30
|
+
hash: 977940575
|
31
|
+
segments:
|
32
|
+
- 1
|
33
|
+
- 0
|
34
|
+
- 0
|
35
|
+
- rc2
|
36
|
+
version: 1.0.0.rc2
|
37
|
+
type: :runtime
|
38
|
+
version_requirements: *id001
|
25
39
|
- !ruby/object:Gem::Dependency
|
26
40
|
name: dm-adjust
|
27
|
-
|
28
|
-
|
29
|
-
|
41
|
+
prerelease: false
|
42
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
30
44
|
requirements:
|
31
45
|
- - ~>
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
|
34
|
-
|
47
|
+
hash: 977940575
|
48
|
+
segments:
|
49
|
+
- 1
|
50
|
+
- 0
|
51
|
+
- 0
|
52
|
+
- rc2
|
53
|
+
version: 1.0.0.rc2
|
54
|
+
type: :runtime
|
55
|
+
version_requirements: *id002
|
35
56
|
- !ruby/object:Gem::Dependency
|
36
|
-
name:
|
37
|
-
|
38
|
-
|
39
|
-
|
57
|
+
name: dm-transactions
|
58
|
+
prerelease: false
|
59
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
40
61
|
requirements:
|
41
62
|
- - ~>
|
42
63
|
- !ruby/object:Gem::Version
|
43
|
-
|
44
|
-
|
64
|
+
hash: 977940575
|
65
|
+
segments:
|
66
|
+
- 1
|
67
|
+
- 0
|
68
|
+
- 0
|
69
|
+
- rc2
|
70
|
+
version: 1.0.0.rc2
|
71
|
+
type: :runtime
|
72
|
+
version_requirements: *id003
|
45
73
|
- !ruby/object:Gem::Dependency
|
46
|
-
name:
|
47
|
-
|
48
|
-
|
49
|
-
|
74
|
+
name: rspec
|
75
|
+
prerelease: false
|
76
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
50
78
|
requirements:
|
51
79
|
- - ~>
|
52
80
|
- !ruby/object:Gem::Version
|
53
|
-
|
54
|
-
|
81
|
+
hash: 9
|
82
|
+
segments:
|
83
|
+
- 1
|
84
|
+
- 3
|
85
|
+
version: "1.3"
|
86
|
+
type: :development
|
87
|
+
version_requirements: *id004
|
55
88
|
description: DataMapper plugin allowing the creation of nested sets from data models
|
56
89
|
email: sindre [a] identu [d] no
|
57
90
|
executables: []
|
@@ -62,6 +95,8 @@ extra_rdoc_files:
|
|
62
95
|
- LICENSE
|
63
96
|
- README.rdoc
|
64
97
|
files:
|
98
|
+
- .gitignore
|
99
|
+
- Gemfile
|
65
100
|
- LICENSE
|
66
101
|
- README.rdoc
|
67
102
|
- Rakefile
|
@@ -74,6 +109,7 @@ files:
|
|
74
109
|
- spec/spec.opts
|
75
110
|
- spec/spec_helper.rb
|
76
111
|
- tasks/ci.rake
|
112
|
+
- tasks/local_gemfile.rake
|
77
113
|
- tasks/metrics.rake
|
78
114
|
- tasks/spec.rake
|
79
115
|
- tasks/yard.rake
|
@@ -88,23 +124,32 @@ rdoc_options:
|
|
88
124
|
require_paths:
|
89
125
|
- lib
|
90
126
|
required_ruby_version: !ruby/object:Gem::Requirement
|
127
|
+
none: false
|
91
128
|
requirements:
|
92
129
|
- - ">="
|
93
130
|
- !ruby/object:Gem::Version
|
131
|
+
hash: 3
|
132
|
+
segments:
|
133
|
+
- 0
|
94
134
|
version: "0"
|
95
|
-
version:
|
96
135
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
|
+
none: false
|
97
137
|
requirements:
|
98
|
-
- - "
|
138
|
+
- - ">"
|
99
139
|
- !ruby/object:Gem::Version
|
100
|
-
|
101
|
-
|
140
|
+
hash: 25
|
141
|
+
segments:
|
142
|
+
- 1
|
143
|
+
- 3
|
144
|
+
- 1
|
145
|
+
version: 1.3.1
|
102
146
|
requirements: []
|
103
147
|
|
104
148
|
rubyforge_project: datamapper
|
105
|
-
rubygems_version: 1.3.
|
149
|
+
rubygems_version: 1.3.7
|
106
150
|
signing_key:
|
107
151
|
specification_version: 3
|
108
152
|
summary: DataMapper plugin allowing the creation of nested sets from data models
|
109
|
-
test_files:
|
110
|
-
|
153
|
+
test_files:
|
154
|
+
- spec/integration/nested_set_spec.rb
|
155
|
+
- spec/spec_helper.rb
|