Merge branch 'master' into abstract-erd
authorNeil Smith <neil.github@njae.me.uk>
Wed, 18 Jul 2012 08:13:18 +0000 (09:13 +0100)
committerNeil Smith <neil.github@njae.me.uk>
Wed, 18 Jul 2012 08:13:18 +0000 (09:13 +0100)
Conflicts:
Gemfile.lock
spec/spec_helper.rb

13 files changed:
Gemfile.lock
lib/erd_handler.rb
lib/erd_handler/abstract_erd.rb [new file with mode: 0644]
lib/erd_handler/box.rb
lib/erd_handler/erd.rb
lib/erd_handler/exceptions.rb [new file with mode: 0644]
lib/erd_handler/link.rb
lib/erd_handler/logger.rb [new file with mode: 0644]
spec/erd_handler/abstract_erd_spec.rb [new file with mode: 0644]
spec/erd_handler/box_spec.rb
spec/erd_handler/erd_spec.rb
spec/erd_handler/label_spec.rb
spec/spec_helper.rb

index 8cec60c0532a8c96a17792af14ba7ccfdd24a076..0a4459e6557a79649e653742171ab8a41dab22b8 100644 (file)
@@ -2,10 +2,11 @@ GEM
   remote: http://rubygems.org/
   specs:
     diff-lcs (1.1.3)
-    graph.njae (0.2.3)
+    graph.njae (0.2.4)
     json (1.6.5)
     multi_json (1.3.6)
     porter2stemmer (1.0.0)
+    porter2stemmer (1.0.1)
     rake (0.9.2.2)
     rdoc (3.12)
       json (~> 1.4)
index 241db56426ace2871c6e77a53b4b0927cff1b7ba..a77d2872950381de799cac75569fbbdeabe66659 100644 (file)
@@ -1,15 +1,18 @@
 require 'bundler/setup'
 
 require 'rexml/document'
-include REXML  
 
 require 'graph.njae'
 include GraphNjae
 
 require 'porter2stemmer'
+require 'logger'
 
-require 'erd_handler/label'
-require 'erd_handler/erd'
-require 'erd_handler/box'
-require 'erd_handler/link'
+require_relative 'erd_handler/exceptions'
+require_relative 'erd_handler/logger'
+require_relative 'erd_handler/label'
+require_relative 'erd_handler/erd'
+require_relative 'erd_handler/box'
+require_relative 'erd_handler/link'
+require_relative 'erd_handler/abstract_erd'
 
diff --git a/lib/erd_handler/abstract_erd.rb b/lib/erd_handler/abstract_erd.rb
new file mode 100644 (file)
index 0000000..c3e8a77
--- /dev/null
@@ -0,0 +1,55 @@
+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)
+        self << link_vertex
+        e.connections.each do |c|
+          connection = AbstractConnection.new(c)
+          self << connection
+          self << link_vertex.connect(connection)
+          self << connection.connect(self.vertices.find {|v| v.base_vertex == c.end})
+        end
+      end
+      self
+    end
+  end
+  
+  class AbstractBox < Vertex
+    def initialize(source)
+      super()
+      self.base_vertex = source
+      self
+    end
+  end
+  
+  class AbstractEdge < Vertex
+    def initialize(source = nil)
+      super()
+      self.base_edge = source unless source.nil?
+      self
+    end
+  end
+  
+  class AbstractConnection < Vertex
+    def initialize(source = nil)
+      super()
+      self.base_connection = source unless source.nil?
+      self
+    end
+  end
+end
index 244b411fc597e663ba4b637685dcf5ddf1f177cc..edd05dcd9b52de5480d307bb0dd327c37dce9c43 100644 (file)
@@ -7,15 +7,15 @@ module ErdHandler
     end # initialize
     
     def read(box_element)
-      self.id = box_element.attributes["id"].to_i
-      self.name = Label.new box_element.attributes["name"]
-      self.mark = box_element.attributes["mark"].to_f
+      self.id = box_element.attributes['id'].to_i
+      self.name = Label.new 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.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
     
