nested_set 1.5.0 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +8 -12
- data/Rakefile +3 -3
- data/VERSION +1 -1
- data/lib/nested_set/railtie.rb +1 -1
- data/nested_set.gemspec +72 -0
- data/test/{awesome_nested_set → nested_set}/helper_test.rb +4 -4
- data/test/{awesome_nested_set_test.rb → nested_set_test.rb} +1 -1
- data/test/test_helper.rb +1 -1
- metadata +8 -7
data/README.rdoc
CHANGED
@@ -1,26 +1,22 @@
|
|
1
|
-
=
|
1
|
+
= NestedSet
|
2
2
|
|
3
|
-
|
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.
|
4
4
|
|
5
5
|
See, it's Rails 3 only.
|
6
6
|
|
7
|
-
== What makes this so awesome?
|
8
|
-
|
9
|
-
This is a new implementation of nested set based off of BetterNestedSet that fixes some bugs, removes tons of duplication, adds a few useful methods, and adds STI support.
|
10
|
-
|
11
7
|
== Installation
|
12
8
|
|
13
9
|
The plugin is available as a gem:
|
14
10
|
|
15
|
-
gem '
|
11
|
+
gem 'nested_set'
|
16
12
|
|
17
13
|
Or install as a plugin:
|
18
14
|
|
19
|
-
rails plugin install git://github.com/
|
15
|
+
rails plugin install git://github.com/skyeagle/nested_set.git
|
20
16
|
|
21
17
|
== Usage
|
22
18
|
|
23
|
-
To make use of
|
19
|
+
To make use of nested_set, your model needs to have 3 fields: lft, rgt, and parent_id:
|
24
20
|
|
25
21
|
class CreateCategories < ActiveRecord::Migration
|
26
22
|
def self.up
|
@@ -29,7 +25,7 @@ To make use of awesome_nested_set, your model needs to have 3 fields: lft, rgt,
|
|
29
25
|
t.integer :parent_id
|
30
26
|
t.integer :lft
|
31
27
|
t.integer :rgt
|
32
|
-
|
28
|
+
|
33
29
|
# Uncomment it to store item level
|
34
30
|
# t.integer :depth
|
35
31
|
end
|
@@ -53,8 +49,8 @@ Run `rake rdoc` to generate the API docs and see CollectiveIdea::Acts::NestedSet
|
|
53
49
|
Coming from acts_as_tree or another system where you only have a parent_id? No problem. Simply add the lft & rgt fields as above, and then run
|
54
50
|
|
55
51
|
Category.rebuild!
|
56
|
-
|
57
|
-
Your tree be converted to a valid nested set.
|
52
|
+
|
53
|
+
Your tree be converted to a valid nested set.
|
58
54
|
|
59
55
|
== View Helper
|
60
56
|
|
data/Rakefile
CHANGED
@@ -9,7 +9,7 @@ begin
|
|
9
9
|
gem.summary = "An awesome nested set implementation for Active Record"
|
10
10
|
gem.description = gem.summary
|
11
11
|
gem.email = "info@collectiveidea.com"
|
12
|
-
gem.homepage = "http://github.com/
|
12
|
+
gem.homepage = "http://github.com/skyeagle/nested_set"
|
13
13
|
gem.authors = ["Brandon Keepers", "Daniel Morrison"]
|
14
14
|
gem.add_dependency "activerecord", ['>= 3.0.0.rc']
|
15
15
|
end
|
@@ -21,7 +21,7 @@ end
|
|
21
21
|
require 'rake/testtask'
|
22
22
|
Rake::TestTask.new(:test) do |test|
|
23
23
|
test.libs << 'lib' << 'test'
|
24
|
-
test.pattern = 'test
|
24
|
+
test.pattern = 'test/**/*_test.rb'
|
25
25
|
test.verbose = true
|
26
26
|
end
|
27
27
|
|
@@ -29,7 +29,7 @@ begin
|
|
29
29
|
require 'rcov/rcovtask'
|
30
30
|
Rcov::RcovTask.new do |test|
|
31
31
|
test.libs << 'test'
|
32
|
-
test.pattern = 'test
|
32
|
+
test.pattern = 'test/**/*_test.rb'
|
33
33
|
test.verbose = true
|
34
34
|
end
|
35
35
|
rescue LoadError
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.5.
|
1
|
+
1.5.1
|
data/lib/nested_set/railtie.rb
CHANGED
data/nested_set.gemspec
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{nested_set}
|
8
|
+
s.version = "1.5.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Brandon Keepers", "Daniel Morrison"]
|
12
|
+
s.date = %q{2010-09-07}
|
13
|
+
s.description = %q{An awesome nested set implementation for Active Record}
|
14
|
+
s.email = %q{info@collectiveidea.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README.rdoc"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
".autotest",
|
20
|
+
".gitignore",
|
21
|
+
"MIT-LICENSE",
|
22
|
+
"README.rdoc",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION",
|
25
|
+
"init.rb",
|
26
|
+
"lib/nested_set.rb",
|
27
|
+
"lib/nested_set/base.rb",
|
28
|
+
"lib/nested_set/depth.rb",
|
29
|
+
"lib/nested_set/descendants.rb",
|
30
|
+
"lib/nested_set/helper.rb",
|
31
|
+
"lib/nested_set/railtie.rb",
|
32
|
+
"nested_set.gemspec",
|
33
|
+
"rails/init.rb",
|
34
|
+
"test/application.rb",
|
35
|
+
"test/db/database.yml",
|
36
|
+
"test/db/schema.rb",
|
37
|
+
"test/fixtures/categories.yml",
|
38
|
+
"test/fixtures/category.rb",
|
39
|
+
"test/fixtures/departments.yml",
|
40
|
+
"test/fixtures/notes.yml",
|
41
|
+
"test/nested_set/helper_test.rb",
|
42
|
+
"test/nested_set_test.rb",
|
43
|
+
"test/test_helper.rb"
|
44
|
+
]
|
45
|
+
s.homepage = %q{http://github.com/skyeagle/nested_set}
|
46
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
47
|
+
s.require_paths = ["lib"]
|
48
|
+
s.rubygems_version = %q{1.3.7}
|
49
|
+
s.summary = %q{An awesome nested set implementation for Active Record}
|
50
|
+
s.test_files = [
|
51
|
+
"test/db/schema.rb",
|
52
|
+
"test/nested_set_test.rb",
|
53
|
+
"test/application.rb",
|
54
|
+
"test/nested_set/helper_test.rb",
|
55
|
+
"test/fixtures/category.rb",
|
56
|
+
"test/test_helper.rb"
|
57
|
+
]
|
58
|
+
|
59
|
+
if s.respond_to? :specification_version then
|
60
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
61
|
+
s.specification_version = 3
|
62
|
+
|
63
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
64
|
+
s.add_runtime_dependency(%q<activerecord>, [">= 3.0.0.rc"])
|
65
|
+
else
|
66
|
+
s.add_dependency(%q<activerecord>, [">= 3.0.0.rc"])
|
67
|
+
end
|
68
|
+
else
|
69
|
+
s.add_dependency(%q<activerecord>, [">= 3.0.0.rc"])
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
@@ -3,10 +3,10 @@ require 'test_helper'
|
|
3
3
|
module CollectiveIdea
|
4
4
|
module Acts #:nodoc:
|
5
5
|
module NestedSet #:nodoc:
|
6
|
-
class
|
6
|
+
class NestedSetTest < ActiveSupport::TestCase
|
7
7
|
include Helper
|
8
8
|
fixtures :categories
|
9
|
-
|
9
|
+
|
10
10
|
def test_nested_set_options
|
11
11
|
expected = [
|
12
12
|
[" Top Level", 1],
|
@@ -21,7 +21,7 @@ module CollectiveIdea
|
|
21
21
|
end
|
22
22
|
assert_equal expected, actual
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
def test_nested_set_options_with_mover
|
26
26
|
expected = [
|
27
27
|
[" Top Level", 1],
|
@@ -34,7 +34,7 @@ module CollectiveIdea
|
|
34
34
|
end
|
35
35
|
assert_equal expected, actual
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
@@ -18,7 +18,7 @@ class RenamedColumns < ActiveRecord::Base
|
|
18
18
|
acts_as_nested_set :parent_column => 'mother_id', :left_column => 'red', :right_column => 'black'
|
19
19
|
end
|
20
20
|
|
21
|
-
class
|
21
|
+
class NestedSetTest < ActiveSupport::TestCase
|
22
22
|
|
23
23
|
def test_left_column_default
|
24
24
|
assert_equal 'lft', Default.acts_as_nested_set_options[:left_column]
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 5
|
8
|
-
-
|
9
|
-
version: 1.5.
|
8
|
+
- 1
|
9
|
+
version: 1.5.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Brandon Keepers
|
@@ -56,19 +56,20 @@ files:
|
|
56
56
|
- lib/nested_set/descendants.rb
|
57
57
|
- lib/nested_set/helper.rb
|
58
58
|
- lib/nested_set/railtie.rb
|
59
|
+
- nested_set.gemspec
|
59
60
|
- rails/init.rb
|
60
61
|
- test/application.rb
|
61
|
-
- test/awesome_nested_set/helper_test.rb
|
62
|
-
- test/awesome_nested_set_test.rb
|
63
62
|
- test/db/database.yml
|
64
63
|
- test/db/schema.rb
|
65
64
|
- test/fixtures/categories.yml
|
66
65
|
- test/fixtures/category.rb
|
67
66
|
- test/fixtures/departments.yml
|
68
67
|
- test/fixtures/notes.yml
|
68
|
+
- test/nested_set/helper_test.rb
|
69
|
+
- test/nested_set_test.rb
|
69
70
|
- test/test_helper.rb
|
70
71
|
has_rdoc: true
|
71
|
-
homepage: http://github.com/
|
72
|
+
homepage: http://github.com/skyeagle/nested_set
|
72
73
|
licenses: []
|
73
74
|
|
74
75
|
post_install_message:
|
@@ -101,8 +102,8 @@ specification_version: 3
|
|
101
102
|
summary: An awesome nested set implementation for Active Record
|
102
103
|
test_files:
|
103
104
|
- test/db/schema.rb
|
105
|
+
- test/nested_set_test.rb
|
104
106
|
- test/application.rb
|
107
|
+
- test/nested_set/helper_test.rb
|
105
108
|
- test/fixtures/category.rb
|
106
|
-
- test/awesome_nested_set/helper_test.rb
|
107
|
-
- test/awesome_nested_set_test.rb
|
108
109
|
- test/test_helper.rb
|