dagnabit 2.2.2 → 2.2.3

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/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
+ :patch: 3
3
+ :build:
2
4
  :major: 2
3
5
  :minor: 2
4
- :patch: 2
5
- :build:
data/dagnabit.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{dagnabit}
8
- s.version = "2.2.2"
8
+ s.version = "2.2.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["David Yip"]
12
- s.date = %q{2010-02-04}
12
+ s.date = %q{2010-02-17}
13
13
  s.default_executable = %q{dagnabit-test}
14
14
  s.email = %q{yipdw@northwestern.edu}
15
15
  s.executables = ["dagnabit-test"]
@@ -75,9 +75,7 @@ Gem::Specification.new do |s|
75
75
  s.rubygems_version = %q{1.3.5}
76
76
  s.summary = %q{Directed acyclic graph plugin for ActiveRecord}
77
77
  s.test_files = [
78
- "test/benchmark/helper.rb",
79
- "test/benchmark/linear_benchmark.rb",
80
- "test/connections/native_postgresql/connection.rb",
78
+ "test/connections/native_postgresql/connection.rb",
81
79
  "test/connections/native_sqlite3/connection.rb",
82
80
  "test/dagnabit/link/test_associations.rb",
83
81
  "test/dagnabit/link/test_class_methods.rb",
@@ -17,7 +17,7 @@ module Dagnabit
17
17
 
18
18
  with_temporary_edge_tables('suspect', 'trusty', 'new') do |suspect, trusty, new|
19
19
  connection.execute <<-END
20
- INSERT INTO #{suspect}
20
+ INSERT INTO #{suspect} (#{tc_aid}, #{tc_did}, #{tc_atype}, #{tc_dtype})
21
21
  SELECT * FROM (
22
22
  SELECT
23
23
  TC1.#{tc_aid}, TC2.#{tc_did}, TC1.#{tc_atype}, TC2.#{tc_dtype}
@@ -54,7 +54,7 @@ module Dagnabit
54
54
  END
55
55
 
56
56
  connection.execute <<-END
57
- INSERT INTO #{trusty}
57
+ INSERT INTO #{trusty} (#{tc_aid}, #{tc_did}, #{tc_atype}, #{tc_dtype})
58
58
  SELECT
59
59
  #{tc_aid}, #{tc_did}, #{tc_atype}, #{tc_dtype}
60
60
  FROM (
@@ -84,9 +84,9 @@ module Dagnabit
84
84
  END
85
85
 
86
86
  connection.execute <<-END
87
- INSERT INTO #{new}
87
+ INSERT INTO #{new} (#{tc_aid}, #{tc_did}, #{tc_atype}, #{tc_dtype})
88
88
  SELECT * FROM (
89
- SELECT * FROM #{trusty}
89
+ SELECT #{tc_aid}, #{tc_did}, #{tc_atype}, #{tc_dtype} FROM #{trusty}
90
90
  UNION
91
91
  SELECT
92
92
  T1.#{tc_aid}, T2.#{tc_aid}, T1.#{tc_atype}, T2.#{tc_dtype}
@@ -54,6 +54,34 @@ module Dagnabit
54
54
  assert_nil tc, 'expected to not find path from n1 to n3'
55
55
  end
56
56
 
57
+ should 'recalculate transitive closure when destroying links with custom data' do
58
+ n1 = ::Node.create
59
+ n2 = ::Node.create
60
+ n3 = ::Node.create
61
+ n4 = ::Node.create
62
+
63
+ l1 = CustomDataLink.create(:ancestor => n1, :descendant => n2, :data => 'foo')
64
+ l2 = CustomDataLink.create(:ancestor => n2, :descendant => n3, :data => 'bar')
65
+ l3 = CustomDataLink.create(:ancestor => n3, :descendant => n4, :data => 'baz')
66
+
67
+ l2.destroy
68
+
69
+ tc1 = TransitiveClosureCustomDataLink.find(:first, :conditions => { :ancestor_id => n1.id, :descendant_id => n2.id })
70
+ assert_not_nil tc1, 'expected to find path from n1 to n2'
71
+ assert_equal 'foo', tc1.data, 'expected to find custom data attribute on n1->n2 edge'
72
+
73
+ tc2 = TransitiveClosureCustomDataLink.find(:first, :conditions => { :ancestor_id => n3.id, :descendant_id => n4.id })
74
+ assert_not_nil tc2, 'expected to find path from n3 to n4'
75
+ assert_equal 'baz', tc2.data, 'expected to find custom data attribute on n3->n4 edge'
76
+
77
+ tc = TransitiveClosureCustomDataLink.find(:first, :conditions => { :ancestor_id => n1.id, :descendant_id => n3.id })
78
+ assert_nil tc, 'expected to not find path from n1 to n3'
79
+ tc = TransitiveClosureCustomDataLink.find(:first, :conditions => { :ancestor_id => n2.id, :descendant_id => n4.id })
80
+ assert_nil tc, 'expected to not find path from n2 to n4'
81
+ tc = TransitiveClosureCustomDataLink.find(:first, :conditions => { :ancestor_id => n1.id, :descendant_id => n4.id })
82
+ assert_nil tc, 'expected to not find path from n1 to n4'
83
+ end
84
+
57
85
  should 'include edges in the graph when reconstructing the transitive closure on destroy' do
58
86
  n1 = ::Node.create
59
87
  n2 = ::Node.create
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dagnabit
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.2
4
+ version: 2.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Yip
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-04 00:00:00 -06:00
12
+ date: 2010-02-17 00:00:00 -06:00
13
13
  default_executable: dagnabit-test
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -141,8 +141,6 @@ signing_key:
141
141
  specification_version: 3
142
142
  summary: Directed acyclic graph plugin for ActiveRecord
143
143
  test_files:
144
- - test/benchmark/helper.rb
145
- - test/benchmark/linear_benchmark.rb
146
144
  - test/connections/native_postgresql/connection.rb
147
145
  - test/connections/native_sqlite3/connection.rb
148
146
  - test/dagnabit/link/test_associations.rb
@@ -1,43 +0,0 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'active_record'
4
- require 'active_support/test_case'
5
-
6
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
7
- $LOAD_PATH.unshift(File.dirname(__FILE__))
8
- require 'dagnabit'
9
-
10
- ActiveRecord::Base.logger = Logger.new("benchmark.log")
11
- ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:')
12
-
13
- ActiveRecord::Schema.define do
14
- [:links, :links_transitive_closure_tuples].each do |table|
15
- create_table table do |t|
16
- t.integer :ancestor_id
17
- t.integer :descendant_id
18
- t.string :ancestor_type
19
- t.string :descendant_type
20
- end
21
- end
22
-
23
- create_table :nodes do |t|
24
- t.string :data
25
- end
26
- end
27
-
28
- class Link < ActiveRecord::Base
29
- acts_as_dag_link
30
- end
31
-
32
- class Node < ActiveRecord::Base
33
- acts_as_dag_node_linked_by 'Link'
34
- end
35
-
36
- REPETITIONS = 5
37
-
38
- class BenchmarkTestCase < ActiveSupport::TestCase
39
- def teardown
40
- Node.delete_all
41
- Link.delete_all
42
- end
43
- end
@@ -1,41 +0,0 @@
1
- require File.dirname(__FILE__) + '/helper'
2
-
3
- class LinearBenchmark < BenchmarkTestCase
4
- def test_speed
5
- Benchmark.bm do |x|
6
- root = Node.create
7
- last_node = root
8
-
9
- 100.times do |i|
10
- target = Node.create
11
-
12
- x.report("Graph depth: #{i+1}") { Link.connect(last_node, target) }
13
-
14
- assert_equal 1, last_node.children.length
15
- assert_equal i+1, root.descendants.length
16
-
17
- last_node = target
18
- end
19
- end
20
- end
21
-
22
- def test_deletion_from_long_list
23
- nodes = []
24
- last_node = Node.create
25
-
26
- puts 'Building long list...'
27
- 50.times do |i|
28
- target = Node.create
29
- Link.connect(last_node, target)
30
- last_node = target
31
-
32
- nodes << target
33
- end
34
-
35
- Benchmark.bm do |x|
36
- nodes.each_with_index do |node, i|
37
- x.report("Destroying node #{i}") { node.destroy }
38
- end
39
- end
40
- end
41
- end