remote: http://rubygems.org/
specs:
diff-lcs (1.1.3)
- graph.njae (0.2.4)
- json (1.6.5)
+ graph.njae (0.4.0)
+ json (1.7.3)
multi_json (1.3.6)
- porter2stemmer (1.0.0)
porter2stemmer (1.0.1)
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
- rspec (2.8.0)
- rspec-core (~> 2.8.0)
- rspec-expectations (~> 2.8.0)
- rspec-mocks (~> 2.8.0)
- rspec-core (2.8.0)
- rspec-expectations (2.8.0)
- diff-lcs (~> 1.1.2)
- rspec-mocks (2.8.0)
+ rspec (2.11.0)
+ rspec-core (~> 2.11.0)
+ rspec-expectations (~> 2.11.0)
+ rspec-mocks (~> 2.11.0)
+ rspec-core (2.11.0)
+ rspec-expectations (2.11.1)
+ diff-lcs (~> 1.1.3)
+ rspec-mocks (2.11.1)
simplecov (0.6.4)
multi_json (~> 1.0)
simplecov-html (~> 0.5.3)
end
# Create an abstract ERD from a base ERD.
- # An abstract ERD has an additional node for each link
+ # An abstract ERD has an additional vertex for each link and each end of the link
def abstract(erd)
self.mark = erd.mark
self.name = erd.name
# also do links for containment
end
erd.edges.each do |e|
- link_vertex = AbstractEdge.new(e)
+ link_vertex = AbstractLink.new(e)
self << link_vertex
e.connections.each do |c|
- connection = AbstractConnection.new(c)
+ connection = AbstractLinkEnd.new(c)
self << connection
self << link_vertex.connect(connection)
self << connection.connect(self.vertices.find {|v| v.base_vertex == c.end})
end
class AbstractBox < Vertex
- def initialize(source)
+ def initialize(source = nil)
super()
- self.base_vertex = source
+ self.base_vertex = source unless source.nil?
self
end
end
- class AbstractEdge < Vertex
+ class AbstractLink < Vertex
def initialize(source = nil)
super()
- self.base_edge = source unless source.nil?
+ self.base_link = source unless source.nil?
self
end
end
- class AbstractConnection < Vertex
+ class AbstractLinkEnd < Vertex
def initialize(source = nil)
super()
- self.base_connection = source unless source.nil?
+ self.base_link_end = source unless source.nil?
self
end
end
box1 = vertices.select {|v| v.id == link_element.elements['box1'].attributes['id'].to_i}[0]
box2 = vertices.select {|v| v.id == link_element.elements['box2'].attributes['id'].to_i}[0]
self << box1 << box2
- box1.edges << self
- box2.edges << self unless box1 == box2
if box1 == box2
c1 = self.connections[0]
c2 = self.connections[1]
aerd.mark.should == 4.5
aerd.should have(5).vertices
aerd.should have(4).edges
+ v0 = aerd.vertices.find {|v| v.class == AbstractBox and v.base_vertex.id == 0}
+ v1 = aerd.vertices.find {|v| v.class == AbstractBox and v.base_vertex.id == 1}
+ e = aerd.vertices.find {|v| v.class == AbstractLink}
+ c0 = aerd.vertices.find {|v| v.class == AbstractLinkEnd and v.neighbours.include? v0}
+ c1 = aerd.vertices.find {|v| v.class == AbstractLinkEnd and v.neighbours.include? v1}
+ v0.should have(1).neighbours
+ v1.should have(1).neighbours
+ e.should have(2).neighbours
+ c0.should have(2).neighbours
+ c1.should have(2).neighbours
+ e.neighbours.should include(c0)
+ e.neighbours.should include(c1)
+ c0.neighbours.should include(e)
+ c0.neighbours.should include(v0)
+ c1.neighbours.should include(e)
+ c1.neighbours.should include(v1)
end
end # #abstract