index 2c10364ef90983bbb74009d2d12d46eccea3e142..09f36614b59a2f74769c6f99961644fc4306b384 100644 (file)
@@ -7,10 +7,11 @@ module ErdHandler
     end
     
     def read(source)
-      doc = Document.new(source)
-      raise InvalidErdFile unless doc.elements.to_a.length == 1 and doc.elements[1].name.downcase == 'drawing'
-      self.mark = doc.elements['Drawing'].attributes["mark"].to_f
-      self.name = Label.new doc.elements['Drawing'].attributes["name"]
+      doc = REXML::Document.new(source)
+      raise(InvalidErdFile, "#{source} doesn't contain a drawing element") unless doc.elements[1].name.downcase == 'drawing'
+      raise(InvalidErdFile, "#{source} doesn't have one drawing element") unless doc.elements.to_a.length == 1
+      self.mark = doc.elements['Drawing'].attributes['mark'].to_f
+      self.name = Label.new doc.elements['Drawing'].attributes['name']
       doc.elements.each('Drawing/box') do |box_element|
         self << Box.new(box_element)
       end
diff --git a/lib/erd_handler/exceptions.rb b/lib/erd_handler/exceptions.rb
new file mode 100644 (file)
index 0000000..ec38c4d
--- /dev/null
@@ -0,0 +1,3 @@
+module ErdHandler
+  class InvalidErdFile < ArgumentError; end;
+end
\ No newline at end of file
index 63bfd0600182574a9a527c18c1a8c68421ac46c9..3b7ff599edb3051835a694fbc051a0d42123785f 100644 (file)
@@ -7,8 +7,8 @@ module ErdHandler
     end
     
     def read(link_element, vertices)
-      self.id = link_element.attributes["id"].to_i
-      self.mark = link_element.attributes["mark"].to_f
+      self.id = link_element.attributes['id'].to_i
+      self.mark = link_element.attributes['mark'].to_f
       self.name = Label.new link_element.elements['moveableName'].attributes['name']
       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]
diff --git a/lib/erd_handler/logger.rb b/lib/erd_handler/logger.rb
new file mode 100644 (file)
index 0000000..2665077
--- /dev/null
@@ -0,0 +1,6 @@
+module ErdHandler
+  #$ERD_LOGGER = Logger.new(STDERR)
+  $ERD_LOGGER = Logger.new('erd.log')
+  #$ERD_LOGGER.level = Logger::WARN
+  $ERD_LOGGER.level = Logger::DEBUG
+end
diff --git a/spec/erd_handler/abstract_erd_spec.rb b/spec/erd_handler/abstract_erd_spec.rb
new file mode 100644 (file)
index 0000000..361bfe1
--- /dev/null
@@ -0,0 +1,42 @@
+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 'creates abstract graph of 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 'creates abstract graph of 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(5).vertices
+        aerd.should have(4).edges
+      end
+    end # #abstract
+    
+  end
+end
index 1d47ed701ed5ec6c9c31ee00be9236e69b006e17..98294c49265f6a9ce4fdbb98cee7a444e0596993 100644 (file)
@@ -8,8 +8,8 @@ module ErdHandler
       undef_method :y
     end
 
-    describe "#contains?" do
-      it "reports when a box contains another" do 
+    describe '#contains?' do
+      it 'reports when a box contains another' do 
         b1 = Box.new 
         b1.x = 10 ; b1.y = 10 ; b1.width = 20 ; b1.height = 20
         b2 = Box.new ; b2.x =  5 ; b2.y =  5 ; b2.width = 30 ; b2.height = 30
@@ -22,8 +22,8 @@ module ErdHandler
       end
     end # contains?
 
-    describe "#within?" do
-      it "reports when a box is within another" do 
+    describe '#within?' do
+      it 'reports when a box is within another' do 
         b1 = Box.new 
         b1.x = 10 ; b1.y = 10 ; b1.width = 20 ; b1.height = 20
         b2 = Box.new ; b2.x =  5 ; b2.y =  5 ; b2.width = 30 ; b2.height = 30
@@ -38,12 +38,12 @@ module ErdHandler
       end
     end # within?
     
-    describe "#similarity" do
-      it "find the similarity of two boxes" do 
+    describe '#similarity' do
+      it 'find the similarity of two boxes' do 
         b1 = Box.new
