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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8a7a921e4428cd9076f8185484e4ba74d1be9f39
4
- data.tar.gz: bb3b20517f05e2b7c0ab292e3339be5439ca67a4
3
+ metadata.gz: 20958e9a99961c9a9e024c2a38d0ca18f2d4edf9
4
+ data.tar.gz: 47fa5205930fda7ef2d272060c1fd762ed5ac5eb
5
5
  SHA512:
6
- metadata.gz: 60def06e6d20971d87279cfead7e62a71095065249f57f33ecdedd87d4c449c4eea3ee3281b396866e6f47cdf7b98f0e8b1f6c2f9abc2c6acd5115c869c34299
7
- data.tar.gz: 1207ee4bb868befd019226da0c3427e40f890a549153f6bdae623b119b54a6111e7c78df6b5b25070da9c2b647950ec77b70d5cca873756c3c98f923eb9aa31f
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, lambda { order("#{descendant_class.table_name}.distance DESC") }, :through => :ancestor_links, :source => :ancestor
60
- has_many :descendants, lambda { order("#{descendant_class.table_name}.distance ASC") }, :through => :descendant_links, :source => :descendant
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 options[:link_conditions] }, :class_name => descendant_class, :foreign_key => 'descendant_id', :dependent => :delete_all
63
- has_many :descendant_links, lambda { where options[:link_conditions] }, :class_name => descendant_class, :foreign_key => 'ancestor_id', :dependent => :delete_all
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
@@ -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 be_true
90
- @child.descendant_of?(@grandpa).should be_true
91
- @child.ancestor_of?(@grandpa).should be_false
92
- @grandpa.descendant_of?(@child).should be_false
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 be_true
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 be_true
157
- ActsAsDAG::HelperMethods.should_descend_from?(@big_totem_pole, @totem_pole).should be_false
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
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.2.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.