dm-is-tree 0.9.11 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- data/{History.txt → History.rdoc} +4 -0
- data/Manifest.txt +2 -2
- data/{README.txt → README.rdoc} +0 -0
- data/Rakefile +2 -3
- data/lib/dm-is-tree.rb +1 -7
- data/lib/dm-is-tree/is/tree.rb +9 -3
- data/lib/dm-is-tree/is/version.rb +1 -1
- data/spec/integration/tree_spec.rb +2 -2
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +8 -4
- data/spec/unit/tree_spec.rb +20 -11
- data/tasks/install.rb +1 -1
- data/tasks/spec.rb +4 -4
- metadata +14 -21
data/Manifest.txt
CHANGED
data/{README.txt → README.rdoc}
RENAMED
File without changes
|
data/Rakefile
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'pathname'
|
2
|
-
require 'rubygems'
|
3
2
|
|
4
3
|
ROOT = Pathname(__FILE__).dirname.expand_path
|
5
4
|
JRUBY = RUBY_PLATFORM =~ /java/
|
@@ -14,10 +13,10 @@ GEM_NAME = 'dm-is-tree'
|
|
14
13
|
GEM_VERSION = DataMapper::Is::Tree::VERSION
|
15
14
|
GEM_DEPENDENCIES = [['dm-core', GEM_VERSION]]
|
16
15
|
GEM_CLEAN = %w[ log pkg coverage ]
|
17
|
-
GEM_EXTRAS = { :has_rdoc => true, :extra_rdoc_files => %w[ README.
|
16
|
+
GEM_EXTRAS = { :has_rdoc => true, :extra_rdoc_files => %w[ README.rdoc LICENSE TODO History.rdoc ] }
|
18
17
|
|
19
18
|
PROJECT_NAME = 'datamapper'
|
20
|
-
PROJECT_URL = "http://github.com/
|
19
|
+
PROJECT_URL = "http://github.com/datamapper/dm-more/tree/master/#{GEM_NAME}"
|
21
20
|
PROJECT_DESCRIPTION = PROJECT_SUMMARY = 'DataMapper plugin allowing the creation of tree structures from data models'
|
22
21
|
|
23
22
|
[ ROOT, ROOT.parent ].each do |dir|
|
data/lib/dm-is-tree.rb
CHANGED
data/lib/dm-is-tree/is/tree.rb
CHANGED
@@ -59,13 +59,19 @@ module DataMapper
|
|
59
59
|
#
|
60
60
|
# * <tt>child_key</tt> - specifies the column name to use for tracking of the tree (default: +parent_id+)
|
61
61
|
def is_tree(options = {})
|
62
|
-
|
62
|
+
|
63
|
+
if options[:class_name]
|
64
|
+
warn '+options[:class_name]+ is deprecated, use :model instead'
|
65
|
+
options[:model] = options.delete(:class_name)
|
66
|
+
end
|
67
|
+
|
68
|
+
options = { :model => name, :child_key => :parent_id }.merge(options) if Hash === options
|
63
69
|
@tree_options = options
|
64
70
|
|
65
71
|
include DataMapper::Is::Tree::InstanceMethods
|
66
72
|
extend DataMapper::Is::Tree::ClassMethods
|
67
73
|
|
68
|
-
assc_options = { :
|
74
|
+
assc_options = { :model => options[:model], :child_key => Array(options[:child_key]) }
|
69
75
|
has_n_options = options[:order] ? { :order => Array(options[:order]) }.merge(assc_options) : assc_options
|
70
76
|
|
71
77
|
belongs_to :parent, assc_options
|
@@ -123,7 +129,7 @@ module DataMapper
|
|
123
129
|
#
|
124
130
|
# grandchild1.siblings # => [grandchild2]
|
125
131
|
def siblings
|
126
|
-
generation
|
132
|
+
generation.reject{|r| r.key == self.key }
|
127
133
|
end
|
128
134
|
|
129
135
|
# Returns all children of the current node’s parent.
|
data/spec/spec.opts
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,10 +1,14 @@
|
|
1
|
-
require 'pathname'
|
2
1
|
require 'rubygems'
|
3
2
|
|
4
|
-
|
5
|
-
|
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'
|
6
7
|
|
7
|
-
|
8
|
+
# Support running specs with 'rake spec' and 'spec'
|
9
|
+
$LOAD_PATH.unshift('lib') unless $LOAD_PATH.include?('lib')
|
10
|
+
|
11
|
+
require 'dm-is-tree'
|
8
12
|
|
9
13
|
def load_driver(name, default_uri)
|
10
14
|
return false if ENV['ADAPTER'] != name.to_s
|
data/spec/unit/tree_spec.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe DataMapper::Is::Tree do
|
4
4
|
|
5
5
|
before do
|
6
|
-
class Category
|
6
|
+
class ::Category
|
7
7
|
include DataMapper::Resource
|
8
8
|
|
9
9
|
property :id, Serial
|
@@ -59,22 +59,26 @@ describe DataMapper::Is::Tree do
|
|
59
59
|
|
60
60
|
describe "parent relationship" do
|
61
61
|
|
62
|
-
it "should set the
|
62
|
+
it "should set the model from the current class" do
|
63
|
+
# Internals of relationships has changed
|
63
64
|
Category.is :tree
|
64
|
-
Category.relationships[:parent].
|
65
|
+
Category.relationships[:parent].child_model.should == Category
|
65
66
|
end
|
66
67
|
|
67
68
|
it "should use the default child_key of :parent_id if none is supplied in the options" do
|
69
|
+
# Internals of relationships has changed
|
68
70
|
Category.is :tree
|
69
|
-
Category.relationships[:parent].options[:child_key].should ==
|
71
|
+
Category.relationships[:parent].options[:child_key].should == [ :parent_id ]
|
70
72
|
end
|
71
73
|
|
72
74
|
it "should use the child_key from the options if it is supplied" do
|
75
|
+
# Internals of relationships has changed
|
73
76
|
Category.is :tree, :child_key => :other_id
|
74
|
-
Category.relationships[:parent].options[:child_key].should ==
|
77
|
+
Category.relationships[:parent].options[:child_key].should == [ :other_id ]
|
75
78
|
end
|
76
79
|
|
77
80
|
it "should not set any order" do
|
81
|
+
# Internals of relationships has changed
|
78
82
|
Category.is :tree, :order => :name
|
79
83
|
Category.relationships[:parent].options.should_not have_key(:order)
|
80
84
|
end
|
@@ -83,29 +87,34 @@ describe DataMapper::Is::Tree do
|
|
83
87
|
|
84
88
|
describe "children relationship" do
|
85
89
|
|
86
|
-
it "should set the
|
90
|
+
it "should set the model from the current class" do
|
91
|
+
# Internals of relationships has changed
|
87
92
|
Category.is :tree
|
88
|
-
Category.relationships[:children].
|
93
|
+
Category.relationships[:children].child_model.should == Category
|
89
94
|
end
|
90
95
|
|
91
96
|
it "should use the default child_key of :parent_id if none is supplied in the options" do
|
97
|
+
# Internals of relationships has changed
|
92
98
|
Category.is :tree
|
93
|
-
Category.relationships[:children].options[:child_key].should ==
|
99
|
+
Category.relationships[:children].options[:child_key].should == [ :parent_id ]
|
94
100
|
end
|
95
101
|
|
96
102
|
it "should use the child_key from the options if it is supplied" do
|
103
|
+
# Internals of relationships has changed
|
97
104
|
Category.is :tree, :child_key => :other_id
|
98
|
-
Category.relationships[:children].options[:child_key].should ==
|
105
|
+
Category.relationships[:children].options[:child_key].should == [ :other_id ]
|
99
106
|
end
|
100
107
|
|
101
108
|
it "should not set any order if none is supplied in the options" do
|
109
|
+
# Internals of relationships has changed
|
102
110
|
Category.is :tree
|
103
111
|
Category.relationships[:children].options.should_not have_key(:order)
|
104
112
|
end
|
105
113
|
|
106
114
|
it "should use the order from the options if it is supplied" do
|
115
|
+
# Internals of relationships has changed
|
107
116
|
Category.is :tree, :order => :name
|
108
|
-
Category.relationships[:children].options[:order].should ==
|
117
|
+
Category.relationships[:children].options[:order].should == [ :name ]
|
109
118
|
end
|
110
119
|
|
111
120
|
end
|
data/tasks/install.rb
CHANGED
@@ -4,7 +4,7 @@ end
|
|
4
4
|
|
5
5
|
desc "Install #{GEM_NAME} #{GEM_VERSION}"
|
6
6
|
task :install => [ :package ] do
|
7
|
-
sudo_gem "install
|
7
|
+
sudo_gem "install pkg/#{GEM_NAME}-#{GEM_VERSION} --no-update-sources"
|
8
8
|
end
|
9
9
|
|
10
10
|
desc "Uninstall #{GEM_NAME} #{GEM_VERSION}"
|
data/tasks/spec.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
begin
|
2
|
-
gem 'rspec', '~>1.2'
|
3
|
-
require 'spec'
|
4
2
|
require 'spec/rake/spectask'
|
5
3
|
|
6
4
|
task :default => [ :spec ]
|
@@ -8,16 +6,18 @@ begin
|
|
8
6
|
desc 'Run specifications'
|
9
7
|
Spec::Rake::SpecTask.new(:spec) do |t|
|
10
8
|
t.spec_opts << '--options' << 'spec/spec.opts' if File.exists?('spec/spec.opts')
|
11
|
-
t.
|
9
|
+
t.libs << 'lib' << 'spec' # needed for CI rake spec task, duplicated in spec_helper
|
12
10
|
|
13
11
|
begin
|
14
|
-
|
12
|
+
require 'rcov'
|
15
13
|
t.rcov = JRUBY ? false : (ENV.has_key?('NO_RCOV') ? ENV['NO_RCOV'] != 'true' : true)
|
16
14
|
t.rcov_opts << '--exclude' << 'spec'
|
17
15
|
t.rcov_opts << '--text-summary'
|
18
16
|
t.rcov_opts << '--sort' << 'coverage' << '--sort-reverse'
|
19
17
|
rescue LoadError
|
20
18
|
# rcov not installed
|
19
|
+
rescue SyntaxError
|
20
|
+
# rcov syntax invalid
|
21
21
|
end
|
22
22
|
end
|
23
23
|
rescue LoadError
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dm-is-tree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Timothy Bennett
|
@@ -9,19 +9,10 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-09-16 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
16
|
-
name: dm-core
|
17
|
-
type: :runtime
|
18
|
-
version_requirement:
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
20
|
-
requirements:
|
21
|
-
- - "="
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.9.11
|
24
|
-
version:
|
14
|
+
dependencies: []
|
15
|
+
|
25
16
|
description: DataMapper plugin allowing the creation of tree structures from data models
|
26
17
|
email:
|
27
18
|
- leapord729 [a] comcast.net
|
@@ -30,15 +21,15 @@ executables: []
|
|
30
21
|
extensions: []
|
31
22
|
|
32
23
|
extra_rdoc_files:
|
33
|
-
- README.
|
24
|
+
- README.rdoc
|
34
25
|
- LICENSE
|
35
26
|
- TODO
|
36
|
-
- History.
|
27
|
+
- History.rdoc
|
37
28
|
files:
|
38
|
-
- History.
|
29
|
+
- History.rdoc
|
39
30
|
- LICENSE
|
40
31
|
- Manifest.txt
|
41
|
-
- README.
|
32
|
+
- README.rdoc
|
42
33
|
- Rakefile
|
43
34
|
- TODO
|
44
35
|
- lib/dm-is-tree.rb
|
@@ -51,11 +42,13 @@ files:
|
|
51
42
|
- tasks/install.rb
|
52
43
|
- tasks/spec.rb
|
53
44
|
has_rdoc: true
|
54
|
-
homepage: http://github.com/
|
45
|
+
homepage: http://github.com/datamapper/dm-more/tree/master/dm-is-tree
|
46
|
+
licenses: []
|
47
|
+
|
55
48
|
post_install_message:
|
56
49
|
rdoc_options:
|
57
50
|
- --main
|
58
|
-
- README.
|
51
|
+
- README.rdoc
|
59
52
|
require_paths:
|
60
53
|
- lib
|
61
54
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -73,9 +66,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
66
|
requirements: []
|
74
67
|
|
75
68
|
rubyforge_project: datamapper
|
76
|
-
rubygems_version: 1.3.
|
69
|
+
rubygems_version: 1.3.5
|
77
70
|
signing_key:
|
78
|
-
specification_version:
|
71
|
+
specification_version: 3
|
79
72
|
summary: DataMapper plugin allowing the creation of tree structures from data models
|
80
73
|
test_files: []
|
81
74
|
|