eaglecad 0 → 1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +5 -1
- data/README.markdown +29 -0
- data/Rakefile +9 -0
- data/eaglecad.gemspec +4 -2
- data/lib/eaglecad.rb +15 -1
- data/lib/eaglecad/attribute.rb +47 -0
- data/lib/eaglecad/board.rb +184 -0
- data/lib/eaglecad/clearance.rb +31 -0
- data/lib/eaglecad/design_rules.rb +38 -0
- data/lib/eaglecad/deviceset.rb +113 -0
- data/lib/eaglecad/drawing.rb +124 -0
- data/lib/eaglecad/geometry.rb +259 -0
- data/lib/eaglecad/layer.rb +40 -0
- data/lib/eaglecad/library.rb +73 -0
- data/lib/eaglecad/package.rb +74 -0
- data/lib/eaglecad/part.rb +29 -0
- data/lib/eaglecad/schematic.rb +83 -0
- data/lib/eaglecad/sheet.rb +256 -0
- data/lib/eaglecad/symbol.rb +73 -0
- data/test/eaglecad.rb +12 -0
- data/test/eaglecad/board.rb +68 -0
- data/test/eaglecad/design_rules.rb +38 -0
- data/test/eaglecad/deviceset.rb +52 -0
- data/test/eaglecad/drawing.rb +94 -0
- data/test/eaglecad/library.rb +47 -0
- data/test/eaglecad/package.rb +60 -0
- data/test/eaglecad/schematic.rb +50 -0
- data/test/eaglecad/sheet.rb +24 -0
- data/test/eaglecad/symbol.rb +41 -0
- data/test/fixtures/board.xml +859 -0
- data/test/fixtures/demo1.sch +10932 -0
- data/test/fixtures/design_rules.xml +70 -0
- data/test/fixtures/deviceset.xml +683 -0
- data/test/fixtures/drawing_board.xml +910 -0
- data/test/fixtures/drawing_schematic.xml +10928 -0
- data/test/fixtures/hexapodu.brd +1863 -0
- data/test/fixtures/library.xml +175 -0
- data/test/fixtures/package.xml +28 -0
- data/test/fixtures/schematic.xml +10861 -0
- data/test/fixtures/sheet.xml +318 -0
- data/test/fixtures/symbol.xml +11 -0
- metadata +79 -5
- data/README.md +0 -29
data/test/eaglecad.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'eaglecad'
|
3
|
+
|
4
|
+
describe EagleCAD do
|
5
|
+
describe "when reading a schematic file" do
|
6
|
+
subject { EagleCAD.read('test/fixtures/demo1.sch') }
|
7
|
+
|
8
|
+
it "must return a Drawing object" do
|
9
|
+
subject.must_be_kind_of(EagleCAD::Drawing)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'eaglecad/board'
|
3
|
+
|
4
|
+
describe EagleCAD::Board do
|
5
|
+
describe "when initialized with an XML element" do
|
6
|
+
subject { EagleCAD::Board.from_xml(REXML::Document.new(File.open('test/fixtures/board.xml')).elements.first) }
|
7
|
+
|
8
|
+
it "must have a description" do
|
9
|
+
subject.description.must_equal 'Board Description'
|
10
|
+
end
|
11
|
+
|
12
|
+
it "must have the correct number of libraries" do
|
13
|
+
subject.libraries.size.must_equal 6
|
14
|
+
end
|
15
|
+
|
16
|
+
it "must have the correct number of elements" do
|
17
|
+
subject.elements.size.must_equal 12
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "when generating XML" do
|
21
|
+
let(:element) { subject.to_xml }
|
22
|
+
|
23
|
+
it "must generate a proper XML element" do
|
24
|
+
element.must_be_instance_of REXML::Element
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "when generating XML" do
|
29
|
+
let(:element) { subject.to_xml }
|
30
|
+
|
31
|
+
it "must generate a proper XML element" do
|
32
|
+
element.must_be_instance_of REXML::Element
|
33
|
+
end
|
34
|
+
|
35
|
+
it "must have a description" do
|
36
|
+
element.elements['description'].text.must_equal 'Board Description'
|
37
|
+
end
|
38
|
+
|
39
|
+
it "must have an attributes container" do
|
40
|
+
element.elements['attributes'].count.must_equal 0
|
41
|
+
end
|
42
|
+
|
43
|
+
it "must have an autorouter container" do
|
44
|
+
element.elements['autorouter'].count.must_equal 4
|
45
|
+
end
|
46
|
+
|
47
|
+
it "must have a classes container" do
|
48
|
+
element.elements['classes'].count.must_equal 2
|
49
|
+
end
|
50
|
+
|
51
|
+
it "must have a designrules container" do
|
52
|
+
element.elements['designrules'].count.must_equal 68
|
53
|
+
end
|
54
|
+
|
55
|
+
it "must have an elements container" do
|
56
|
+
element.elements['elements'].count.must_equal 12
|
57
|
+
end
|
58
|
+
|
59
|
+
it "must have a libraries container" do
|
60
|
+
element.elements['libraries'].count.must_equal 6
|
61
|
+
end
|
62
|
+
|
63
|
+
it "must have a plan container" do
|
64
|
+
element.elements['plain'].count.must_equal 4
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'eaglecad/design_rules'
|
3
|
+
|
4
|
+
describe EagleCAD::DesignRules do
|
5
|
+
subject { EagleCAD::DesignRules.from_xml(REXML::Document.new(File.open('test/fixtures/design_rules.xml')).elements.first) }
|
6
|
+
|
7
|
+
it "must have a name" do
|
8
|
+
subject.name.must_equal 'Name'
|
9
|
+
end
|
10
|
+
|
11
|
+
it "must have a description" do
|
12
|
+
subject.description.must_equal 'Design Rule Description'
|
13
|
+
end
|
14
|
+
|
15
|
+
it "must have the correct number of parameters" do
|
16
|
+
subject.parameters.size.must_equal 67
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "when generating XML" do
|
20
|
+
let(:element) { subject.to_xml }
|
21
|
+
|
22
|
+
it "must generate a proper XML element" do
|
23
|
+
element.must_be_instance_of REXML::Element
|
24
|
+
end
|
25
|
+
|
26
|
+
it "must have a name attribute" do
|
27
|
+
element.attributes['name'].must_equal 'Name'
|
28
|
+
end
|
29
|
+
|
30
|
+
it "must have a description element" do
|
31
|
+
element.elements['description'].text.must_equal 'Design Rule Description'
|
32
|
+
end
|
33
|
+
|
34
|
+
it "must have parameter elements" do
|
35
|
+
element.get_elements('param').count.must_equal 67
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'eaglecad/deviceset'
|
3
|
+
|
4
|
+
describe EagleCAD::DeviceSet do
|
5
|
+
subject { EagleCAD::DeviceSet.from_xml(REXML::Document.new(File.open('test/fixtures/deviceset.xml')).elements.first) }
|
6
|
+
|
7
|
+
it "must have a name" do
|
8
|
+
subject.name.must_equal 'C-EU'
|
9
|
+
end
|
10
|
+
|
11
|
+
it "must have a prefix" do
|
12
|
+
subject.prefix.must_equal 'C'
|
13
|
+
end
|
14
|
+
|
15
|
+
it "must have a uservalue" do
|
16
|
+
subject.uservalue.must_equal true
|
17
|
+
end
|
18
|
+
|
19
|
+
it "must have a description" do
|
20
|
+
subject.description.must_equal '<B>CAPACITOR</B>, European symbol'
|
21
|
+
end
|
22
|
+
|
23
|
+
it "must have the correct number of devices" do
|
24
|
+
subject.devices.size.must_equal 75
|
25
|
+
end
|
26
|
+
|
27
|
+
it "must have the correct number of gates" do
|
28
|
+
subject.gates.size.must_equal 1
|
29
|
+
subject.gates.first.name.must_equal 'G$1'
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "when generating XML" do
|
33
|
+
subject { EagleCAD::DeviceSet.from_xml(REXML::Document.new(File.open('test/fixtures/deviceset.xml')).elements.first).to_xml }
|
34
|
+
|
35
|
+
it "must generate an XML element" do
|
36
|
+
subject.must_be_instance_of REXML::Element
|
37
|
+
end
|
38
|
+
|
39
|
+
it "must have a Devices container element" do
|
40
|
+
subject.elements['devices'].count.must_equal 75
|
41
|
+
end
|
42
|
+
|
43
|
+
it "must have a Description element" do
|
44
|
+
subject.elements['description'].wont_be_nil
|
45
|
+
subject.elements['description'].text.must_equal '<B>CAPACITOR</B>, European symbol'
|
46
|
+
end
|
47
|
+
|
48
|
+
it "must have a Gates container element" do
|
49
|
+
subject.elements['gates'].count.must_equal 1
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'eaglecad/drawing'
|
3
|
+
|
4
|
+
describe EagleCAD::Drawing do
|
5
|
+
describe "when initialized with an XML element containing a Schematic" do
|
6
|
+
subject { EagleCAD::Drawing.from_xml(REXML::Document.new(File.open('test/fixtures/drawing_schematic.xml')).elements.first) }
|
7
|
+
|
8
|
+
it "must set the vector font property" do
|
9
|
+
subject.always_vector_font.must_equal true
|
10
|
+
end
|
11
|
+
|
12
|
+
it "must set the vertical text property" do
|
13
|
+
subject.vertical_text.must_equal :up
|
14
|
+
end
|
15
|
+
|
16
|
+
it "must have the correct number of layers" do
|
17
|
+
subject.layers.size.must_equal 59
|
18
|
+
end
|
19
|
+
|
20
|
+
it "must have a schematic" do
|
21
|
+
subject.schematic.must_be_instance_of(EagleCAD::Schematic)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "when initialized with an XML element containing a Board" do
|
26
|
+
subject { EagleCAD::Drawing.from_xml(REXML::Document.new(File.open('test/fixtures/drawing_board.xml')).elements.first) }
|
27
|
+
|
28
|
+
it "must have a Board" do
|
29
|
+
subject.board.must_be_instance_of(EagleCAD::Board)
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "when generating XML" do
|
33
|
+
let(:element) { subject.to_xml }
|
34
|
+
|
35
|
+
it "must generate a proper XML element" do
|
36
|
+
element.must_be_instance_of REXML::Element
|
37
|
+
end
|
38
|
+
|
39
|
+
it "must have a settings element" do
|
40
|
+
element.get_elements('settings').count.must_equal 1
|
41
|
+
element.get_elements('settings').first.must_be_instance_of(REXML::Element)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "must have a grid element" do
|
45
|
+
element.get_elements('grid').count.must_equal 1
|
46
|
+
end
|
47
|
+
|
48
|
+
it "must have a layers container element" do
|
49
|
+
element.get_elements('layers').count.must_equal 1
|
50
|
+
end
|
51
|
+
|
52
|
+
it "must have the correct number of layers" do
|
53
|
+
element.get_elements('layers').first.get_elements('layer').count.must_equal 43
|
54
|
+
end
|
55
|
+
|
56
|
+
it "must have a Board" do
|
57
|
+
element.elements['board'].wont_be_nil
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "when the Drawing has only a Schematic" do
|
63
|
+
subject { EagleCAD::Drawing.from_xml(REXML::Document.new(File.open('test/fixtures/drawing_schematic.xml')).elements.first) }
|
64
|
+
|
65
|
+
describe "when generating XML" do
|
66
|
+
let(:element) { subject.to_xml }
|
67
|
+
|
68
|
+
it "must generate a proper XML element" do
|
69
|
+
element.must_be_instance_of REXML::Element
|
70
|
+
end
|
71
|
+
|
72
|
+
it "must have a settings element" do
|
73
|
+
element.get_elements('settings').count.must_equal 1
|
74
|
+
element.get_elements('settings').first.must_be_instance_of(REXML::Element)
|
75
|
+
end
|
76
|
+
|
77
|
+
it "must have a grid element" do
|
78
|
+
element.get_elements('grid').count.must_equal 1
|
79
|
+
end
|
80
|
+
|
81
|
+
it "must have a layers container element" do
|
82
|
+
element.get_elements('layers').count.must_equal 1
|
83
|
+
end
|
84
|
+
|
85
|
+
it "must have the correct number of layers" do
|
86
|
+
element.get_elements('layers').first.get_elements('layer').count.must_equal 59
|
87
|
+
end
|
88
|
+
|
89
|
+
it "must have a Schematic" do
|
90
|
+
element.get_elements('schematic').count.must_equal 1
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'eaglecad/library'
|
3
|
+
|
4
|
+
describe EagleCAD::Library do
|
5
|
+
subject { EagleCAD::Library.from_xml(REXML::Document.new(File.open('test/fixtures/library.xml')).elements.first) }
|
6
|
+
|
7
|
+
it "must have a name" do
|
8
|
+
subject.name.must_equal 'microchip'
|
9
|
+
end
|
10
|
+
|
11
|
+
it "must not have a description" do
|
12
|
+
subject.description.must_be_nil
|
13
|
+
end
|
14
|
+
|
15
|
+
it "must have the correct number of device sets" do
|
16
|
+
subject.device_sets.size.must_equal 1
|
17
|
+
end
|
18
|
+
|
19
|
+
it "must have the correct number of packages" do
|
20
|
+
subject.packages.size.must_equal 2
|
21
|
+
end
|
22
|
+
|
23
|
+
it "must have the correct number of symbols" do
|
24
|
+
subject.symbols.size.must_equal 1
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "when generating XML" do
|
28
|
+
subject { EagleCAD::Library.from_xml(REXML::Document.new(File.open('test/fixtures/library.xml')).elements.first).to_xml }
|
29
|
+
|
30
|
+
it "must generate an XML element" do
|
31
|
+
subject.must_be_instance_of REXML::Element
|
32
|
+
end
|
33
|
+
|
34
|
+
it "must have a Device Sets container element" do
|
35
|
+
subject.get_elements('devicesets').count.must_equal 1
|
36
|
+
subject.elements['devicesets'].wont_be_nil
|
37
|
+
end
|
38
|
+
|
39
|
+
it "must have a Packages container element" do
|
40
|
+
subject.get_elements('packages').count.must_equal 1
|
41
|
+
end
|
42
|
+
|
43
|
+
it "must have a Symbols container element" do
|
44
|
+
subject.get_elements('symbols').count.must_equal 1
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'eaglecad/package'
|
3
|
+
|
4
|
+
describe EagleCAD::Package do
|
5
|
+
Package = EagleCAD::Package
|
6
|
+
|
7
|
+
describe "when initialized with an XML element" do
|
8
|
+
subject { Package.from_xml(REXML::Document.new(File.open('test/fixtures/package.xml')).elements.first) }
|
9
|
+
|
10
|
+
it "must have a name" do
|
11
|
+
subject.name.must_equal 'C0402'
|
12
|
+
end
|
13
|
+
|
14
|
+
it "must have a description" do
|
15
|
+
subject.description.must_equal '<b>CAPACITOR</b><p>chip'
|
16
|
+
end
|
17
|
+
|
18
|
+
it "must have the correct number of layers" do
|
19
|
+
subject.layers.size.must_equal 7
|
20
|
+
end
|
21
|
+
|
22
|
+
it "must have the correct layers" do
|
23
|
+
subject.layers[1].size.must_equal 2
|
24
|
+
subject.layers[21].size.must_equal 1
|
25
|
+
subject.layers[25].size.must_equal 1
|
26
|
+
subject.layers[27].size.must_equal 1
|
27
|
+
subject.layers[35].size.must_equal 1
|
28
|
+
subject.layers[39].size.must_equal 4
|
29
|
+
subject.layers[51].size.must_equal 5
|
30
|
+
end
|
31
|
+
|
32
|
+
it "must have the correct holes" do
|
33
|
+
subject.holes.size.must_equal 1
|
34
|
+
end
|
35
|
+
|
36
|
+
it "must have the correct pads" do
|
37
|
+
subject.pads.size.must_equal 1
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "when generating XML" do
|
42
|
+
subject { Package.from_xml(REXML::Document.new(File.open('test/fixtures/package.xml')).elements.first).to_xml }
|
43
|
+
|
44
|
+
it "must generate an XML element" do
|
45
|
+
subject.must_be_instance_of REXML::Element
|
46
|
+
end
|
47
|
+
|
48
|
+
it "must have the correct name attribute" do
|
49
|
+
subject.attributes['name'].must_equal 'C0402'
|
50
|
+
end
|
51
|
+
|
52
|
+
it "must have a description element" do
|
53
|
+
subject.elements['description'].text.must_equal '<b>CAPACITOR</b><p>chip'
|
54
|
+
end
|
55
|
+
|
56
|
+
it "must have the correct number of children" do
|
57
|
+
subject.elements.count.must_equal 18
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'eaglecad/schematic'
|
3
|
+
|
4
|
+
describe EagleCAD::Schematic do
|
5
|
+
describe "when initialized with an XML element" do
|
6
|
+
subject { EagleCAD::Schematic.from_xml(REXML::Document.new(File.open('test/fixtures/schematic.xml')).elements.first) }
|
7
|
+
|
8
|
+
it "must have a description" do
|
9
|
+
subject.description.must_equal 'Schematic Description'
|
10
|
+
end
|
11
|
+
|
12
|
+
it "must have the correct number of attributes" do
|
13
|
+
subject.attributes.count.must_equal 0
|
14
|
+
end
|
15
|
+
|
16
|
+
it "must have the correct number of clearance classes" do
|
17
|
+
subject.classes.size.must_equal 2
|
18
|
+
end
|
19
|
+
|
20
|
+
it "must have the correct number of libraries" do
|
21
|
+
subject.libraries.count.must_equal 8
|
22
|
+
end
|
23
|
+
|
24
|
+
it "must have the correct number of parts" do
|
25
|
+
subject.parts.size.must_equal 27
|
26
|
+
end
|
27
|
+
|
28
|
+
it "must have the correct number of sheets" do
|
29
|
+
subject.sheets.size.must_equal 1
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "when generating XML" do
|
34
|
+
subject { EagleCAD::Schematic.from_xml(REXML::Document.new(File.open('test/fixtures/schematic.xml')).elements.first).to_xml }
|
35
|
+
|
36
|
+
it "must generate an XML element" do
|
37
|
+
subject.must_be_instance_of REXML::Element
|
38
|
+
end
|
39
|
+
|
40
|
+
it "must have a libraries container element" do
|
41
|
+
subject.get_elements('libraries').count.must_equal 1
|
42
|
+
end
|
43
|
+
|
44
|
+
it "must have the correct libraries" do
|
45
|
+
library_element = subject.get_elements('libraries').first.first
|
46
|
+
library_element.must_be_instance_of REXML::Element
|
47
|
+
library_element.attributes['name'].must_equal 'rcl'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'eaglecad/sheet'
|
3
|
+
|
4
|
+
describe EagleCAD::Sheet do
|
5
|
+
describe "when initialized with an XML element" do
|
6
|
+
subject { EagleCAD::Sheet.from_xml(REXML::Document.new(File.open('test/fixtures/sheet.xml')).elements.first) }
|
7
|
+
|
8
|
+
it "must have a description" do
|
9
|
+
subject.description.must_equal 'Sheet Description'
|
10
|
+
end
|
11
|
+
|
12
|
+
it "must have the correct number of busses" do
|
13
|
+
subject.busses.size.must_equal 1
|
14
|
+
end
|
15
|
+
|
16
|
+
it "must have the correct number of instances" do
|
17
|
+
subject.instances.size.must_equal 28
|
18
|
+
end
|
19
|
+
|
20
|
+
it "must have the correct number of nets" do
|
21
|
+
subject.nets.size.must_equal 21
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|