Another commit
authorNeil Smith <neil.github@njae.me.uk>
Sun, 25 Sep 2011 18:36:31 +0000 (19:36 +0100)
committerNeil Smith <neil.github@njae.me.uk>
Sun, 25 Sep 2011 18:36:31 +0000 (19:36 +0100)
.rspec [new file with mode: 0644]
Gemfile [new file with mode: 0644]
Gemfile.lock [new file with mode: 0644]
Rakefile [new file with mode: 0644]
lib/erd_handler/box.rb [new file with mode: 0644]
lib/erd_handler/link.rb [new file with mode: 0644]
spec/fixtures/two_boxes_one_link_erd.xml [new file with mode: 0644]

diff --git a/.rspec b/.rspec
new file mode 100644 (file)
index 0000000..4e1e0d2
--- /dev/null
+++ b/.rspec
@@ -0,0 +1 @@
+--color
diff --git a/Gemfile b/Gemfile
new file mode 100644 (file)
index 0000000..6444095
--- /dev/null
+++ b/Gemfile
@@ -0,0 +1,14 @@
+source "http://rubygems.org"
+# Add dependencies required to use your gem here.
+# Example:
+#   gem "activesupport", ">= 2.3.5"
+
+# Add dependencies to develop your gem here.
+# Include everything needed to run rake, tests, features, etc.
+group :development do
+  gem "rspec", "~> 2.6.0"
+  gem "bundler", "~> 1.0.0"
+  gem "rdoc"
+  gem "rake"
+  gem "graph.njae", "0.2.1"
+end
diff --git a/Gemfile.lock b/Gemfile.lock
new file mode 100644 (file)
index 0000000..dca8027
--- /dev/null
@@ -0,0 +1,25 @@
+GEM
+  remote: http://rubygems.org/
+  specs:
+    diff-lcs (1.1.2)
+    graph.njae (0.2.1)
+    rake (0.9.2)
+    rdoc (3.7)
+    rspec (2.6.0)
+      rspec-core (~> 2.6.0)
+      rspec-expectations (~> 2.6.0)
+      rspec-mocks (~> 2.6.0)
+    rspec-core (2.6.4)
+    rspec-expectations (2.6.0)
+      diff-lcs (~> 1.1.2)
+    rspec-mocks (2.6.0)
+
+PLATFORMS
+  ruby
+
+DEPENDENCIES
+  bundler (~> 1.0.0)
+  graph.njae (= 0.2.1)
+  rake
+  rdoc
+  rspec (~> 2.6.0)
diff --git a/Rakefile b/Rakefile
new file mode 100644 (file)
index 0000000..e0a0436
--- /dev/null
+++ b/Rakefile
@@ -0,0 +1,35 @@
+# encoding: utf-8
+
+require 'rubygems'
+require 'bundler'
+begin
+  Bundler.setup(:default, :development)
+rescue Bundler::BundlerError => e
+  $stderr.puts e.message
+  $stderr.puts "Run `bundle install` to install missing gems"
+  exit e.status_code
+end
+require 'rake'
+
+require 'rspec/core'
+require 'rspec/core/rake_task'
+RSpec::Core::RakeTask.new(:spec) do |spec|
+  spec.pattern = FileList['spec/**/*_spec.rb']
+end
+
+RSpec::Core::RakeTask.new(:rcov) do |spec|
+  spec.pattern = 'spec/**/*_spec.rb'
+  spec.rcov = true
+end
+
+task :default => :spec
+
+require 'rdoc/task'
+RDoc::Task.new do |rdoc|
+  version = File.exist?('VERSION') ? File.read('VERSION') : ""
+
+  rdoc.rdoc_dir = 'rdoc'
+  rdoc.title = "graph.njae #{version}"
+  rdoc.rdoc_files.include('README*')
+  rdoc.rdoc_files.include('lib/**/*.rb')
+end
diff --git a/lib/erd_handler/box.rb b/lib/erd_handler/box.rb
new file mode 100644 (file)
index 0000000..7389955
--- /dev/null
@@ -0,0 +1,23 @@
+module ErdHandler
+  class Box < Vertex
+    def initialize(box_element = nil)
+      super()
+      read(box_element) unless box_element.nil?
+      self
+    end # initialize
+    
+    def read(box_element)
+      self.id = box_element.attributes["id"].to_i
+      self.name = box_element.attributes["name"]
+      self.mark = box_element.attributes["mark"].to_f
+      
+      self.x = box_element.elements["location"].attributes["x"].to_f
+      self.y = box_element.elements["location"].attributes["y"].to_f
+      self.width = box_element.elements["size"].attributes["width"].to_f
+      self.height = box_element.elements["size"].attributes["height"].to_f
+      self.comment = box_element.elements["comment"].text
+      self
+    end
+    
+  end
+end
diff --git a/lib/erd_handler/link.rb b/lib/erd_handler/link.rb
new file mode 100644 (file)
index 0000000..f8ebc19
--- /dev/null
@@ -0,0 +1,15 @@
+module ErdHandler
+  class Link < Edge
+    def initialize(link_element = nil, vertices = nil)
+      super()
+      read(link_element, vertices) unless link_element.nil?
+      self
+    end
+    
+    def read(link_element, vertices)
+      self.id = link_element.attributes["id"].to_i
+      self.mark = link_element.attributes["mark"].to_f
+      
+    end
+  end
+end
\ No newline at end of file
diff --git a/spec/fixtures/two_boxes_one_link_erd.xml b/spec/fixtures/two_boxes_one_link_erd.xml
new file mode 100644 (file)
index 0000000..3e0f74d
--- /dev/null
@@ -0,0 +1,36 @@
+<?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="326.0" y="72.0"/>
+  <size width="80.0" height="40.0"/>
+  <comment></comment>
+</box>
+
+<link id="0" mark="0.0">
+  <moveableName name="PreparedBy">
+    <point x="236" y="95"/>
+  </moveableName>
+  <converseName name="converseName"/>
+  <box1 id="0"/>
+  <box2 id="1"/>
+  <bendPoints>
+    <point x="127.0" y="89.0"/>
+    <point x="167.0" y="89.5020920502092"/>
+    <point x="246.5" y="90.5"/>
+    <point x="326.0" y="91.4979079497908"/>
+    <point x="366.0" y="92.0"/>
+  </bendPoints>
+  <midMoved value="false"/>
+  <box1EndAdornments blob="Closed" crowsfoot="Yes"/>
+  <box2EndAdornments blob="Open" crowsfoot="No"/>
+  <comment></comment>
+</link>
+</Drawing>
\ No newline at end of file