From 29a64f0a2207a69d136c6f67edcd6855af8152d8 Mon Sep 17 00:00:00 2001 From: Neil Smith Date: Fri, 23 Sep 2011 14:27:01 +0100 Subject: [PATCH 1/1] Initial commit --- .gitignore | 48 ++++++++++++++++++++++++++++++++ lib/erd_handler.rb | 4 +++ lib/erd_handler/erd.rb | 8 ++++++ spec/erd_handler/erd_spec.rb | 19 +++++++++++++ spec/fixtures/single_box_erd.xml | 10 +++++++ spec/spec_helper.rb | 3 ++ 6 files changed, 92 insertions(+) create mode 100644 .gitignore create mode 100644 lib/erd_handler.rb create mode 100644 lib/erd_handler/erd.rb create mode 100644 spec/erd_handler/erd_spec.rb create mode 100644 spec/fixtures/single_box_erd.xml create mode 100644 spec/spec_helper.rb diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..63a685e --- /dev/null +++ b/.gitignore @@ -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 index 0000000..501d016 --- /dev/null +++ b/lib/erd_handler.rb @@ -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 index 0000000..b9e6da1 --- /dev/null +++ b/lib/erd_handler/erd.rb @@ -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 index 0000000..ec75afe --- /dev/null +++ b/spec/erd_handler/erd_spec.rb @@ -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 index 0000000..45e7118 --- /dev/null +++ b/spec/fixtures/single_box_erd.xml @@ -0,0 +1,10 @@ + + + + + + + + + diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..3c4ea53 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,3 @@ +require 'erd_handler' +require "rexml/document" +include REXML \ No newline at end of file -- 2.34.1