nested_set 1.5.2 → 1.5.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,8 +1,8 @@
1
1
  = NestedSet
2
2
 
3
- Nested Set is an implementation of the nested set pattern for ActiveRecord models. It is replacement for acts_as_nested_set and BetterNestedSet, but awesomer. It supports Rails 3.0.rc and later.
3
+ Nested Set is an implementation of the nested set pattern for ActiveRecord models. It is replacement for acts_as_nested_set and BetterNestedSet, but awesomer. It supports Rails 3.0 and later.
4
4
 
5
- See, it's Rails 3 only.
5
+ === See, it's Rails 3 only.
6
6
 
7
7
  == Installation
8
8
 
@@ -41,7 +41,7 @@ Enable the nested set functionality by declaring acts_as_nested_set on your mode
41
41
  class Category < ActiveRecord::Base
42
42
  acts_as_nested_set
43
43
  end
44
-
44
+
45
45
  Run `rake rdoc` to generate the API docs and see CollectiveIdea::Acts::NestedSet::Base::SingletonMethods for more info.
46
46
 
47
47
  == Conversion from other trees
@@ -78,13 +78,13 @@ You can learn more about nested sets at:
78
78
  If you find what you might think is a bug:
79
79
 
80
80
  1. Check the GitHub issue tracker to see if anyone else has had the same issue.
81
- http://github.com/collectiveidea/awesome_nested_set/issues/
81
+ http://github.com/skyeagle/nested_set/issues/
82
82
  2. If you don't see anything, create an issue with information on how to reproduce it.
83
83
 
84
84
  If you want to contribute an enhancement or a fix:
85
85
 
86
86
  1. Fork the project on github.
87
- http://github.com/collectiveidea/awesome_nested_set/
87
+ http://github.com/skyeagle/nested_set/
88
88
  2. Make your changes with tests.
89
89
  3. Commit the changes without making changes to the Rakefile, VERSION, or any other files that aren't related to your enhancement or fix
90
90
  4. Send a pull request.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.5.2
1
+ 1.5.3
@@ -26,9 +26,16 @@ module CollectiveIdea #:nodoc:
26
26
  items = Array(class_or_item)
27
27
  result = []
28
28
  items.each do |root|
29
+ levels = []
29
30
  result += root.self_and_descendants.map do |i|
31
+ if level = levels.index(i.parent_id)
32
+ levels.slice!((level + 1)..-1)
33
+ else
34
+ levels << i.parent_id
35
+ level = levels.size - 1
36
+ end
30
37
  if mover.nil? || mover.new_record? || mover.move_possible?(i)
31
- [yield(i), i.id]
38
+ [yield(i, level), i.id]
32
39
  end
33
40
  end.compact
34
41
  end
data/nested_set.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{nested_set}
8
- s.version = "1.5.2"
8
+ s.version = "1.5.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Brandon Keepers", "Daniel Morrison"]
12
- s.date = %q{2010-10-01}
12
+ s.date = %q{2010-11-10}
13
13
  s.description = %q{An awesome nested set implementation for Active Record}
14
14
  s.email = %q{info@collectiveidea.com}
15
15
  s.extra_rdoc_files = [
@@ -49,11 +49,11 @@ Gem::Specification.new do |s|
49
49
  s.rubygems_version = %q{1.3.7}
50
50
  s.summary = %q{An awesome nested set implementation for Active Record}
51
51
  s.test_files = [
52
- "test/nested_set/helper_test.rb",
53
- "test/nested_set_test.rb",
54
- "test/db/schema.rb",
52
+ "test/nested_set_test.rb",
53
+ "test/nested_set/helper_test.rb",
54
+ "test/test_helper.rb",
55
55
  "test/fixtures/category.rb",
56
- "test/test_helper.rb"
56
+ "test/db/schema.rb"
57
57
  ]
58
58
 
59
59
  if s.respond_to? :specification_version then
@@ -16,8 +16,8 @@ module CollectiveIdea
16
16
  ['- Child 3', 5],
17
17
  [" Top Level 2", 6]
18
18
  ]
19
- actual = nested_set_options(Category) do |c|
20
- "#{'-' * c.level} #{c.name}"
19
+ actual = nested_set_options(Category) do |c, level|
20
+ "#{'-' * level} #{c.name}"
21
21
  end
22
22
  assert_equal expected, actual
23
23
  end
@@ -29,8 +29,8 @@ module CollectiveIdea
29
29
  ['- Child 3', 5],
30
30
  [" Top Level 2", 6]
31
31
  ]
32
- actual = nested_set_options(Category, categories(:child_2)) do |c|
33
- "#{'-' * c.level} #{c.name}"
32
+ actual = nested_set_options(Category, categories(:child_2)) do |c, level|
33
+ "#{'-' * level} #{c.name}"
34
34
  end
35
35
  assert_equal expected, actual
36
36
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 5
8
- - 2
9
- version: 1.5.2
8
+ - 3
9
+ version: 1.5.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Brandon Keepers
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-01 00:00:00 +04:00
18
+ date: 2010-11-10 00:00:00 +03:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -172,8 +172,8 @@ signing_key:
172
172
  specification_version: 3
173
173
  summary: An awesome nested set implementation for Active Record
174
174
  test_files:
175
- - test/nested_set/helper_test.rb
176
175
  - test/nested_set_test.rb
177
- - test/db/schema.rb
178
- - test/fixtures/category.rb
176
+ - test/nested_set/helper_test.rb
179
177
  - test/test_helper.rb
178
+ - test/fixtures/category.rb
179
+ - test/db/schema.rb