-        b1.name = Label.new "box 1", true
+        b1.name = Label.new 'box 1', true
         b2 = Box.new
-        b2.name = Label.new "box 2", true
+        b2.name = Label.new 'box 2', true
         b1.similarity(b2).should be_within(0.005).of(0.75)
       end
     end
index 77d7ad2b42dbf19531a3684ea4a41cb23fbbcb31..aff330a79df793bca833d23d3113bf5268059466 100644 (file)
@@ -2,38 +2,35 @@ require 'spec_helper'
 
 module ErdHandler
   describe Erd do
-    let(:input) { double('input').as_null_object }
-    let(:output) { double('output').as_null_object }
-    let(:erd) { Erd.new(input, output) }
     
-    describe "#initialize" do
-      it "creates an empty ERD" do
+    describe '#initialize' do
+      it 'creates an empty ERD' do
         erd = Erd.new
         erd.mark.should be_nil
         erd.should have(0).vertices
         erd.should have(0).edges       
       end
       
-      it "reads and creates a single box" do
-        erd = Erd.new(File.new("spec/fixtures/single_box_erd.xml"))
+      it 'reads and creates a single box' do
+        erd = Erd.new(File.new('spec/fixtures/single_box_erd.xml'))
         erd.mark.should == 6.5
         erd.should have(1).vertices
         erd.should have(0).edges
       end
     end # #initialize
     
-    describe "#read" do
-      it "reads and creates a single box" do
+    describe '#read' do
+      it 'reads and creates a single box' do
         erd = Erd.new
-        erd.read(File.new("spec/fixtures/single_box_erd.xml"))
+        erd.read(File.new('spec/fixtures/single_box_erd.xml'))
         erd.mark.should == 6.5
         erd.should have(1).vertices
         erd.should have(0).edges
       end
 
-      it "reads and creates two boxes with an edge joining them" do
+      it 'reads and creates two boxes with an edge joining them' do
         erd = Erd.new
-        erd.read(File.new("spec/fixtures/two_boxes_one_link_erd.xml"))
+        erd.read(File.new('spec/fixtures/two_boxes_one_link_erd.xml'))
         erd.mark.should == 4.5
         erd.should have(2).vertices
         erd.should have(1).edges
@@ -52,9 +49,9 @@ module ErdHandler
         link.connection_at(b1).crowsfoot.should be(:no)
       end
       
-      it "reads and creates a box with a self-loop" do
+      it 'reads and creates a box with a self-loop' do
         erd = Erd.new
-        erd.read(File.new("spec/fixtures/single_box_self_loop_erd.xml"))
+        erd.read(File.new('spec/fixtures/single_box_self_loop_erd.xml'))
         erd.mark.should == 4.5
         erd.should have(1).vertices
         erd.should have(1).edges
@@ -71,9 +68,9 @@ module ErdHandler
         c1.should_not == c2
       end
 
-      it "reads and creates an ERD with subclassing" do
+      it 'reads and creates an ERD with subclassing' do
         erd = Erd.new
-        erd.read(File.new("spec/fixtures/two_boxes_one_contained_erd.xml"))
+        erd.read(File.new('spec/fixtures/two_boxes_one_contained_erd.xml'))
         erd.mark.should == 4.5
         erd.should have(2).vertices
         erd.should have(0).edges
@@ -85,70 +82,70 @@ module ErdHandler
         erd.vertices[1].should be_contains(erd.vertices[0])
       end
       
-      it "reads and creates full diagram" do
+      it 'reads and creates full diagram' do
         erd = Erd.new
-        erd.read(File.new("spec/fixtures/complex_erd.xml"))
+        erd.read(File.new('spec/fixtures/complex_erd.xml'))
         erd.mark.should == 4.0
         erd.should have(5).vertices
         erd.should have(6).edges
         
         b0 = erd.vertices.find {|b| b.id == 0}
-        b0.name.original.should == "Unit"
+        b0.name.original.should == 'Unit'
         b0.should have(2).neighbours
         
         b1 = erd.vertices.find {|b| b.id == 1}
