acts_as_dag 2.0.3 → 2.0.4
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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/acts_as_dag.rb +0 -1
- data/lib/acts_as_dag/acts_as_dag.rb +1 -1
- data/lib/acts_as_dag/deprecated.rb +5 -0
- data/lib/acts_as_dag/version.rb +1 -1
- data/spec/acts_as_dag_spec.rb +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9811f8fe46b37783ba3668be42a552611127175
|
4
|
+
data.tar.gz: 408ebd1239ac16da5d7d298e9e18d9a9e93fcfb1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9b67b40f5f0cac839662b2adeb4cd405e3d88de5bf59829ce72c8d994b08b91f8a87973055472bade3604d83c3bb7a8bef9f7996d43d960b4a7cfa2ae14f76a
|
7
|
+
data.tar.gz: 994578a50819239073d05589a3de5d28c77e5cd3c5aa02ed3eec4cc05b371722be2a361d1b59743144cd44ffcd53f8e728332acd130d35e81c6f727b3801207a
|
data/README.md
CHANGED
@@ -82,7 +82,7 @@ subtree_ids Returns a list of all ids in the record's subtree
|
|
82
82
|
|
83
83
|
```
|
84
84
|
roots Nodes without parents
|
85
|
-
|
85
|
+
leaves Nodes without children
|
86
86
|
ancestors_of(node) Ancestors of node, node can be either a record or an id
|
87
87
|
children_of(node) Children of node, node can be either a record or an id
|
88
88
|
descendants_of(node) Descendants of node, node can be either a record or an id
|
data/lib/acts_as_dag.rb
CHANGED
@@ -83,7 +83,7 @@ module ActsAsDAG
|
|
83
83
|
|
84
84
|
# NOTE: Use select to prevent ActiveRecord::ReadOnlyRecord if the returned records are modified
|
85
85
|
scope :roots, lambda { joins(:parent_links).where(link_class.table_name => {:parent_id => nil}) }
|
86
|
-
scope :
|
86
|
+
scope :leaves, lambda { joins("LEFT OUTER JOIN #{link_class.table_name} ON #{table_name}.id = parent_id").where(link_class.table_name => {:child_id => nil}).uniq }
|
87
87
|
scope :children, lambda { joins(:parent_links).where.not(link_class.table_name => {:parent_id => nil}).uniq }
|
88
88
|
scope :parent_records, lambda { joins(:child_links).where.not(link_class.table_name => {:child_id => nil}).uniq }
|
89
89
|
|
@@ -2,6 +2,11 @@ module ActsAsDAG
|
|
2
2
|
module Deprecated
|
3
3
|
|
4
4
|
module ClassMethods
|
5
|
+
# Deprecated misspelled method name
|
6
|
+
def leafs
|
7
|
+
leaves
|
8
|
+
end
|
9
|
+
|
5
10
|
# Reorganizes the entire class of records based on their name, first resetting the hierarchy, then reoganizing
|
6
11
|
# Can pass a list of categories and only those will be reorganized
|
7
12
|
def reorganize(categories_to_reorganize = self.all)
|
data/lib/acts_as_dag/version.rb
CHANGED
data/spec/acts_as_dag_spec.rb
CHANGED
@@ -737,20 +737,20 @@ describe 'acts_as_dag' do
|
|
737
737
|
end
|
738
738
|
end
|
739
739
|
|
740
|
-
describe '::
|
740
|
+
describe '::leaves' do
|
741
741
|
it "returns all leaf nodes" do
|
742
742
|
mom.add_child(suzy)
|
743
|
-
expect(klass.
|
743
|
+
expect(klass.leaves).to include(suzy)
|
744
744
|
end
|
745
745
|
|
746
746
|
it "doesn't return non-leaf nodes" do
|
747
747
|
mom.add_child(suzy)
|
748
|
-
expect(klass.
|
748
|
+
expect(klass.leaves).not_to include(mom)
|
749
749
|
end
|
750
750
|
|
751
751
|
it "doesn't mark returned records as readonly" do
|
752
752
|
mom.add_child(suzy)
|
753
|
-
expect(klass.
|
753
|
+
expect(klass.leaves.none?(&:readonly?)).to be_truthy
|
754
754
|
end
|
755
755
|
end
|
756
756
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_dag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicholas Jakobsen
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-06-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|