acts-as-dag 2.5.7 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/README.rdoc +2 -2
- data/acts-as-dag.gemspec +1 -1
- data/lib/acts-as-dag/version.rb +1 -1
- data/lib/dag/edges.rb +3 -18
- data/test/dag_test.rb +11 -39
- metadata +8 -6
- data/VERSION +0 -1
data/Gemfile
CHANGED
data/README.rdoc
CHANGED
@@ -81,7 +81,7 @@ With polymorphic graphs we also have...
|
|
81
81
|
|
82
82
|
Each of the optional column parameters needs a field in the link table. Hence for non-polymorphic graphs a migration would look like...
|
83
83
|
|
84
|
-
create_table :links
|
84
|
+
create_table :links do |t|
|
85
85
|
t.integer :ancestor_id
|
86
86
|
t.integer :descendant_id
|
87
87
|
t.boolean :direct
|
@@ -90,7 +90,7 @@ Each of the optional column parameters needs a field in the link table. Hence fo
|
|
90
90
|
|
91
91
|
And for polymorphic graphs...
|
92
92
|
|
93
|
-
create_table :links
|
93
|
+
create_table :links do |t|
|
94
94
|
t.integer :ancestor_id
|
95
95
|
t.string :ancestor_type
|
96
96
|
t.integer :descendant_id
|
data/acts-as-dag.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
21
|
# As specified in test/dag_test.rb
|
22
|
-
s.add_development_dependency 'activerecord', '~> 3.
|
22
|
+
s.add_development_dependency 'activerecord', '~> 3.2.12'
|
23
23
|
s.add_development_dependency 'rake'
|
24
24
|
s.add_development_dependency 'sqlite3'
|
25
25
|
s.add_runtime_dependency 'activemodel'
|
data/lib/acts-as-dag/version.rb
CHANGED
data/lib/dag/edges.rb
CHANGED
@@ -63,21 +63,6 @@ module Dag
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
-
#Alias for create_edge
|
67
|
-
def connect(ancestor, descendant)
|
68
|
-
self.create_edge(ancestor, descendant)
|
69
|
-
end
|
70
|
-
|
71
|
-
#Alias for create_edge!
|
72
|
-
def connect!(ancestor, descendant)
|
73
|
-
self.create_edge!(ancestor, descendant)
|
74
|
-
end
|
75
|
-
|
76
|
-
#Determines if a link exists between two points
|
77
|
-
def connected?(ancestor, descendant)
|
78
|
-
!self.find_link(ancestor, descendant).nil?
|
79
|
-
end
|
80
|
-
|
81
66
|
#Finds the longest path between ancestor and descendant returning as an array
|
82
67
|
def longest_path_between(ancestor, descendant, path=[])
|
83
68
|
longest = []
|
@@ -88,7 +73,7 @@ module Dag
|
|
88
73
|
if temp.length > longest.length
|
89
74
|
longest = temp
|
90
75
|
end
|
91
|
-
elsif self.
|
76
|
+
elsif self.find_link(child, descendant)
|
92
77
|
temp = path.clone
|
93
78
|
temp << child
|
94
79
|
temp = self.longest_path_between(child, descendant, temp)
|
@@ -110,7 +95,7 @@ module Dag
|
|
110
95
|
if shortest.blank? || temp.length < shortest.length
|
111
96
|
shortest = temp
|
112
97
|
end
|
113
|
-
elsif self.
|
98
|
+
elsif self.find_link(child, descendant)
|
114
99
|
temp = path.clone
|
115
100
|
temp << child
|
116
101
|
temp = self.shortest_path_between(child, descendant, temp)
|
@@ -320,4 +305,4 @@ module Dag
|
|
320
305
|
end
|
321
306
|
|
322
307
|
end
|
323
|
-
end
|
308
|
+
end
|
data/test/dag_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'test/unit'
|
2
2
|
require 'rubygems'
|
3
|
-
gem 'activerecord', '~> 3.
|
3
|
+
gem 'activerecord', '~> 3.2.8'
|
4
4
|
require "./init"
|
5
5
|
|
6
6
|
|
@@ -9,13 +9,13 @@ ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => "#{F
|
|
9
9
|
#Used for basic graph link testing
|
10
10
|
class Default < ActiveRecord::Base
|
11
11
|
acts_as_dag_links :node_class_name => 'Node'
|
12
|
-
|
12
|
+
self.table_name = 'edges'
|
13
13
|
end
|
14
14
|
|
15
15
|
#Used for polymorphic graph link testing
|
16
16
|
class Poly < ActiveRecord::Base
|
17
17
|
acts_as_dag_links :polymorphic => true
|
18
|
-
|
18
|
+
self.table_name = 'poly_edges'
|
19
19
|
end
|
20
20
|
|
21
21
|
#Used for redefinition testing
|
@@ -25,43 +25,43 @@ class Redefiner < ActiveRecord::Base
|
|
25
25
|
:count_column => 'c',
|
26
26
|
:ancestor_id_column => 'foo_id',
|
27
27
|
:descendant_id_column => 'bar_id'
|
28
|
-
|
28
|
+
self.table_name = 'edges2'
|
29
29
|
end
|
30
30
|
|
31
31
|
class Node < ActiveRecord::Base
|
32
32
|
has_dag_links :link_class_name => 'Default'
|
33
|
-
|
33
|
+
self.table_name = 'nodes'
|
34
34
|
end
|
35
35
|
|
36
36
|
class RedefNode < ActiveRecord::Base
|
37
37
|
has_dag_links :link_class_name => 'Redefiner'
|
38
|
-
|
38
|
+
self.table_name = 'redef_nodes'
|
39
39
|
end
|
40
40
|
|
41
41
|
class AlphaNode < ActiveRecord::Base
|
42
42
|
has_dag_links :link_class_name => 'Poly',
|
43
43
|
:descendant_class_names => ['BetaNode', 'GammaNode', 'ZetaNode']
|
44
|
-
|
44
|
+
self.table_name = 'alpha_nodes'
|
45
45
|
end
|
46
46
|
|
47
47
|
class BetaNode < ActiveRecord::Base
|
48
48
|
has_dag_links :link_class_name => 'Poly',
|
49
49
|
:ancestor_class_names => ['AlphaNode', 'BetaNode'],
|
50
50
|
:descendant_class_names => ['BetaNode', 'GammaNode', 'ZetaNode']
|
51
|
-
|
51
|
+
self.table_name = 'beta_nodes'
|
52
52
|
end
|
53
53
|
|
54
54
|
class GammaNode < ActiveRecord::Base
|
55
55
|
has_dag_links :link_class_name => 'Poly',
|
56
56
|
:ancestor_class_names => ['AlphaNode', 'BetaNode', 'GammaNode'],
|
57
57
|
:descendant_class_names => ['GammaNode', 'ZetaNode']
|
58
|
-
|
58
|
+
self.table_name = 'gamma_nodes'
|
59
59
|
end
|
60
60
|
|
61
61
|
class ZetaNode < ActiveRecord::Base
|
62
62
|
has_dag_links :link_class_name => 'Poly',
|
63
63
|
:ancestor_class_names => ['AlphaNode', 'BetaNode', 'GammaNode']
|
64
|
-
|
64
|
+
self.table_name = 'zeta_nodes'
|
65
65
|
end
|
66
66
|
|
67
67
|
|
@@ -509,34 +509,6 @@ class DagTest < Test::Unit::TestCase
|
|
509
509
|
assert_nil testnil
|
510
510
|
end
|
511
511
|
|
512
|
-
#Tests class method connect
|
513
|
-
def test_manual_connect_lonely_edge
|
514
|
-
a = Node.create!
|
515
|
-
b = Node.create!
|
516
|
-
e = Default.connect!(a, b)
|
517
|
-
e2 = Default.find_edge(a, b)
|
518
|
-
assert e2.direct?
|
519
|
-
assert_equal 1, e2.count
|
520
|
-
assert_equal e, e2
|
521
|
-
assert_equal e2.ancestor, a
|
522
|
-
assert_equal e2.descendant, b
|
523
|
-
end
|
524
|
-
|
525
|
-
#Tests simple indirect link creation
|
526
|
-
def test_auto_simple_cross
|
527
|
-
a = Node.create!
|
528
|
-
b = Node.create!
|
529
|
-
c = Node.create!
|
530
|
-
e = Default.connect(a, b)
|
531
|
-
e2 = Default.connect(b, c)
|
532
|
-
indirect = Default.find_link(a, c)
|
533
|
-
assert !indirect.nil?
|
534
|
-
assert !indirect.direct?
|
535
|
-
assert_equal 1, indirect.count
|
536
|
-
assert_equal a, indirect.ancestor
|
537
|
-
assert_equal c, indirect.descendant
|
538
|
-
end
|
539
|
-
|
540
512
|
##########################
|
541
513
|
#TESTS FOR has_dag_links #
|
542
514
|
##########################
|
@@ -869,4 +841,4 @@ class DagTest < Test::Unit::TestCase
|
|
869
841
|
e.destroy
|
870
842
|
end
|
871
843
|
|
872
|
-
end
|
844
|
+
end
|
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:
|
4
|
+
version: 3.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2013-02-18 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 3.
|
22
|
+
version: 3.2.12
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -27,7 +27,7 @@ dependencies:
|
|
27
27
|
requirements:
|
28
28
|
- - ~>
|
29
29
|
- !ruby/object:Gem::Version
|
30
|
-
version: 3.
|
30
|
+
version: 3.2.12
|
31
31
|
- !ruby/object:Gem::Dependency
|
32
32
|
name: rake
|
33
33
|
requirement: !ruby/object:Gem::Requirement
|
@@ -104,7 +104,6 @@ files:
|
|
104
104
|
- MIT-LICENSE
|
105
105
|
- README.rdoc
|
106
106
|
- Rakefile
|
107
|
-
- VERSION
|
108
107
|
- acts-as-dag.gemspec
|
109
108
|
- init.rb
|
110
109
|
- lib/acts-as-dag.rb
|
@@ -129,6 +128,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
129
128
|
- - ! '>='
|
130
129
|
- !ruby/object:Gem::Version
|
131
130
|
version: '0'
|
131
|
+
segments:
|
132
|
+
- 0
|
133
|
+
hash: -251717266432713559
|
132
134
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
135
|
none: false
|
134
136
|
requirements:
|
@@ -137,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
139
|
version: '0'
|
138
140
|
requirements: []
|
139
141
|
rubyforge_project: acts-as-dag
|
140
|
-
rubygems_version: 1.8.
|
142
|
+
rubygems_version: 1.8.25
|
141
143
|
signing_key:
|
142
144
|
specification_version: 3
|
143
145
|
summary: Directed Acyclic Graph hierarchy for Rail's ActiveRecord
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.5.5
|