-        b1.name.original.should == "Employee"
+        b1.name.original.should == 'Employee'
         b1.should have(2).neighbours
         
         b2 = erd.vertices.find {|b| b.id == 2}
-        b2.name.original.should == "Course"
+        b2.name.original.should == 'Course'
         b2.should have(3).neighbours
 
         b3 = erd.vertices.find {|b| b.id == 3}
-        b3.name.original.should == "Presentation"
+        b3.name.original.should == 'Presentation'
         b3.should have(3).neighbours
         
         b4 = erd.vertices.find {|b| b.id == 4}
-        b4.name.original.should == "Client"
+        b4.name.original.should == 'Client'
         b4.should have(1).neighbours
 
         l0 = erd.edges.find {|e| e.id == 0}
-        l0.name.original.should == "ConsistsOf"
+        l0.name.original.should == 'ConsistsOf'
         l0.connections.find {|c| c.end == b0}.blob.should be :closed
         l0.connections.find {|c| c.end == b0}.crowsfoot.should be :yes
         l0.connections.find {|c| c.end == b2}.blob.should be :closed
         l0.connections.find {|c| c.end == b2}.crowsfoot.should be :no
 
         l1 = erd.edges.find {|e| e.id == 1}
-        l1.name.original.should == "Prepares"
+        l1.name.original.should == 'Prepares'
         l1.connections.find {|c| c.end == b0}.blob.should be :open
         l1.connections.find {|c| c.end == b0}.crowsfoot.should be :yes
         l1.connections.find {|c| c.end == b1}.blob.should be :closed
         l1.connections.find {|c| c.end == b1}.crowsfoot.should be :no
 
         l2 = erd.edges.find {|e| e.id == 2}
-        l2.name.original.should == "Presents"
+        l2.name.original.should == 'Presents'
         l2.connections.find {|c| c.end == b1}.blob.should be :closed
         l2.connections.find {|c| c.end == b1}.crowsfoot.should be :no
         l2.connections.find {|c| c.end == b3}.blob.should be :closed
         l2.connections.find {|c| c.end == b3}.crowsfoot.should be :yes
 
         l3 = erd.edges.find {|e| e.id == 3}
-        l3.name.original.should == "Presented"
+        l3.name.original.should == 'Presented'
         l3.connections.find {|c| c.end == b2}.blob.should be :open
         l3.connections.find {|c| c.end == b2}.crowsfoot.should be :no
         l3.connections.find {|c| c.end == b3}.blob.should be :closed
         l3.connections.find {|c| c.end == b3}.crowsfoot.should be :yes
 
         l4 = erd.edges.find {|e| e.id == 4}
-        l4.name.original.should == "Recieves"
+        l4.name.original.should == 'Recieves'
         l4.connections.find {|c| c.end == b3}.blob.should be :closed
         l4.connections.find {|c| c.end == b3}.crowsfoot.should be :yes
         l4.connections.find {|c| c.end == b4}.blob.should be :closed
         l4.connections.find {|c| c.end == b4}.crowsfoot.should be :no
 
         l5 = erd.edges.find {|e| e.id == 5}
-        l5.name.original.should == "IsPrerequisiteOf"
+        l5.name.original.should == 'IsPrerequisiteOf'
         l5.connections.find {|c| c.crowsfoot == :yes}.blob.should be :open
         l5.connections.find {|c| c.crowsfoot == :no}.blob.should be :open
         l5.connections.find {|c| c.crowsfoot == :yes}.end.should be b2
@@ -156,10 +153,10 @@ module ErdHandler
       end
     end # #read
     
-    describe "#mmus" do
-      it "finds three MMUs in a simple ERD" do
+    describe '#mmus' do
+      it 'finds three MMUs in a simple ERD' do
         erd = Erd.new
-        erd.read(File.new("spec/fixtures/two_boxes_one_link_erd.xml"))
+        erd.read(File.new('spec/fixtures/two_boxes_one_link_erd.xml'))
         mmus = erd.mmus
         
         mmus.should have(3).items
@@ -183,9 +180,9 @@ module ErdHandler
         end
       end
       
