Initial commit
authorNeil Smith <neil.github@njae.me.uk>
Fri, 23 Sep 2011 13:27:01 +0000 (14:27 +0100)
committerNeil Smith <neil.github@njae.me.uk>
Fri, 23 Sep 2011 13:27:01 +0000 (14:27 +0100)
.gitignore [new file with mode: 0644]
lib/erd_handler.rb [new file with mode: 0644]
lib/erd_handler/erd.rb [new file with mode: 0644]
spec/erd_handler/erd_spec.rb [new file with mode: 0644]
spec/fixtures/single_box_erd.xml [new file with mode: 0644]
spec/spec_helper.rb [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..63a685e
--- /dev/null
@@ -0,0 +1,48 @@
+# rcov generated
+coverage
+
+# rdoc generated
+rdoc
+
+# yard generated
+doc
+.yardoc
+
+# bundler
+.bundle
+
+# jeweler generated
+pkg
+
+# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore: 
+#
+# * Create a file at ~/.gitignore
+# * Include files you want ignored
+# * Run: git config --global core.excludesfile ~/.gitignore
+#
+# After doing this, these files will be ignored in all your git projects,
+# saving you from having to 'pollute' every project you touch with them
+#
+# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
+#
+# For MacOS:
+#
+#.DS_Store
+
+# For TextMate
+#*.tmproj
+#tmtags
+
+# For emacs:
+*~
+\#*
+.\#*
+
+# For vim:
+#*.swp
+
+# For redcar:
+#.redcar
+
+# For rubinius:
+#*.rbc
diff --git a/lib/erd_handler.rb b/lib/erd_handler.rb
new file mode 100644 (file)
index 0000000..501d016
--- /dev/null
@@ -0,0 +1,4 @@
+require 'erd_handler/erd'
+require "rexml/document"
+include REXML  
+
diff --git a/lib/erd_handler/erd.rb b/lib/erd_handler/erd.rb
new file mode 100644 (file)
index 0000000..b9e6da1
--- /dev/null
@@ -0,0 +1,8 @@
+module Erd
+  class Erd
+    def initialize(source = nil)
+      doc = Document.new source
+      raise InvalidErdFile unless doc.elements.length == 1 and doc.elements[1].name.downcase == 'drawing'
+    end
+  end
+end
diff --git a/spec/erd_handler/erd_spec.rb b/spec/erd_handler/erd_spec.rb
new file mode 100644 (file)
index 0000000..ec75afe
--- /dev/null
@@ -0,0 +1,19 @@
+require 'spec_helper'
+
+module Erd
+  describe Erd do
+    let(:input) { double('input').as_null_object }
+    let(:output) { double('output').as_null_object }
+    let(:erd) { Erd.new(input, output) }
+    
+    describe "#read" do
+      it "reads a single box" do
+       doc = Document.new File.new("spec/fixtures/single_box_erd.xml")
+       erd = Erd.new doc
+       erd.mark.should == 6.5
+       erd.boxes.length.should == 1
+       
+      end
+    end # #read
+  end
+end
\ No newline at end of file
diff --git a/spec/fixtures/single_box_erd.xml b/spec/fixtures/single_box_erd.xml
new file mode 100644 (file)
index 0000000..45e7118
--- /dev/null
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
+  <Drawing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   name="Untitled" mark="6.5">
+
+<box id="0" name="Client" mark="0.0">
+  <location x="33.0" y="43.0"/>
+  <size width="80.0" height="40.0"/>
+  <comment></comment>
+</box> 
+</Drawing>
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
new file mode 100644 (file)
index 0000000..3c4ea53
--- /dev/null
@@ -0,0 +1,3 @@
+require 'erd_handler'
+require "rexml/document"
+include REXML  
\ No newline at end of file