nbrew-better_nested_set 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,15 @@
1
+ mysql:
2
+ :adapter: mysql
3
+ :host: localhost
4
+ :username: rails
5
+ :password:
6
+ :database: acts_as_nested_set_plugin_test
7
+ postgresql:
8
+ :adapter: postgresql
9
+ :host: localhost
10
+ :username: rails
11
+ :password:
12
+ :database: acts_as_nested_set_plugin_test
13
+ sqlite3:
14
+ :adapter: sqlite3
15
+ :dbfile: test/acts_as_nested_set_plugin_test.db
@@ -0,0 +1,33 @@
1
+ class Mixin < ActiveRecord::Base
2
+ belongs_to :parent_node, :class_name => 'Mixin', :foreign_key => 'parent_id'
3
+ end
4
+
5
+ class NestedSet < Mixin
6
+ acts_as_nested_set :scope => "mixins.root_id IS NULL"
7
+ end
8
+
9
+ class NestedSetWithStringScope < Mixin
10
+ acts_as_nested_set :scope => 'mixins.root_id = #{root_id}'
11
+ end
12
+
13
+ class NS1 < NestedSetWithStringScope
14
+ end
15
+
16
+ class NS2 < NS1
17
+ my_callbacks = [:before_create, :before_save, :before_update, :before_destroy,
18
+ :after_create, :after_save, :after_update, :after_destroy]
19
+ my_callbacks.each do |sym|
20
+ define_method(sym) do
21
+ $callbacks ||= []
22
+ $callbacks << sym
23
+ end
24
+ end
25
+ end
26
+
27
+ class NestedSetWithSymbolScope < Mixin
28
+ acts_as_nested_set :scope => :root
29
+ end
30
+
31
+ class Category < Mixin
32
+ acts_as_nested_set
33
+ end
@@ -0,0 +1,66 @@
1
+ # Nested set mixins
2
+
3
+ <% (1..10).each do |counter| %>
4
+ set_<%= counter %>:
5
+ id: <%= counter+3000 %>
6
+ type: NestedSet
7
+ <% end %>
8
+
9
+ # Big old set
10
+ <%
11
+ [[4001, 0, 1, 20],
12
+ [4002, 4001, 2, 7],
13
+ [4003, 4002, 3, 4],
14
+ [4004, 4002, 5, 6],
15
+ [4005, 4001, 8, 13],
16
+ [4006, 4005, 9, 10],
17
+ [4007, 4005, 11, 12],
18
+ [4008, 4001, 14, 19],
19
+ [4009, 4008, 15, 16],
20
+ [4010, 4008, 17, 18]].each do |set| %>
21
+ tree_<%= set[0] %>:
22
+ id: <%= set[0]%>
23
+ parent_id: <%= set[1]%>
24
+ type: NestedSetWithStringScope
25
+ lft: <%= set[2]%>
26
+ rgt: <%= set[3]%>
27
+ root_id: 42
28
+
29
+ <% end %>
30
+
31
+
32
+ # Third group of nested set fixtures.
33
+ # the following schematic may help when working with this nested set:
34
+ # ____________________________________________________________________________________________________________
35
+ # | root_node |
36
+ # | _____________ _______________________________________ _________________________________________ |
37
+ # | | child_left | | child_middle | | child_right | |
38
+ # | | | | _________ _________ _________ | | _________ ___________________ | |
39
+ # | | | | | gc_1 | | gc_2 | | gc_3 | | | | gc_4 | | gc_5 | | |
40
+ # | | | | | | | | | | | | | | | ___________ | | |
41
+ # | | | | | | | | | | | | | | | | gg_child | | | |
42
+ # 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16________17 18 19 20
43
+ # | | | | |________| |________| |________| | | |________| |__________________| | |
44
+ # | |____________| |_______________________________________| |_______________________________________| |
45
+ # |___________________________________________________________________________________________________________|
46
+ <%
47
+ [ ["root_node", 101, 1, 1, 20, 0, "NS1"],
48
+ ["child_left", 102, 1, 2, 3, 101, "NestedSetWithStringScope"],
49
+ ["child_middle", 103, 3, 4, 11, 101, "NS2"],
50
+ ["child_right", 104, 5, 12, 19, 101, "NestedSetWithStringScope"],
51
+ ["gc_1", 105, 3, 5, 6, 103, "NestedSetWithStringScope"],
52
+ ["gc_2", 106, 3, 7, 8, 103, "NestedSetWithStringScope"],
53
+ ["gc_3", 107, 3, 9, 10, 103, "NestedSetWithStringScope"],
54
+ ["gc_4", 108, 6, 13, 14, 104, "NS2"],
55
+ ["gc_5", 109, 7, 15, 18, 104, "NS1"],
56
+ ["gg_child", 110, 9, 16, 17, 109, "NestedSetWithStringScope"]].each do |set| %>
57
+ ns_<%= set[0] %>:
58
+ id: <%= set[1]%>
59
+ parent_id: <%= set[5]%>
60
+ pos: <%= set[2]%>
61
+ lft: <%= set[3]%>
62
+ rgt: <%= set[4]%>
63
+ root_id: 101
64
+ type: <%= set[6]%>
65
+
66
+ <% end %>
@@ -0,0 +1,2 @@
1
+ ENV['DB'] = 'mysql'
2
+ require File.dirname(__FILE__) + '/acts_as_nested_set_test'
@@ -0,0 +1,2 @@
1
+ ENV['DB'] = 'postgresql'
2
+ require File.dirname(__FILE__) + '/acts_as_nested_set_test'
@@ -0,0 +1,12 @@
1
+ ActiveRecord::Schema.define :version => 0 do
2
+ create_table :mixins, :force => true do |t|
3
+ t.column :parent_id, :integer
4
+ t.column :pos, :integer
5
+ t.column :created_at, :datetime
6
+ t.column :updated_at, :datetime
7
+ t.column :lft, :integer
8
+ t.column :rgt, :integer
9
+ t.column :root_id, :integer
10
+ t.column :type, :string
11
+ end
12
+ end
@@ -0,0 +1,2 @@
1
+ ENV['DB'] = 'sqlite3'
2
+ require File.dirname(__FILE__) + '/acts_as_nested_set_test'
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nbrew-better_nested_set
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - "Jean-Christophe Michel, Sym\xC3\xA9trie, Chris Bailey"
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-02-17 00:00:00 -08:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: "An enhanced acts_as_nested_set mixin for ActiveRecord. A Gemified version of the betternestedset svn repo at svn://rubyforge.org/var/svn/betternestedset/trunk "
23
+ email: nhyde@bigdrift.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files:
29
+ - README
30
+ - test/RUNNING_UNIT_TESTS
31
+ files:
32
+ - README
33
+ - Rakefile.rb
34
+ - lib/better_nested_set.rb
35
+ - lib/better_nested_set_helper.rb
36
+ - rails/init.rb
37
+ - test/abstract_unit.rb
38
+ - test/acts_as_nested_set_test.rb
39
+ - test/database.yml
40
+ - test/fixtures/mixin.rb
41
+ - test/fixtures/mixins.yml
42
+ - test/mysql.rb
43
+ - test/postgresql.rb
44
+ - test/RUNNING_UNIT_TESTS
45
+ - test/schema.rb
46
+ - test/sqlite3.rb
47
+ has_rdoc: true
48
+ homepage: http://github.com/nbrew/better_nested_set
49
+ licenses: []
50
+
51
+ post_install_message:
52
+ rdoc_options:
53
+ - --charset=UTF-8
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ hash: 3
62
+ segments:
63
+ - 0
64
+ version: "0"
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ hash: 3
71
+ segments:
72
+ - 0
73
+ version: "0"
74
+ requirements: []
75
+
76
+ rubyforge_project:
77
+ rubygems_version: 1.3.7
78
+ signing_key:
79
+ specification_version: 3
80
+ summary: ""
81
+ test_files:
82
+ - test/abstract_unit.rb
83
+ - test/acts_as_nested_set_test.rb
84
+ - test/database.yml
85
+ - test/fixtures/mixin.rb
86
+ - test/fixtures/mixins.yml
87
+ - test/mysql.rb
88
+ - test/postgresql.rb
89
+ - test/schema.rb
90
+ - test/sqlite3.rb