-      it "finds many MMUs in a complex ERD" do
+      it 'finds many MMUs in a complex ERD' do
         erd = Erd.new
-        erd.read(File.new("spec/fixtures/complex_erd.xml"))
+        erd.read(File.new('spec/fixtures/complex_erd.xml'))
         mmus = erd.mmus
         
         mmus.should have(11).items
index 6f09b95e91336434dfbec22cc3b35bbdfd8ac2ae..e2364a095a1d13a047adaab3c85ad49a1bdedf43 100644 (file)
@@ -3,19 +3,19 @@ require 'spec_helper'
 module ErdHandler
   describe Label do
     describe '#initialize' do
-      it "should give an error if not given an original string" do
+      it 'should give an error if not given an original string' do
         # Label.new.should raise_error(ArgumentError)
         expect {Label.new}.to raise_error(ArgumentError)
       end
       
-      it "should create a copy of the original as the processed string" do
-        test_label = "Test label"
+      it 'should create a copy of the original as the processed string' do
+        test_label = 'Test label'
         l1 = Label.new test_label
         l1.original.should == test_label
       end
       
-      it "should tidy the processed string if asked" do
-        test_label = "testingLabeller string, he_pontificated"
+      it 'should tidy the processed string if asked' do
+        test_label = 'testingLabeller string, he_pontificated'
         l1 = Label.new test_label.dup, true
         l2 = Label.new test_label.dup
         l2.split.downcase.stem
@@ -24,18 +24,18 @@ module ErdHandler
     end # initialze
     
     describe '#original' do
-      it "reports the string it was initialised with" do
-        test_label = "Test label"
+      it 'reports the string it was initialised with' do
+        test_label = 'Test label'
         l1 = Label.new test_label
         l1.original.should == test_label
         #l1 = Label.new
-        #l1.original.should == ""
+        #l1.original.should == ''
       end
     end # original
 
     describe '#processed' do
-      it "reports the original if no processing has been done" do
-        test_label = "Test label"
+      it 'reports the original if no processing has been done' do
+        test_label = 'Test label'
         l1 = Label.new test_label
         l1.processed.should == [test_label]
         l1.original.should == test_label
@@ -43,124 +43,124 @@ module ErdHandler
     end # processed
 
     describe '#split' do
-      it "splits the original on the specified regexp" do
-        l1 = Label.new "Test label"
+      it 'splits the original on the specified regexp' do
+        l1 = Label.new 'Test label'
         l1.split(/ /)
-        l1.processed.should == ["Test", "label"]
-        l1.original.should == "Test label"
+        l1.processed.should == ['Test', 'label']
+        l1.original.should == 'Test label'
         
-        l1 = Label.new "Test_label"
+        l1 = Label.new 'Test_label'
         l1.split(/_/)
-        l1.processed.should == ["Test", "label"]
+        l1.processed.should == ['Test', 'label']
         
-        l1 = Label.new "Test label_string"
+        l1 = Label.new 'Test label_string'
         l1.split(/[ _]/)
-        l1.processed.should == ["Test", "label", "string"]
+        l1.processed.should == ['Test', 'label', 'string']
       end
       
-      it "splits the original on camel case" do
-        l1 = Label.new "TestLabel"
+      it 'splits the original on camel case' do
+        l1 = Label.new 'TestLabel'
         l1.split :camel_case => true
-        l1.processed.should == ["Test", "Label"]
-        l1.original.should == "TestLabel"
+        l1.processed.should == ['Test', 'Label']
+        l1.original.should == 'TestLabel'
 
-        l2 = Label.new "testLabel"
+        l2 = Label.new 'testLabel'
         l2.split :camel_case => true
-        l2.processed.should == ["test", "Label"]
-        l2.original.should == "testLabel"
+        l2.processed.should == ['test', 'Label']
+        l2.original.should == 'testLabel'
       end
 
-      it "doesn't split the original on camel case if asked not to" do
-        l1 = Label.new "TestLabel"
+      it 'does not split the original on camel case if asked not to' do
+        l1 = Label.new 'TestLabel'
         l1.split :camel_case => false
