remote: http://rubygems.org/
specs:
diff-lcs (1.1.3)
- graph.njae (0.2.3)
+ graph.njae (0.2.4)
json (1.6.5)
- porter2stemmer (1.0.0)
+ porter2stemmer (1.0.1)
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
--- /dev/null
+#!/usr/bin/env ruby
+#
+# This file was generated by Bundler.
+#
+# The application 'autospec' is installed as part of a gem, and
+# this file is here to facilitate running it.
+#
+
+require 'pathname'
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
+ Pathname.new(__FILE__).realpath)
+
+require 'rubygems'
+require 'bundler/setup'
+
+load Gem.bin_path('rspec-core', 'autospec')
--- /dev/null
+#!/usr/bin/env ruby
+#
+# This file was generated by Bundler.
+#
+# The application 'htmldiff' is installed as part of a gem, and
+# this file is here to facilitate running it.
+#
+
+require 'pathname'
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
+ Pathname.new(__FILE__).realpath)
+
+require 'rubygems'
+require 'bundler/setup'
+
+load Gem.bin_path('diff-lcs', 'htmldiff')
--- /dev/null
+#!/usr/bin/env ruby
+#
+# This file was generated by Bundler.
+#
+# The application 'ldiff' is installed as part of a gem, and
+# this file is here to facilitate running it.
+#
+
+require 'pathname'
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
+ Pathname.new(__FILE__).realpath)
+
+require 'rubygems'
+require 'bundler/setup'
+
+load Gem.bin_path('diff-lcs', 'ldiff')
--- /dev/null
+#!/usr/bin/env ruby
+#
+# This file was generated by Bundler.
+#
+# The application 'rake' is installed as part of a gem, and
+# this file is here to facilitate running it.
+#
+
+require 'pathname'
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
+ Pathname.new(__FILE__).realpath)
+
+require 'rubygems'
+require 'bundler/setup'
+
+load Gem.bin_path('rake', 'rake')
--- /dev/null
+#!/usr/bin/env ruby
+#
+# This file was generated by Bundler.
+#
+# The application 'ri' is installed as part of a gem, and
+# this file is here to facilitate running it.
+#
+
+require 'pathname'
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
+ Pathname.new(__FILE__).realpath)
+
+require 'rubygems'
+require 'bundler/setup'
+
+load Gem.bin_path('rdoc', 'ri')
--- /dev/null
+#!/usr/bin/env ruby
+#
+# This file was generated by Bundler.
+#
+# The application 'rspec' is installed as part of a gem, and
+# this file is here to facilitate running it.
+#
+
+require 'pathname'
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
+ Pathname.new(__FILE__).realpath)
+
+require 'rubygems'
+require 'bundler/setup'
+
+load Gem.bin_path('rspec-core', 'rspec')
require 'erd_handler/erd'
require 'erd_handler/box'
require 'erd_handler/link'
+require 'erd_handler/abstract_erd'
--- /dev/null
+module ErdHandler
+ class AbstractErd < Graph
+ def initialize(source = nil)
+ super()
+ abstract(source) unless source.nil?
+ self
+ end
+
+ # Create an abstract ERD from a base ERD.
+ # An abstract ERD has an additional node for each link
+ def abstract(erd)
+ self.mark = erd.mark
+ self.name = erd.name
+ erd.vertices.each do |v|
+ self << AbstractBox.new(v)
+ # also do links for containment
+ end
+ erd.edges.each do |e|
+ link_vertex = AbstractEdge.new(e)
+ e.connections.each do |c|
+ # find the abstract vertex at this end
+ # connect the abstract link to it
+ end
+ end
+ self
+ end
+ end
+
+ class AbstractBox < Vertex
+ def initialize(souce = nil)
+ super()
+ self.base_vertex = source unless source.nil?
+ self
+ end
+ end
+
+ class AbstractEdge < Vertex
+ def initialize(source = nil)
+ super()
+ self.base_vertex = source unless source.nil?
+ self
+ end
+ end
+end
--- /dev/null
+require 'spec_helper'
+
+module ErdHandler
+ describe AbstractErd do
+ describe "#initialize" do
+ it "creates an empty abstract ERD" do
+ aerd = AbstractErd.new
+ aerd.should have(0).vertices
+ aerd.should have(0).edges
+ end
+
+ it "reads and creates a single box" do
+ erd = Erd.new(File.new("spec/fixtures/single_box_erd.xml"))
+ aerd = AbstractErd.new(erd)
+ aerd.mark.should == 6.5
+ aerd.should have(1).vertices
+ aerd.should have(0).edges
+ end
+ end # #initialize
+
+ describe "#abstract" do
+ it "reads and creates a single box" do
+ erd = Erd.new(File.new("spec/fixtures/single_box_erd.xml"))
+ aerd = AbstractErd.new
+ aerd.abstract erd
+ aerd.mark.should == 6.5
+ aerd.should have(1).vertices
+ aerd.should have(0).edges
+ end
+
+ it "reads and creates two boxes with an edge joining them" do
+ erd = Erd.new(File.new("spec/fixtures/two_boxes_one_link_erd.xml"))
+ aerd = AbstractErd.new
+ aerd.abstract erd
+ aerd.mark.should == 4.5
+ aerd.should have(3).vertices
+ aerd.should have(2).edges
+ end
+ end # #abstract
+
+ end
+end
describe Erd do
let(:input) { double('input').as_null_object }
let(:output) { double('output').as_null_object }
- let(:erd) { Erd.new(input, output) }
+ let(:erd) { Erd.new(input) }
describe "#initialize" do
it "creates an empty ERD" do
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><Drawing
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ name="Untitled" mark="4.5">
+
+<box id="0" name="Unit" mark="0.0">
+ <location x="87.0" y="69.0"/>
+ <size width="80.0" height="40.0"/>
+ <comment></comment>
+</box>
+
+<box id="1" name="Employee" mark="0.0">
+ <location x="80.0" y="60.0"/>
+ <size width="180.0" height="140.0"/>
+ <comment></comment>
+</box>
+
+</Drawing>
\ No newline at end of file