diff --git a/.gitignore b/.gitignore index d87d4be..8f994bd 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,6 @@ .bundle .config .yardoc -Gemfile.lock InstalledFiles _yardoc coverage diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..411557d --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,40 @@ +GIT + remote: git://github.com/bfoz/sketch.git + revision: 1f7977e3f93d801a6a970e74508510055ed2e12e + specs: + sketch (0.4) + geometry (~> 6.4) + +GIT + remote: git://github.com/bfoz/units-ruby.git + revision: e198cdb4e6978676b9e131ff8540b44aa7f57595 + specs: + units (3.0.1) + +PATH + remote: . + specs: + dxf (0.3.1) + geometry (~> 6.4) + sketch (~> 0.4) + units (~> 3.0) + +GEM + remote: https://rubygems.org/ + specs: + geometry (6.5) + minitest (5.9.0) + rake (11.2.2) + +PLATFORMS + ruby + +DEPENDENCIES + dxf! + minitest + rake + sketch! + units! + +BUNDLED WITH + 1.12.5 diff --git a/lib/dxf/entity.rb b/lib/dxf/entity.rb index e4284d9..d8226af 100644 --- a/lib/dxf/entity.rb +++ b/lib/dxf/entity.rb @@ -13,6 +13,7 @@ class Entity attr_accessor :handle attr_accessor :layer + attr_accessor :color_number def self.new(type) case type @@ -30,9 +31,11 @@ def parse_pair(code, value) # These are from the table that starts on page 70 of specification case code when '5' - handle = value + self.handle = value when '8' - layer = value + self.layer = value + when '62' + self.color_number = value.to_i else p "Unrecognized entity group code: #{code} #{value}" end diff --git a/lib/dxf/parser.rb b/lib/dxf/parser.rb index cccbdcd..20db5be 100644 --- a/lib/dxf/parser.rb +++ b/lib/dxf/parser.rb @@ -245,4 +245,4 @@ def to_entity end end end -end \ No newline at end of file +end diff --git a/lib/dxf/unparser.rb b/lib/dxf/unparser.rb index cfbb25d..34652aa 100644 --- a/lib/dxf/unparser.rb +++ b/lib/dxf/unparser.rb @@ -106,4 +106,4 @@ def unparse(output, sketch) [0, 'EOF']).join("\n") end end -end \ No newline at end of file +end diff --git a/test/dxf/parser.rb b/test/dxf/parser.rb index a3b6fff..35c48da 100644 --- a/test/dxf/parser.rb +++ b/test/dxf/parser.rb @@ -12,6 +12,7 @@ circle = parser.entities.last circle.must_be_instance_of(DXF::Circle) circle.center.must_equal Geometry::Point[0,0] + circle.layer.must_equal '0' circle.radius.must_equal 1 end @@ -25,6 +26,7 @@ arc.radius.must_equal 1 arc.start_angle.must_equal 180.0 arc.end_angle.must_equal 270.0 + arc.layer.must_equal '0' end it 'must parse a file with a translated circle' do @@ -34,6 +36,7 @@ circle.must_be_instance_of(DXF::Circle) circle.center.must_equal Geometry::Point[1,1] circle.radius.must_equal 1 + circle.layer.must_equal '0' end it 'must parse a file with a lightweight polyline' do @@ -50,6 +53,8 @@ line.must_be_instance_of(DXF::Line) line.first.must_equal Geometry::Point[0, 1] line.last.must_equal Geometry::Point[0, 0] + parser.entities.first.layer.must_equal 'testing' + parser.entities.first.color_number.must_equal 254 end it 'must parse a file with a spline' do diff --git a/test/fixtures/square_inches.dxf b/test/fixtures/square_inches.dxf index d4cfabc..a394c01 100644 --- a/test/fixtures/square_inches.dxf +++ b/test/fixtures/square_inches.dxf @@ -11,7 +11,7 @@ ENTITIES 0 LINE 8 -0 +testing 10 0 20 @@ -20,6 +20,8 @@ LINE 1 21 0 +62 +254 0 LINE 8 @@ -59,4 +61,4 @@ LINE 0 ENDSEC 0 -EOF \ No newline at end of file +EOF