1
1
# Closure Tree
2
2
3
- __ Important: please [ vote on the future of ClosureTree] ( https://github.com/mceachen /closure_tree/issues/277 ) !__
3
+ __ Important: please [ vote on the future of ClosureTree] ( https://github.com/ClosureTree /closure_tree/issues/277 ) !__
4
4
5
5
### Closure_tree lets your ActiveRecord models act as nodes in a [ tree data structure] ( http://en.wikipedia.org/wiki/Tree_%28data_structure%29 )
6
6
7
7
Common applications include modeling hierarchical data, like tags, threaded comments, page graphs in CMSes,
8
8
and tracking user referrals.
9
9
10
10
[ ![ Join the chat at https://gitter.im/closure_tree/Lobby ] ( https://badges.gitter.im/closure_tree/Lobby.svg )] ( https://gitter.im/closure_tree/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge )
11
- [ ![ Build Status] ( https://api.travis-ci.org/mceachen /closure_tree.svg?branch=master )] ( http://travis-ci.org/mceachen /closure_tree )
11
+ [ ![ Build Status] ( https://api.travis-ci.org/ClosureTree /closure_tree.svg?branch=master )] ( http://travis-ci.org/ClosureTree /closure_tree )
12
12
[ ![ Gem Version] ( https://badge.fury.io/rb/closure_tree.svg )] ( https://badge.fury.io/rb/closure_tree )
13
- [ ![ Codacy Badge] ( https://api.codacy.com/project/badge/Grade/fa5a8ae2193d42adb30b4256732a757d )] ( https://www.codacy.com/app/matthew-github/closure_tree )
14
- [ ![ Dependency Status] ( https://gemnasium.com/badges/github.com/mceachen/closure_tree.svg )] ( https://gemnasium.com/github.com/mceachen/closure_tree )
13
+ [ ![ Dependency Status] ( https://gemnasium.com/badges/github.com/ClosureTree/closure_tree.svg )] ( https://gemnasium.com/github.com/ClosureTree/closure_tree )
15
14
16
15
Dramatically more performant than
17
16
[ ancestry] ( https://github.com/stefankroes/ancestry ) and
@@ -28,7 +27,7 @@ closure_tree has some great features:
28
27
* __ Best-in-class mutation performance__ :
29
28
* 2 SQL INSERTs on node creation
30
29
* 3 SQL INSERT/UPDATEs on node reparenting
31
- * __ Support for [ concurrency] ( #concurrency ) __ (using [ with_advisory_lock] ( https://github.com/mceachen /with_advisory_lock ) )
30
+ * __ Support for [ concurrency] ( #concurrency ) __ (using [ with_advisory_lock] ( https://github.com/ClosureTree /with_advisory_lock ) )
32
31
* __ Tested against ActiveRecord 4.2, 5.0, and 5.1, with Ruby 2.2 and 2.3__
33
32
* Support for reparenting children (and all their descendants)
34
33
* Support for [ single-table inheritance (STI)] ( #sti ) within the hierarchy
@@ -255,7 +254,7 @@ b.hash_tree(:limit_depth => 2)
255
254
Without this option, ```hash_tree``` will load the entire contents of that table into RAM. Your
256
255
server may not be happy trying to do this.
257
256
258
- HT: [ancestry](https://github.com/stefankroes/ancestry#arrangement) and [elhoyos](https://github.com/mceachen /closure_tree/issues/11)
257
+ HT: [ancestry](https://github.com/stefankroes/ancestry#arrangement) and [elhoyos](https://github.com/ClosureTree /closure_tree/issues/11)
259
258
260
259
### Eager loading
261
260
@@ -306,13 +305,13 @@ File.open("example.dot", "w") { |f| f.write(Tag.root.to_dot_digraph) }
306
305
` ` `
307
306
Then , in a shell, ` ` ` dot -Tpng example.dot > example.png` ` ` , which produces:
308
307
309
- ! [Example tree](https: // raw.github.com/ mceachen / closure_tree/ master/ img/ example.png)
308
+ ! [Example tree](https: // raw.github.com/ ClosureTree / closure_tree/ master/ img/ example.png)
310
309
311
310
If you want to customize the label value, override the ` ` ` #to_digraph_label` ` ` instance method in your model.
312
311
313
312
Just for kicks, this is the test tree I used for proving that preordered tree traversal was correct:
314
313
315
- ! [Preordered test tree](https: // raw.github.com/ mceachen / closure_tree/ master/ img/ preorder.png)
314
+ ! [Preordered test tree](https: // raw.github.com/ ClosureTree / closure_tree/ master/ img/ preorder.png)
316
315
317
316
# ## Available options
318
317
@@ -485,7 +484,7 @@ Several methods, especially ```#rebuild``` and ```#find_or_create_by_path```, ca
485
484
486
485
Database row- level locks work correctly with PostgreSQL , but MySQL ' s row-level locking is broken, and
487
486
erroneously reports deadlocks where there are none. To work around this, and have a consistent implementation
488
- for both MySQL and PostgreSQL, [with_advisory_lock](https://github.com/mceachen /with_advisory_lock)
487
+ for both MySQL and PostgreSQL, [with_advisory_lock](https://github.com/ClosureTree /with_advisory_lock)
489
488
is used automatically to ensure correctness.
490
489
491
490
If you are already managing concurrency elsewhere in your application, and want to disable the use
@@ -518,7 +517,7 @@ Yup! [Ilya Bodrov](https://github.com/bodrovis) wrote [Nested Comments with Rail
518
517
519
518
# ## Does this work well with ```#default_scope```?
520
519
521
- ** No .** Please see [issue 86 ](https: // github.com/ mceachen / closure_tree/ issues/ 86 ) for details.
520
+ ** No .** Please see [issue 86 ](https: // github.com/ ClosureTree / closure_tree/ issues/ 86 ) for details.
522
521
523
522
# ## Can I update parentage with `update_attribute`?
524
523
@@ -527,7 +526,7 @@ hierarchy table.
527
526
528
527
# ## Can I assign a parent to multiple children with ```#update_all```?
529
528
530
- ** No .** Please see [issue 197 ](https: // github.com/ mceachen / closure_tree/ issues/ 197 ) for details.
529
+ ** No .** Please see [issue 197 ](https: // github.com/ ClosureTree / closure_tree/ issues/ 197 ) for details.
531
530
532
531
# ## Does this gem support multiple parents?
533
532
@@ -586,11 +585,11 @@ bundle install
586
585
587
586
### Object destroy fails with MySQL v5.7+
588
587
589
- A bug was introduced in MySQL's query optimizer. [See the workaround here](https://github.com/mceachen /closure_tree/issues/206).
588
+ A bug was introduced in MySQL's query optimizer. [See the workaround here](https://github.com/ClosureTree /closure_tree/issues/206).
590
589
591
590
### Hierarchy maintenance errors from MySQL v5.7.9-v5.7.10
592
591
593
- Upgrade to MySQL 5.7.12 or later if you see [this issue](https://github.com/mceachen /closure_tree/issues/190):
592
+ Upgrade to MySQL 5.7.12 or later if you see [this issue](https://github.com/ClosureTree /closure_tree/issues/190):
594
593
595
594
Mysql2::Error: You can't specify target table '*_hierarchies' for update in FROM clause
596
595
627
626
628
627
## Testing
629
628
630
- Closure tree is [ tested under every valid combination] ( http://travis-ci.org/#!/mceachen /closure_tree ) of
629
+ Closure tree is [ tested under every valid combination] ( http://travis-ci.org/#!/ClosureTree /closure_tree ) of
631
630
632
631
* Ruby 2.2, 2.3
633
632
* ActiveRecord 4.2, 5.0, and 5.1
@@ -638,12 +637,12 @@ run the test matrix locally.
638
637
639
638
## Change log
640
639
641
- See the [ change log] ( https://github.com/mceachen /closure_tree/blob/master/CHANGELOG.md ) .
640
+ See the [ change log] ( https://github.com/ClosureTree /closure_tree/blob/master/CHANGELOG.md ) .
642
641
643
642
## Thanks to
644
643
645
644
* The 45+ engineers around the world that have contributed their time and code to this gem
646
- (see the [ changelog] ( https://github.com/mceachen /closure_tree/blob/master/CHANGELOG.md ) !)
645
+ (see the [ changelog] ( https://github.com/ClosureTree /closure_tree/blob/master/CHANGELOG.md ) !)
647
646
* https://github.com/collectiveidea/awesome_nested_set
648
647
* https://github.com/patshaughnessy/class_factory
649
648
* JetBrains, which provides an [ open-source license] ( http://www.jetbrains.com/ruby/buy/buy.jsp#openSource ) to
0 commit comments