acts_as_dag 1.2.4 → 1.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +23 -0
- data/lib/acts_as_dag/acts_as_dag.rb +4 -4
- data/spec/acts_as_dag_spec.rb +7 -7
- 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: 20958e9a99961c9a9e024c2a38d0ca18f2d4edf9
|
4
|
+
data.tar.gz: 47fa5205930fda7ef2d272060c1fd762ed5ac5eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee43e1f45b2e1a342d68af770fd77dacdababb279e1cf304ecc77c4273c523ba20084faf6a36b682933b337db6dafcd856f792cf28f7188d42223e149bbd9679
|
7
|
+
data.tar.gz: 674b7382f83397b73749a83487454302ccc1a1b9c086141c7fc63d5efd58d1dd53fd46ac4c81510a127c6c8e03c473c788d0101e01f62e0b4ecde334b614334e
|
data/README.rdoc
CHANGED
@@ -3,3 +3,26 @@
|
|
3
3
|
Adds Directed Acyclic Graph functionality to ActiveRecord
|
4
4
|
|
5
5
|
Used by RRN data mapper to setup link and descendant database tables
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
### Migration
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
class CreateActsAsDagTables < ActiveRecord::Migration
|
13
|
+
def change
|
14
|
+
create_table "acts_as_dag_descendants", :force => true do |t|
|
15
|
+
t.string :category_type
|
16
|
+
t.references :ancestor
|
17
|
+
t.references :descendant
|
18
|
+
t.integer :distance
|
19
|
+
end
|
20
|
+
|
21
|
+
create_table "acts_as_dag_links", :force => true do |t|
|
22
|
+
t.string :category_type
|
23
|
+
t.references :parent
|
24
|
+
t.references :child
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
```
|
@@ -56,11 +56,11 @@ module ActsAsDAG
|
|
56
56
|
# \ /
|
57
57
|
# D
|
58
58
|
#
|
59
|
-
has_many :ancestors,
|
60
|
-
has_many :descendants,
|
59
|
+
has_many :ancestors, :through => :ancestor_links, :source => :ancestor
|
60
|
+
has_many :descendants, :through => :descendant_links, :source => :descendant
|
61
61
|
|
62
|
-
has_many :ancestor_links, lambda { where
|
63
|
-
has_many :descendant_links, lambda { where
|
62
|
+
has_many :ancestor_links, lambda { where(options[:link_conditions]).order("distance DESC") }, :class_name => descendant_class, :foreign_key => 'descendant_id', :dependent => :delete_all
|
63
|
+
has_many :descendant_links, lambda { where(options[:link_conditions]).order("distance ASC") }, :class_name => descendant_class, :foreign_key => 'ancestor_id', :dependent => :delete_all
|
64
64
|
|
65
65
|
has_many :parents, :through => :parent_links, :source => :parent
|
66
66
|
has_many :children, :through => :child_links, :source => :child
|
data/spec/acts_as_dag_spec.rb
CHANGED
@@ -86,15 +86,15 @@ describe 'acts_as_dag' do
|
|
86
86
|
@dad.add_child(@child)
|
87
87
|
@grandpa.add_child(@dad)
|
88
88
|
|
89
|
-
@grandpa.ancestor_of?(@child).should
|
90
|
-
@child.descendant_of?(@grandpa).should
|
91
|
-
@child.ancestor_of?(@grandpa).should
|
92
|
-
@grandpa.descendant_of?(@child).should
|
89
|
+
@grandpa.ancestor_of?(@child).should be_truthy
|
90
|
+
@child.descendant_of?(@grandpa).should be_truthy
|
91
|
+
@child.ancestor_of?(@grandpa).should be_falsy
|
92
|
+
@grandpa.descendant_of?(@child).should be_falsy
|
93
93
|
end
|
94
94
|
|
95
95
|
it "should be a root node immediately after saving" do
|
96
96
|
@grandpa.parents.should be_empty
|
97
|
-
@grandpa.root?.should
|
97
|
+
@grandpa.root?.should be_truthy
|
98
98
|
end
|
99
99
|
|
100
100
|
it "should be a child if it has a parent" do
|
@@ -153,8 +153,8 @@ describe 'acts_as_dag' do
|
|
153
153
|
end
|
154
154
|
|
155
155
|
it "should be able to determine whether one category is an ancestor of the other by inspecting the name" do
|
156
|
-
ActsAsDAG::HelperMethods.should_descend_from?(@totem_pole, @big_totem_pole).should
|
157
|
-
ActsAsDAG::HelperMethods.should_descend_from?(@big_totem_pole, @totem_pole).should
|
156
|
+
ActsAsDAG::HelperMethods.should_descend_from?(@totem_pole, @big_totem_pole).should be_truthy
|
157
|
+
ActsAsDAG::HelperMethods.should_descend_from?(@big_totem_pole, @totem_pole).should be_falsy
|
158
158
|
end
|
159
159
|
|
160
160
|
it "should be able to determine the number of matching words in two categories names" do
|
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: 1.2.
|
4
|
+
version: 1.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicholas Jakobsen
|
@@ -56,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
56
56
|
version: '0'
|
57
57
|
requirements: []
|
58
58
|
rubyforge_project:
|
59
|
-
rubygems_version: 2.
|
59
|
+
rubygems_version: 2.4.6
|
60
60
|
signing_key:
|
61
61
|
specification_version: 4
|
62
62
|
summary: Adds directed acyclic graph functionality to ActiveRecord.
|