-        l1.processed.should == ["TestLabel"]
-        l1.original.should == "TestLabel"
+        l1.processed.should == ['TestLabel']
+        l1.original.should == 'TestLabel'
         
-        l2 = Label.new "TestLabel"
+        l2 = Label.new 'TestLabel'
         l2.split :camel_case => nil
-        l2.processed.should == ["TestLabel"]
-        l2.original.should == "TestLabel"
+        l2.processed.should == ['TestLabel']
+        l2.original.should == 'TestLabel'
       end
 
-      it "splits the original on numbers" do
-        l1 = Label.new "Test123Label"
+      it 'splits the original on numbers' do
+        l1 = Label.new 'Test123Label'
         l1.split :numbers => true
-        l1.processed.should == ["Test", "123", "Label"]
-        l1.original.should == "Test123Label"
+        l1.processed.should == ['Test', '123', 'Label']
+        l1.original.should == 'Test123Label'
 
-        l2 = Label.new "test1label"
+        l2 = Label.new 'test1label'
         l2.split :numbers => true
-        l2.processed.should == ["test", "1", "label"]
-        l2.original.should == "test1label"
+        l2.processed.should == ['test', '1', 'label']
+        l2.original.should == 'test1label'
       end
 
-      it "doesn't split the original on numbers if asked not to" do
-        l1 = Label.new "Test123Label"
+      it 'does not split the original on numbers if asked not to' do
+        l1 = Label.new 'Test123Label'
         l1.split :numbers => false
-        l1.processed.should == ["Test123Label"]
-        l1.original.should == "Test123Label"
+        l1.processed.should == ['Test123Label']
+        l1.original.should == 'Test123Label'
         
-        l2 = Label.new "Test123Label"
+        l2 = Label.new 'Test123Label'
         l2.split :numbers => nil
-        l2.processed.should == ["Test123Label"]
-        l2.original.should == "Test123Label"
+        l2.processed.should == ['Test123Label']
+        l2.original.should == 'Test123Label'
       end
       
-      it "splits the original using a default regexp" do
+      it 'splits the original using a default regexp' do
         l1 = Label.new "Test label_string\tfred"
         l1.split
-        l1.processed.should == ["Test", "label", "string", "fred"]
+        l1.processed.should == ['Test', 'label', 'string', 'fred']
       end
       
-      it "splits the original on camel case by default" do
-        l1 = Label.new "TestLabel"
+      it 'splits the original on camel case by default' do
+        l1 = Label.new 'TestLabel'
         l1.split
-        l1.processed.should == ["Test", "Label"]
-        l1.original.should == "TestLabel"
+        l1.processed.should == ['Test', 'Label']
+        l1.original.should == 'TestLabel'
       end
 
-      it "splits the original on numbers by default" do
-        l1 = Label.new "Test123Label"
+      it 'splits the original on numbers by default' do
+        l1 = Label.new 'Test123Label'
         l1.split
-        l1.processed.should == ["Test", "123", "Label"]
-        l1.original.should == "Test123Label"
+        l1.processed.should == ['Test', '123', 'Label']
+        l1.original.should == 'Test123Label'
       end
      
-      it "splits the original on punctuation, whitespace, camel case, and numbers by default" do
-        l1 = Label.new "TestLabel is_split, 123 he,said456Fred"
+      it 'splits the original on punctuation, whitespace, camel case, and numbers by default' do
+        l1 = Label.new 'TestLabel is_split, 123 he,said456Fred'
         l1.split
-        l1.processed.should == ["Test", "Label", "is", "split","123", "he", "said", "456", "Fred"]
-        l1.original.should == "TestLabel is_split, 123 he,said456Fred"
+        l1.processed.should == ['Test', 'Label', 'is', 'split','123', 'he', 'said', '456', 'Fred']
+        l1.original.should == 'TestLabel is_split, 123 he,said456Fred'
       end
 
-      it "is idempotent" do
-        l1 = Label.new "TestLabel is_split, 123 he,said456Fred"
+      it 'is idempotent' do
+        l1 = Label.new 'TestLabel is_split, 123 he,said456Fred'
         res1 = l1.split.dup
         res2 = l1.split
         res1.processed.should == res2.processed
