closure_tree 3.0.3 → 3.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,6 +1,4 @@
1
- # Closure Tree
2
-
3
- [![Build Status](https://secure.travis-ci.org/mceachen/closure_tree.png?branch=master)](http://travis-ci.org/mceachen/closure_tree)
1
+ # Closure Tree [![Build Status](https://secure.travis-ci.org/mceachen/closure_tree.png?branch=master)](http://travis-ci.org/mceachen/closure_tree)
4
2
 
5
3
  Closure Tree is a mostly-API-compatible replacement for the
6
4
  acts_as_tree and awesome_nested_set gems, but with much better
@@ -183,32 +181,37 @@ class WhatTag < Tag ; end
183
181
 
184
182
  ## Change log
185
183
 
186
- ### 2.0.0
184
+ ### 3.0.4
187
185
 
188
- * Had to increment the major version, as rebuild! will need to be called by prior consumers to support the new ```leaves``` class and instance methods.
189
- * Tag deletion is supported now along with ```:dependent => :destroy``` and ```:dependent => :delete_all```
190
- * Switched from default rails plugin directory structure to rspec
191
- * Support for running specs under different database engines: ```export DB ; for DB in sqlite3 mysql postgresql ; do rake ; done```
186
+ * Merged [pull request](https://github.com/mceachen/closure_tree/pull/8) to fix ```.siblings``` and ```.self_and_siblings```
187
+ (Thanks, [eljojo](https://github.com/eljojo)!)
192
188
 
193
- ### 3.0.0
189
+ ### 3.0.3
194
190
 
195
- * Support for polymorphic trees
196
- * ```find_by_path``` and ```find_or_create_by_path``` signatures changed to support constructor attributes
197
- * tested against Rails 3.1.3
191
+ * Added support for ActiveRecord's whitelist_attributes
192
+ (Make sure you read [the Rails Security Guide](http://guides.rubyonrails.org/security.html), and
193
+ enable ```config.active_record.whitelist_attributes``` in your ```config/application.rb``` ASAP!)
194
+
195
+ ### 3.0.2
196
+
197
+ * Fix for ancestry-loop detection (performed by a validation, not through raising an exception in before_save)
198
198
 
199
199
  ### 3.0.1
200
200
 
201
201
  * Support 3.2.0's fickle deprecation of InstanceMethods (Thanks, [jheiss](https://github.com/mceachen/closure_tree/pull/5))!
202
202
 
203
- ### 3.0.2
203
+ ### 3.0.0
204
204
 
205
- * Fix for ancestry-loop detection (performed by a validation, not through raising an exception in before_save)
205
+ * Support for polymorphic trees
206
+ * ```find_by_path``` and ```find_or_create_by_path``` signatures changed to support constructor attributes
207
+ * tested against Rails 3.1.3
206
208
 
207
- ### 3.0.3
209
+ ### 2.0.0
208
210
 
209
- * Added support for ActiveRecord's whitelist_attributes
210
- (Make sure you read [the Rails Security Guide](http://guides.rubyonrails.org/security.html), and
211
- enable ```config.active_record.whitelist_attributes``` in your ```config/application.rb``` ASAP!)
211
+ * Had to increment the major version, as rebuild! will need to be called by prior consumers to support the new ```leaves``` class and instance methods.
212
+ * Tag deletion is supported now along with ```:dependent => :destroy``` and ```:dependent => :delete_all```
213
+ * Switched from default rails plugin directory structure to rspec
214
+ * Support for running specs under different database engines: ```export DB ; for DB in sqlite3 mysql postgresql ; do rake ; done```
212
215
 
213
216
  ## Thanks to
214
217
 
@@ -120,7 +120,7 @@ module ClosureTree
120
120
  end
121
121
 
122
122
  def self_and_siblings
123
- self.class.scoped.where(:parent => parent)
123
+ self.class.scoped.where(:parent_id => parent)
124
124
  end
125
125
 
126
126
  def siblings
@@ -1,3 +1,3 @@
1
1
  module ClosureTree
2
- VERSION = "3.0.3" unless defined?(::ClosureTree::VERSION)
2
+ VERSION = "3.0.4" unless defined?(::ClosureTree::VERSION)
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -18,8 +18,9 @@ ActiveRecord::Base.logger = Logger.new(plugin_test_dir + "/debug.log")
18
18
 
19
19
  require 'yaml'
20
20
  require 'erb'
21
+ ENV["DB"] ||= "sqlite3mem"
21
22
  ActiveRecord::Base.configurations = YAML::load(ERB.new(IO.read(plugin_test_dir + "/db/database.yml")).result)
22
- ActiveRecord::Base.establish_connection(ENV["DB"] || "mysql")
23
+ ActiveRecord::Base.establish_connection(ENV["DB"])
23
24
  ActiveRecord::Migration.verbose = false
24
25
  load(File.join(plugin_test_dir, "db", "schema.rb"))
25
26
 
data/spec/tag_spec.rb CHANGED
@@ -184,7 +184,7 @@ shared_examples_for Tag do
184
184
  tags(:d2).ancestry_path.should == %w{a1 b2 c2 d2}
185
185
  tags(:b1).add_child(tags(:c2))
186
186
  tags(:b2).leaf?.should_not be_nil
187
- tags(:b1).children.include?(tags(:c2)).should_not be_nil
187
+ tags(:b1).children.include?(tags(:c2)).should be_true
188
188
  tags(:d2).reload.ancestry_path.should == %w{a1 b1 c2 d2}
189
189
  end
190
190
 
@@ -227,9 +227,15 @@ shared_examples_for Tag do
227
227
  end
228
228
 
229
229
  it "should have a sane children collection" do
230
- tags(:grandparent).children.include? tags(:parent).should_not be_nil
231
- tags(:parent).children.include? tags(:child).should_not be_nil
232
- tags(:child).children.empty?.should_not be_nil
230
+ tags(:grandparent).children.include? tags(:parent).should be_true
231
+ tags(:parent).children.include? tags(:child).should be_true
232
+ tags(:child).children.should be_empty
233
+ end
234
+
235
+ it "assembles siblings correctly" do
236
+ tags(:b1).siblings.to_a.should =~ [tags(:b2)]
237
+ tags(:a1).siblings.to_a.should =~ (Tag.roots.to_a - [tags(:a1)])
238
+ tags(:a1).self_and_siblings.to_a.should =~ Tag.roots.to_a
233
239
  end
234
240
 
235
241
  it "should assemble ancestors correctly" do
metadata CHANGED
@@ -1,160 +1,169 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: closure_tree
3
- version: !ruby/object:Gem::Version
4
- hash: 1
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.0.4
5
5
  prerelease:
6
- segments:
7
- - 3
8
- - 0
9
- - 3
10
- version: 3.0.3
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Matthew McEachen
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-03-11 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- prerelease: false
22
- requirement: &id001 !ruby/object:Gem::Requirement
23
- none: false
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- hash: 7
28
- segments:
29
- - 3
30
- - 0
31
- - 0
32
- version: 3.0.0
33
- version_requirements: *id001
12
+ date: 2012-06-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
34
15
  name: activerecord
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 3.0.0
35
22
  type: :runtime
36
- - !ruby/object:Gem::Dependency
37
23
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- hash: 3
44
- segments:
45
- - 0
46
- version: "0"
47
- version_requirements: *id002
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 3.0.0
30
+ - !ruby/object:Gem::Dependency
48
31
  name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
49
38
  type: :development
50
- - !ruby/object:Gem::Dependency
51
39
  prerelease: false
52
- requirement: &id003 !ruby/object:Gem::Requirement
53
- none: false
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- hash: 3
58
- segments:
59
- - 0
60
- version: "0"
61
- version_requirements: *id003
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
62
47
  name: yard
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
63
54
  type: :development
64
- - !ruby/object:Gem::Dependency
65
55
  prerelease: false
66
- requirement: &id004 !ruby/object:Gem::Requirement
67
- none: false
68
- requirements:
69
- - - ">="
70
- - !ruby/object:Gem::Version
71
- hash: 3
72
- segments:
73
- - 0
74
- version: "0"
75
- version_requirements: *id004
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
76
63
  name: rspec
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
77
70
  type: :development
78
- - !ruby/object:Gem::Dependency
79
71
  prerelease: false
80
- requirement: &id005 !ruby/object:Gem::Requirement
81
- none: false
82
- requirements:
83
- - - ">="
84
- - !ruby/object:Gem::Version
85
- hash: 3
86
- segments:
87
- - 0
88
- version: "0"
89
- version_requirements: *id005
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
90
79
  name: rails
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
91
86
  type: :development
92
- - !ruby/object:Gem::Dependency
93
87
  prerelease: false
94
- requirement: &id006 !ruby/object:Gem::Requirement
95
- none: false
96
- requirements:
97
- - - ">="
98
- - !ruby/object:Gem::Version
99
- hash: 3
100
- segments:
101
- - 0
102
- version: "0"
103
- version_requirements: *id006
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
104
95
  name: rspec-rails
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
105
102
  type: :development
106
- - !ruby/object:Gem::Dependency
107
103
  prerelease: false
108
- requirement: &id007 !ruby/object:Gem::Requirement
109
- none: false
110
- requirements:
111
- - - ">="
112
- - !ruby/object:Gem::Version
113
- hash: 3
114
- segments:
115
- - 0
116
- version: "0"
117
- version_requirements: *id007
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
118
111
  name: mysql2
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
119
118
  type: :development
120
- - !ruby/object:Gem::Dependency
121
119
  prerelease: false
122
- requirement: &id008 !ruby/object:Gem::Requirement
123
- none: false
124
- requirements:
125
- - - ">="
126
- - !ruby/object:Gem::Version
127
- hash: 3
128
- segments:
129
- - 0
130
- version: "0"
131
- version_requirements: *id008
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
132
127
  name: pg
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
133
134
  type: :development
134
- - !ruby/object:Gem::Dependency
135
135
  prerelease: false
136
- requirement: &id009 !ruby/object:Gem::Requirement
137
- none: false
138
- requirements:
139
- - - ">="
140
- - !ruby/object:Gem::Version
141
- hash: 3
142
- segments:
143
- - 0
144
- version: "0"
145
- version_requirements: *id009
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ - !ruby/object:Gem::Dependency
146
143
  name: sqlite3
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
147
150
  type: :development
148
- description: " A mostly-API-compatible replacement for the acts_as_tree and awesome_nested_set gems,\n but with much better mutation performance thanks to the Closure Tree storage algorithm\n"
149
- email:
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ description: ! " A mostly-API-compatible replacement for the acts_as_tree and awesome_nested_set
159
+ gems,\n but with much better mutation performance thanks to the Closure Tree
160
+ storage algorithm\n"
161
+ email:
150
162
  - matthew-github@mceachen.org
151
163
  executables: []
152
-
153
164
  extensions: []
154
-
155
165
  extra_rdoc_files: []
156
-
157
- files:
166
+ files:
158
167
  - lib/closure_tree/acts_as_tree.rb
159
168
  - lib/closure_tree/version.rb
160
169
  - lib/closure_tree.rb
@@ -171,38 +180,35 @@ files:
171
180
  - spec/user_spec.rb
172
181
  homepage: http://matthew.mceachen.us/closure_tree
173
182
  licenses: []
174
-
175
183
  post_install_message:
176
184
  rdoc_options: []
177
-
178
- require_paths:
185
+ require_paths:
179
186
  - lib
180
- required_ruby_version: !ruby/object:Gem::Requirement
187
+ required_ruby_version: !ruby/object:Gem::Requirement
181
188
  none: false
182
- requirements:
183
- - - ">="
184
- - !ruby/object:Gem::Version
185
- hash: 3
186
- segments:
189
+ requirements:
190
+ - - ! '>='
191
+ - !ruby/object:Gem::Version
192
+ version: '0'
193
+ segments:
187
194
  - 0
188
- version: "0"
189
- required_rubygems_version: !ruby/object:Gem::Requirement
195
+ hash: 1662601254141526016
196
+ required_rubygems_version: !ruby/object:Gem::Requirement
190
197
  none: false
191
- requirements:
192
- - - ">="
193
- - !ruby/object:Gem::Version
194
- hash: 3
195
- segments:
198
+ requirements:
199
+ - - ! '>='
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ segments:
196
203
  - 0
197
- version: "0"
204
+ hash: 1662601254141526016
198
205
  requirements: []
199
-
200
206
  rubyforge_project:
201
- rubygems_version: 1.8.17
207
+ rubygems_version: 1.8.21
202
208
  signing_key:
203
209
  specification_version: 3
204
210
  summary: Hierarchies for ActiveRecord models using a Closure Tree storage algorithm
205
- test_files:
211
+ test_files:
206
212
  - spec/db/database.yml
207
213
  - spec/db/schema.rb
208
214
  - spec/fixtures/tags.yml