dagnabit 3.0.0 → 3.0.1
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.
- data/History.md +11 -0
- data/LICENSE +1 -1
- data/README.md +8 -6
- data/lib/dagnabit/edge/connectivity.rb +1 -3
- data/lib/dagnabit/graph.rb +10 -5
- data/lib/dagnabit/version.rb +1 -1
- metadata +12 -65
data/History.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
3.0.1 (2011-04-30)
|
2
|
+
==================
|
3
|
+
|
4
|
+
Minor changes
|
5
|
+
-------------
|
6
|
+
|
7
|
+
* Declare compatibility with ActiveRecord 3.
|
8
|
+
* Eagerly load parent and child associations for edges loaded by
|
9
|
+
`Dagnabit::Graph#load_descendants!`.
|
10
|
+
* Loosened up RSpec dependency.
|
11
|
+
|
1
12
|
3.0.0 2011-01-10
|
2
13
|
================
|
3
14
|
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -61,7 +61,9 @@ The primary differences between dagnabit and acts-as-dag are:
|
|
61
61
|
Database compatibility
|
62
62
|
======================
|
63
63
|
|
64
|
-
PostgreSQL. That's all I know that'll work with dagnabit, anyway.
|
64
|
+
PostgreSQL 8.4. That's all I know that'll work with dagnabit, anyway.
|
65
|
+
Versions of PostgreSQL less than 8.4 will not work because they do not
|
66
|
+
implement `WITH RECURSIVE`.
|
65
67
|
|
66
68
|
It's possible other SQL databases will work, but I have no tests to demonstrate
|
67
69
|
that situation.
|
@@ -142,16 +144,16 @@ dagnabit's cycle-checking trigger
|
|
142
144
|
---------------------------------
|
143
145
|
|
144
146
|
dagnabit ships with a PL/pgSQL trigger that can be installed on edge tables.
|
145
|
-
The trigger algorithm is run per inserted or updated row, and
|
146
|
-
|
147
|
+
The trigger algorithm is run per inserted or updated row, and is implemented
|
148
|
+
with a depth-first search:
|
147
149
|
|
148
150
|
trigger check_cycle(seen = [], edge = (a, b)):
|
149
|
-
if
|
151
|
+
if b is not in seen
|
150
152
|
if b has no children
|
151
153
|
ok
|
152
154
|
else
|
153
155
|
for each child c of b
|
154
|
-
check_cycle(seen + [b], (
|
156
|
+
check_cycle(seen + [b], (b, c))
|
155
157
|
end
|
156
158
|
else
|
157
159
|
abort
|
@@ -218,5 +220,5 @@ listing of the `dagnabit-test` program.
|
|
218
220
|
Copyright
|
219
221
|
=========
|
220
222
|
|
221
|
-
Copyright (c) 2009, 2010 David Yip. Released under the MIT License; see
|
223
|
+
Copyright (c) 2009, 2010, 2011 David Yip. Released under the MIT License; see
|
222
224
|
LICENSE for details.
|
@@ -30,9 +30,7 @@ module Dagnabit::Edge
|
|
30
30
|
def connecting(*vertices)
|
31
31
|
ids = vertices.map(&:id)
|
32
32
|
|
33
|
-
|
34
|
-
SELECT * FROM #{table_name} WHERE parent_id IN (:ids) AND child_id IN (:ids)
|
35
|
-
}, { :ids => ids }])
|
33
|
+
scoped(:conditions => { :parent_id => ids, :child_id => ids })
|
36
34
|
end
|
37
35
|
end
|
38
36
|
end
|
data/lib/dagnabit/graph.rb
CHANGED
@@ -85,18 +85,23 @@ module Dagnabit
|
|
85
85
|
# {#vertex_model} and {#edge_model} must be set before calling this method.
|
86
86
|
# If either are not set, this method raises `RuntimeError`.
|
87
87
|
#
|
88
|
-
#
|
89
|
-
# vertices in the working vertex set.
|
90
|
-
#
|
91
|
-
# Vertices and edges that were present before a load_descendants! call will
|
88
|
+
# Vertices and edges that were present before a `load_descendants!` call will
|
92
89
|
# remain in {#vertices} and {#edges}, respectively.
|
93
90
|
#
|
91
|
+
#
|
92
|
+
# Edge load behavior
|
93
|
+
# ==================
|
94
|
+
#
|
95
|
+
# Once vertices have been loaded, `load_descendants!` loads all edges that
|
96
|
+
# connect vertices in the working vertex set. It also eagerly loads
|
97
|
+
# `parent` and `child` associations on edges.
|
98
|
+
#
|
94
99
|
# @raise [RuntimeError] if {#vertex_model} or {#edge_model} are unset
|
95
100
|
def load_descendants!
|
96
101
|
raise 'vertex_model and edge_model must be set' unless vertex_model && edge_model
|
97
102
|
|
98
103
|
self.vertices += vertex_model.descendants_of(*vertices)
|
99
|
-
self.edges += edge_model.connecting(*vertices)
|
104
|
+
self.edges += edge_model.connecting(*vertices).scoped(:include => [:parent, :child])
|
100
105
|
end
|
101
106
|
|
102
107
|
##
|
data/lib/dagnabit/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dagnabit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
segments:
|
7
|
-
- 3
|
8
|
-
- 0
|
9
|
-
- 0
|
10
|
-
version: 3.0.0
|
4
|
+
prerelease:
|
5
|
+
version: 3.0.1
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
8
|
- David Yip
|
@@ -15,7 +10,7 @@ autorequire:
|
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
12
|
|
18
|
-
date: 2011-
|
13
|
+
date: 2011-04-30 00:00:00 -05:00
|
19
14
|
default_executable:
|
20
15
|
dependencies:
|
21
16
|
- !ruby/object:Gem::Dependency
|
@@ -24,13 +19,8 @@ dependencies:
|
|
24
19
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
20
|
none: false
|
26
21
|
requirements:
|
27
|
-
- -
|
22
|
+
- - ">="
|
28
23
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 3
|
30
|
-
segments:
|
31
|
-
- 2
|
32
|
-
- 3
|
33
|
-
- 0
|
34
24
|
version: 2.3.0
|
35
25
|
type: :runtime
|
36
26
|
version_requirements: *id001
|
@@ -42,9 +32,6 @@ dependencies:
|
|
42
32
|
requirements:
|
43
33
|
- - ">="
|
44
34
|
- !ruby/object:Gem::Version
|
45
|
-
hash: 3
|
46
|
-
segments:
|
47
|
-
- 0
|
48
35
|
version: "0"
|
49
36
|
type: :development
|
50
37
|
version_requirements: *id002
|
@@ -56,9 +43,6 @@ dependencies:
|
|
56
43
|
requirements:
|
57
44
|
- - ">="
|
58
45
|
- !ruby/object:Gem::Version
|
59
|
-
hash: 3
|
60
|
-
segments:
|
61
|
-
- 0
|
62
46
|
version: "0"
|
63
47
|
type: :development
|
64
48
|
version_requirements: *id003
|
@@ -70,9 +54,6 @@ dependencies:
|
|
70
54
|
requirements:
|
71
55
|
- - ">="
|
72
56
|
- !ruby/object:Gem::Version
|
73
|
-
hash: 3
|
74
|
-
segments:
|
75
|
-
- 0
|
76
57
|
version: "0"
|
77
58
|
type: :development
|
78
59
|
version_requirements: *id004
|
@@ -84,70 +65,42 @@ dependencies:
|
|
84
65
|
requirements:
|
85
66
|
- - ">="
|
86
67
|
- !ruby/object:Gem::Version
|
87
|
-
hash: 3
|
88
|
-
segments:
|
89
|
-
- 0
|
90
68
|
version: "0"
|
91
69
|
type: :development
|
92
70
|
version_requirements: *id005
|
93
|
-
- !ruby/object:Gem::Dependency
|
94
|
-
name: rcov
|
95
|
-
prerelease: false
|
96
|
-
requirement: &id006 !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
|
-
requirements:
|
99
|
-
- - ">="
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
hash: 3
|
102
|
-
segments:
|
103
|
-
- 0
|
104
|
-
version: "0"
|
105
|
-
type: :development
|
106
|
-
version_requirements: *id006
|
107
71
|
- !ruby/object:Gem::Dependency
|
108
72
|
name: rspec
|
109
73
|
prerelease: false
|
110
|
-
requirement: &
|
74
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
111
75
|
none: false
|
112
76
|
requirements:
|
113
77
|
- - ~>
|
114
78
|
- !ruby/object:Gem::Version
|
115
|
-
|
116
|
-
segments:
|
117
|
-
- 2
|
118
|
-
- 0
|
119
|
-
- 0
|
120
|
-
version: 2.0.0
|
79
|
+
version: "2.0"
|
121
80
|
type: :development
|
122
|
-
version_requirements: *
|
81
|
+
version_requirements: *id006
|
123
82
|
- !ruby/object:Gem::Dependency
|
124
83
|
name: pg
|
125
84
|
prerelease: false
|
126
|
-
requirement: &
|
85
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
127
86
|
none: false
|
128
87
|
requirements:
|
129
88
|
- - ">="
|
130
89
|
- !ruby/object:Gem::Version
|
131
|
-
hash: 3
|
132
|
-
segments:
|
133
|
-
- 0
|
134
90
|
version: "0"
|
135
91
|
type: :development
|
136
|
-
version_requirements: *
|
92
|
+
version_requirements: *id007
|
137
93
|
- !ruby/object:Gem::Dependency
|
138
94
|
name: yard
|
139
95
|
prerelease: false
|
140
|
-
requirement: &
|
96
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
141
97
|
none: false
|
142
98
|
requirements:
|
143
99
|
- - ">="
|
144
100
|
- !ruby/object:Gem::Version
|
145
|
-
hash: 3
|
146
|
-
segments:
|
147
|
-
- 0
|
148
101
|
version: "0"
|
149
102
|
type: :development
|
150
|
-
version_requirements: *
|
103
|
+
version_requirements: *id008
|
151
104
|
description: Directed acyclic graph support library for applications using ActiveRecord on top of PostgreSQL.
|
152
105
|
email:
|
153
106
|
- yipdw@member.fsf.org
|
@@ -199,23 +152,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
199
152
|
requirements:
|
200
153
|
- - ">="
|
201
154
|
- !ruby/object:Gem::Version
|
202
|
-
hash: 3
|
203
|
-
segments:
|
204
|
-
- 0
|
205
155
|
version: "0"
|
206
156
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
207
157
|
none: false
|
208
158
|
requirements:
|
209
159
|
- - ">="
|
210
160
|
- !ruby/object:Gem::Version
|
211
|
-
hash: 3
|
212
|
-
segments:
|
213
|
-
- 0
|
214
161
|
version: "0"
|
215
162
|
requirements: []
|
216
163
|
|
217
164
|
rubyforge_project:
|
218
|
-
rubygems_version: 1.3
|
165
|
+
rubygems_version: 1.5.3
|
219
166
|
signing_key:
|
220
167
|
specification_version: 3
|
221
168
|
summary: Directed acyclic graph plugin for ActiveRecord/PostgreSQL
|