-        l1.original.should == "TestLabel is_split, 123 he,said456Fred"
+        l1.original.should == 'TestLabel is_split, 123 he,said456Fred'
       end
     end # split
 
-    describe "#downcase" do
-      it "downcases all parts of the processed label" do
-        l1 = Label.new "Test label_string"
+    describe '#downcase' do
+      it 'downcases all parts of the processed label' do
+        l1 = Label.new 'Test label_string'
         l1.split.downcase
-        l1.processed.should == ["test", "label", "string"]
+        l1.processed.should == ['test', 'label', 'string']
       end
     end # downcase
     
-    describe "#stem" do
-      it "stems all parts of the processed label" do
-        l1 = Label.new "testing labeller string pontificated"
+    describe '#stem' do
+      it 'stems all parts of the processed label' do
+        l1 = Label.new 'testing labeller string pontificated'
         l1.split.stem
-        l1.processed.should == ["test", "label", "string", "pontif"]
+        l1.processed.should == ['test', 'label', 'string', 'pontif']
       end
     end # stem
     
-    describe "#tidy" do
-      it "tidies a label" do
-        l1 = Label.new "testingLabeller string, he_pontificated"
+    describe '#tidy' do
+      it 'tidies a label' do
+        l1 = Label.new 'testingLabeller string, he_pontificated'
         l2 = Label.new l1.original
         l1.tidy
         l2.split.downcase.stem
@@ -168,33 +168,33 @@ module ErdHandler
       end
     end # tidy
     
-    describe "#length" do
-      it "returns the length of the processed label" do
-        l1 = Label.new "testingLabeller string, he_pontificated"
+    describe '#length' do
+      it 'returns the length of the processed label' do
+        l1 = Label.new 'testingLabeller string, he_pontificated'
         l1.tidy
         l1.length.should == l1.processed.join('').length
       end
     end # length
     
-    describe "#levenshtein" do
-      it "calculates the Levenshtein distance of the processed string" do
-        l1 = Label.new "Fred"
-        l1.levenshtein("Fred").should == 0
-        l1.levenshtein("Free").should == 1
-        l1.levenshtein("").should == 4
-        l2 = Label.new ""
-        l2.levenshtein("Free").should == 4
-        l2.levenshtein("").should == 0
-        l3 = Label.new "meilenstein"
-        l3.levenshtein("levenshtein").should == 4
-        l4 = Label.new "testingLabeller string, he_pontificated"
-        l4.tidy.levenshtein("testlabelstringhepontif").should == 0
-        l4.tidy.levenshtein("testlabelXstringhepontif").should == 1
+    describe '#levenshtein' do
+      it 'calculates the Levenshtein distance of the processed string' do
+        l1 = Label.new 'Fred'
+        l1.levenshtein('Fred').should == 0
+        l1.levenshtein('Free').should == 1
+        l1.levenshtein('').should == 4
+        l2 = Label.new ''
+        l2.levenshtein('Free').should == 4
+        l2.levenshtein('').should == 0
+        l3 = Label.new 'meilenstein'
+        l3.levenshtein('levenshtein').should == 4
+        l4 = Label.new 'testingLabeller string, he_pontificated'
+        l4.tidy.levenshtein('testlabelstringhepontif').should == 0
+        l4.tidy.levenshtein('testlabelXstringhepontif').should == 1
       end
       
-      it "calculates the Levenshtein distance between Labels" do
-        l1 = Label.new "meilenstein"
-        l2 = Label.new "levenshtein"
+      it 'calculates the Levenshtein distance between Labels' do
+        l1 = Label.new 'meilenstein'
+        l2 = Label.new 'levenshtein'
         l1.levenshtein(l2).should == 4
       end
     end
index d0c7f1a3ee4762dc60a7bd38f996e4b6d4d3f996..b54e9f5ce10e24e397be2c9244293cf9f2862fd1 100644 (file)
@@ -1,10 +1,4 @@
 require 'simplecov'
 SimpleCov.start
 
-require 'rexml/document.rb'
-include REXML  
-
-require 'graph.njae'
-include GraphNjae
-
 require 'erd_handler'