microstation 0.8.5 → 0.8.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +26 -29
- data/Rakefile +45 -44
- data/bin/dgn2pdf +5 -6
- data/bin/dgn_template +23 -25
- data/bin/pw_print +11 -13
- data/cad_files/drawing_no_block.dgn +0 -0
- data/cad_files/drawing_with_3_block.dgn +0 -0
- data/cad_files/drawing_with_block.dgn +0 -0
- data/cad_files/drawing_with_text.dgn +0 -0
- data/lib/microstation/app.rb +91 -87
- data/lib/microstation/cad_input_queue.rb +10 -20
- data/lib/microstation/cell.rb +6 -18
- data/lib/microstation/changer.rb +3 -3
- data/lib/microstation/configuration.rb +33 -50
- data/lib/microstation/criteria_creation_t.rb +4 -8
- data/lib/microstation/dir.rb +27 -59
- data/lib/microstation/directory.rb +2 -7
- data/lib/microstation/drawing.rb +103 -102
- data/lib/microstation/element.rb +55 -68
- data/lib/microstation/enumerator.rb +4 -9
- data/lib/microstation/errors.rb +0 -5
- data/lib/microstation/event_handler.rb +1 -5
- data/lib/microstation/ext/pathname.rb +12 -14
- data/lib/microstation/ext/win32ole.rb +0 -2
- data/lib/microstation/extensions/faa.rb +12 -34
- data/lib/microstation/file_tests.rb +15 -50
- data/lib/microstation/functions.rb +10 -20
- data/lib/microstation/graphics.rb +6 -13
- data/lib/microstation/line.rb +2 -6
- data/lib/microstation/model.rb +11 -20
- data/lib/microstation/model_trait.rb +40 -40
- data/lib/microstation/ole_cad_input_message.rb +25 -34
- data/lib/microstation/ole_helper.rb +58 -66
- data/lib/microstation/pdf_support.rb +7 -16
- data/lib/microstation/point3d.rb +17 -30
- data/lib/microstation/primitive_command_interface.rb +8 -14
- data/lib/microstation/properties.rb +29 -17
- data/lib/microstation/property_handler.rb +6 -8
- data/lib/microstation/scan/color.rb +1 -8
- data/lib/microstation/scan/criteria.rb +17 -33
- data/lib/microstation/scan/klass.rb +8 -12
- data/lib/microstation/scan/level.rb +2 -9
- data/lib/microstation/scan/line_style.rb +4 -12
- data/lib/microstation/scan/line_weight.rb +1 -3
- data/lib/microstation/scan/range.rb +2 -8
- data/lib/microstation/scan/scan_trait.rb +48 -51
- data/lib/microstation/scan/subtype.rb +0 -10
- data/lib/microstation/scan/type.rb +9 -15
- data/lib/microstation/scan_trait.rb +13 -20
- data/lib/microstation/scanner.rb +1 -11
- data/lib/microstation/tag.rb +12 -21
- data/lib/microstation/tag_set.rb +52 -71
- data/lib/microstation/tag_set_trait.rb +6 -10
- data/lib/microstation/tagged_element.rb +16 -28
- data/lib/microstation/template.rb +15 -14
- data/lib/microstation/template_info.rb +35 -49
- data/lib/microstation/template_runner.rb +14 -22
- data/lib/microstation/text.rb +15 -19
- data/lib/microstation/text_node.rb +17 -26
- data/lib/microstation/ts/attribute.rb +16 -20
- data/lib/microstation/ts/instance.rb +28 -38
- data/lib/microstation/ts/tagset_trait.rb +5 -12
- data/lib/microstation/types.rb +0 -3
- data/lib/microstation/version.rb +1 -3
- data/lib/microstation/wrap.rb +3 -10
- data/lib/microstation.rb +57 -72
- data/spec/microstation/app_spec.rb +49 -46
- data/spec/microstation/configuration_spec.rb +45 -43
- data/spec/microstation/drawing_spec.rb +103 -101
- data/spec/microstation/functions_spec.rb +18 -12
- data/spec/microstation/tag_set_spec.rb +57 -55
- data/spec/microstation/template_spec.rb +41 -42
- data/spec/microstation/text_node_spec.rb +16 -14
- data/spec/microstation/text_spec.rb +10 -8
- data/spec/microstation_spec.rb +18 -17
- data/spec/spec_helper.rb +18 -18
- metadata +36 -22
@@ -1,13 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative "../spec_helper"
|
4
4
|
|
5
|
-
$LOAD_PATH.unshift(File.join(__dir__,
|
5
|
+
$LOAD_PATH.unshift(File.join(__dir__, "../lib"))
|
6
6
|
|
7
7
|
# require 'minitest/spec'
|
8
8
|
# require 'minitest/autorun'
|
9
9
|
|
10
|
-
describe
|
10
|
+
describe "Lets start the Microstation once" do
|
11
11
|
include Minitest::Hooks
|
12
12
|
before(:all) do
|
13
13
|
@app = Microstation::App.new
|
@@ -15,75 +15,77 @@ describe 'Lets start the Microstation once' do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
after(:all) do
|
18
|
-
@app.quit
|
18
|
+
@app.quit
|
19
|
+
rescue
|
20
|
+
nil
|
19
21
|
end
|
20
22
|
|
21
|
-
describe
|
22
|
-
let(:drawing) { new_drawing(
|
23
|
+
describe "a drawing created with app.new drawing" do
|
24
|
+
let(:drawing) { new_drawing("temp.dgn", seedfile: "seed2d") }
|
23
25
|
|
24
|
-
it
|
26
|
+
it "should be active drawing" do
|
25
27
|
_(drawing).must_be :active?
|
26
28
|
end
|
27
29
|
|
28
|
-
it
|
30
|
+
it "should have an ole_obj" do
|
29
31
|
_(drawing.ole_obj).must_be_instance_of WIN32OLE
|
30
32
|
end
|
31
33
|
|
32
|
-
describe
|
34
|
+
describe "#author" do
|
33
35
|
it "should be '' for new drawing" do
|
34
36
|
skip
|
35
|
-
_(drawing.author).must_equal
|
37
|
+
_(drawing.author).must_equal ""
|
36
38
|
end
|
37
39
|
|
38
|
-
it
|
39
|
-
drawing.author =
|
40
|
-
_(drawing.author).must_equal
|
40
|
+
it "should set author if given a new author" do
|
41
|
+
drawing.author = "A newer author"
|
42
|
+
_(drawing.author).must_equal "A newer author"
|
41
43
|
end
|
42
44
|
end
|
43
45
|
|
44
|
-
describe
|
46
|
+
describe "#title" do
|
45
47
|
it "should be '' to start" do
|
46
|
-
expect(drawing.title).must_equal(
|
48
|
+
expect(drawing.title).must_equal("")
|
47
49
|
end
|
48
50
|
|
49
|
-
it
|
50
|
-
drawing.title =
|
51
|
-
expect(drawing.title).must_equal
|
51
|
+
it "should set title if given a new title" do
|
52
|
+
drawing.title = "a new title"
|
53
|
+
expect(drawing.title).must_equal "a new title"
|
52
54
|
end
|
53
55
|
end
|
54
56
|
|
55
|
-
describe
|
56
|
-
it
|
57
|
-
_(drawing.keywords).must_equal
|
57
|
+
describe "#keywords" do
|
58
|
+
it "should be empty string to start" do
|
59
|
+
_(drawing.keywords).must_equal ""
|
58
60
|
end
|
59
61
|
|
60
|
-
it
|
61
|
-
drawing.keywords =
|
62
|
-
_(drawing.keywords).must_equal
|
62
|
+
it "should set keywords if given a string of words" do
|
63
|
+
drawing.keywords = "project, rcl, new"
|
64
|
+
_(drawing.keywords).must_equal "project, rcl, new"
|
63
65
|
end
|
64
66
|
end
|
65
67
|
|
66
|
-
describe
|
67
|
-
it
|
68
|
-
_(drawing.comments).must_equal
|
68
|
+
describe "#comments" do
|
69
|
+
it "should be nil to start" do
|
70
|
+
_(drawing.comments).must_equal ""
|
69
71
|
end
|
70
72
|
|
71
|
-
it
|
72
|
-
drawing.comments =
|
73
|
-
_(drawing.comments).must_equal
|
73
|
+
it "should be able to be set" do
|
74
|
+
drawing.comments = "these are comments"
|
75
|
+
_(drawing.comments).must_equal "these are comments"
|
74
76
|
end
|
75
77
|
end
|
76
78
|
|
77
|
-
it
|
79
|
+
it "should be able to save as pdf" do
|
78
80
|
drawing.save_as_pdf
|
79
81
|
end
|
80
82
|
|
81
|
-
describe
|
82
|
-
it
|
83
|
+
describe "revision count" do
|
84
|
+
it "should have a revision_count" do
|
83
85
|
_(drawing).must_respond_to(:revision_count)
|
84
86
|
end
|
85
87
|
|
86
|
-
it
|
88
|
+
it "should forward revision count to ole_obj" do
|
87
89
|
skip
|
88
90
|
ole = drawing.ole_obj
|
89
91
|
ole.stub :DesignRevisionCount, true do
|
@@ -92,38 +94,38 @@ describe 'Lets start the Microstation once' do
|
|
92
94
|
end
|
93
95
|
end
|
94
96
|
|
95
|
-
describe
|
96
|
-
describe
|
97
|
-
it
|
98
|
-
drawing.stub(:name,
|
99
|
-
_(drawing.pdf_name.to_s).must_equal
|
97
|
+
describe "pdf_name" do
|
98
|
+
describe "with no args" do
|
99
|
+
it "should equal the drawing path with ext changed" do
|
100
|
+
drawing.stub(:name, "Drawing Name.dgn") do
|
101
|
+
_(drawing.pdf_name.to_s).must_equal "Drawing Name.pdf"
|
100
102
|
end
|
101
103
|
end
|
102
104
|
end
|
103
105
|
|
104
|
-
describe
|
105
|
-
it
|
106
|
-
_(drawing.pdf_name(
|
106
|
+
describe "with arg for name" do
|
107
|
+
it "should equal the arg and the current directory" do
|
108
|
+
_(drawing.pdf_name("my_drawing").to_s).must_equal("my_drawing.pdf")
|
107
109
|
end
|
108
110
|
end
|
109
111
|
end
|
110
112
|
|
111
|
-
describe
|
112
|
-
it
|
113
|
+
describe "save_as_pdf" do
|
114
|
+
it "should find the pdf name with pdf_name rules" do
|
113
115
|
skip
|
114
116
|
path = drawing.path
|
115
|
-
_(drawing).to receive(:pdf_name).with(
|
116
|
-
drawing.save_as_pdf(
|
117
|
+
_(drawing).to receive(:pdf_name).with("testfile", nil)
|
118
|
+
drawing.save_as_pdf("testfile")
|
117
119
|
end
|
118
120
|
end
|
119
121
|
|
120
|
-
describe
|
121
|
-
it
|
122
|
+
describe "scanning" do
|
123
|
+
it "should have a #create_scanner" do
|
122
124
|
scanner = drawing.create_scanner(:test)
|
123
125
|
_(scanner).must_be_instance_of Microstation::Scan::Criteria
|
124
126
|
end
|
125
127
|
|
126
|
-
it
|
128
|
+
it "should scan the drawing" do
|
127
129
|
scanner = drawing.create_scanner(:test) do |scan|
|
128
130
|
_(scan).must_be_instance_of Microstation::Scan::Criteria
|
129
131
|
end
|
@@ -131,111 +133,111 @@ describe 'Lets start the Microstation once' do
|
|
131
133
|
end
|
132
134
|
end
|
133
135
|
|
134
|
-
describe
|
135
|
-
it
|
136
|
+
describe "#scan_text" do
|
137
|
+
it "only yields textual items" do
|
136
138
|
drawing.scan_text do |item|
|
137
139
|
_(item.class).must_equal(Microstation::Text || Microstation::TextNode)
|
138
140
|
end
|
139
141
|
end
|
140
142
|
end
|
141
143
|
|
142
|
-
describe
|
143
|
-
describe
|
144
|
+
describe "#update_tagset" do
|
145
|
+
describe "when 1 block exists" do
|
144
146
|
end
|
145
147
|
|
146
|
-
describe
|
147
|
-
let(:drawing) { new_drawing(
|
148
|
+
describe "when 1 block not in default drawing" do
|
149
|
+
let(:drawing) { new_drawing("test.dgn", seedfile: "drawing_faatitle_in_non_default_model.dgn") }
|
148
150
|
let(:app) { @app }
|
149
151
|
|
150
|
-
it
|
152
|
+
it "finds tagsets in drawing" do
|
151
153
|
tagsets = drawing.tagsets_in_drawing.to_a
|
152
154
|
_(tagsets.size).must_be :>, 0
|
153
155
|
end
|
154
156
|
|
155
|
-
it
|
156
|
-
ts = drawing.find_tagset_instance_by_name(
|
157
|
-
ts_title = ts[
|
158
|
-
_(ts_title).must_equal(
|
159
|
-
drawing.update_tagset(
|
160
|
-
ts = drawing.find_tagset_instance_by_name(
|
161
|
-
_(ts[
|
157
|
+
it "updates tagset" do
|
158
|
+
ts = drawing.find_tagset_instance_by_name("faatitle")
|
159
|
+
ts_title = ts["title1"].to_s
|
160
|
+
_(ts_title).must_equal("TITLE 1")
|
161
|
+
drawing.update_tagset("faatitle", {"title1" => "MY NEW TITLE"})
|
162
|
+
ts = drawing.find_tagset_instance_by_name("faatitle")
|
163
|
+
_(ts["title1"].to_s).must_equal("MY NEW TITLE")
|
162
164
|
end
|
163
165
|
end
|
164
|
-
describe
|
165
|
-
let(:drawing) { new_drawing(
|
166
|
-
let(:panel_atts) { {
|
166
|
+
describe "when multiple blocks" do
|
167
|
+
let(:drawing) { new_drawing("test.dgn", seedfile: "drawing_with_3_block.dgn") }
|
168
|
+
let(:panel_atts) { {"brk_1_service" => "OUTLETS", "brk_2_service" => "AIR CONDITIONER"} }
|
167
169
|
let(:app) { @app }
|
168
170
|
|
169
171
|
before do
|
170
172
|
before_new_drawing
|
171
173
|
end
|
172
174
|
|
173
|
-
describe
|
174
|
-
it
|
175
|
+
describe "#save_tagsets" do
|
176
|
+
it "saves the atts to a file" do
|
175
177
|
drawing.save_tagsets_to_file("#{Microstation::ROOT}drawing_atts.txt")
|
176
178
|
end
|
177
179
|
end
|
178
180
|
|
179
|
-
describe
|
180
|
-
it
|
181
|
-
_ { drawing.update_tagset(
|
181
|
+
describe "with no microstation_id" do
|
182
|
+
it "errors" do
|
183
|
+
_ { drawing.update_tagset("electrical_panel_42", panel_atts) }.must_raise Microstation::MultipleUpdateError
|
182
184
|
end
|
183
185
|
end
|
184
186
|
|
185
|
-
describe
|
186
|
-
it
|
187
|
-
ts = drawing.find_tagset_instance_by_name_and_id(
|
188
|
-
_(ts.brk_1_service).must_equal(
|
189
|
-
_(ts.brk_2_service).must_equal(
|
190
|
-
panel = panel_atts.merge({
|
191
|
-
drawing.update_tagset(
|
192
|
-
ts = drawing.find_tagset_instance_by_name_and_id(
|
193
|
-
_(ts.brk_2_service).must_equal(
|
194
|
-
_(ts.brk_1_service).must_equal(
|
187
|
+
describe "when multiple blocks exist and microstation_id" do
|
188
|
+
it "updates drawing with block" do
|
189
|
+
ts = drawing.find_tagset_instance_by_name_and_id("electrical_panel_42", 324)
|
190
|
+
_(ts.brk_1_service).must_equal("")
|
191
|
+
_(ts.brk_2_service).must_equal("")
|
192
|
+
panel = panel_atts.merge({"microstation_id" => 324})
|
193
|
+
drawing.update_tagset("electrical_panel_42", panel)
|
194
|
+
ts = drawing.find_tagset_instance_by_name_and_id("electrical_panel_42", 324)
|
195
|
+
_(ts.brk_2_service).must_equal("AIR CONDITIONER")
|
196
|
+
_(ts.brk_1_service).must_equal("OUTLETS")
|
195
197
|
end
|
196
198
|
end
|
197
199
|
end
|
198
200
|
end
|
199
|
-
describe
|
200
|
-
describe
|
201
|
-
let(:drawing) { open_existing_drawing(
|
202
|
-
it
|
201
|
+
describe "#get_text" do
|
202
|
+
describe "drawing with no text" do
|
203
|
+
let(:drawing) { open_existing_drawing("drawing_no_block.dgn") }
|
204
|
+
it "returns empty array if text has no text" do
|
203
205
|
_(drawing.get_text.to_a).must_equal([])
|
204
206
|
end
|
205
207
|
end
|
206
208
|
|
207
|
-
describe
|
208
|
-
let(:drawing) { open_existing_drawing(
|
209
|
+
describe "drawing_with_text in block" do
|
210
|
+
let(:drawing) { open_existing_drawing("drawing_with_block.dgn") }
|
209
211
|
let(:text_in_drawing) do
|
210
|
-
[
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
212
|
+
["text1 {{ a1 }}",
|
213
|
+
"text2 {{ a2 }}",
|
214
|
+
"text3 {{ a3 }}",
|
215
|
+
"node1 {{ a4 }}\nnode1 {{ a5 }}",
|
216
|
+
"node2 {{ a7 }}\nnode2 {{ a7 }}",
|
217
|
+
"text a1 again {{ a1 }}"]
|
216
218
|
end
|
217
219
|
|
218
|
-
it
|
220
|
+
it "gets all the text if drawing has text" do
|
219
221
|
text_from_drawing = drawing.get_text
|
220
222
|
_(text_from_drawing.to_a.sort).must_equal(text_in_drawing.sort)
|
221
223
|
end
|
222
224
|
end
|
223
225
|
end
|
224
226
|
|
225
|
-
describe
|
226
|
-
describe
|
227
|
-
let(:drawing) { new_drawing(
|
227
|
+
describe "2d and 3d" do
|
228
|
+
describe "when have a 2d drawing" do
|
229
|
+
let(:drawing) { new_drawing("temp.dgn", seedfile: "seed2d") }
|
228
230
|
|
229
|
-
it
|
231
|
+
it "should be 2d and not 3d two_d? " do
|
230
232
|
_(drawing).must_be :two_d?
|
231
233
|
_(drawing).wont_be :three_d?
|
232
234
|
end
|
233
235
|
end
|
234
236
|
|
235
|
-
describe
|
236
|
-
let(:drawing) { new_drawing(
|
237
|
+
describe "when we have a 3d drawing" do
|
238
|
+
let(:drawing) { new_drawing("temp.dgn", seedfile: "seed3d") }
|
237
239
|
|
238
|
-
it
|
240
|
+
it "should be 3d and not 2d" do
|
239
241
|
_(drawing).must_be :three_d?
|
240
242
|
_(drawing).wont_be :two_d?
|
241
243
|
end
|
@@ -1,35 +1,41 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative "../spec_helper"
|
4
4
|
|
5
|
-
describe
|
5
|
+
describe "points by rectangle" do
|
6
6
|
include Minitest::Hooks
|
7
7
|
|
8
8
|
before(:all) do
|
9
|
-
|
10
|
-
|
9
|
+
@app = Microstation::App.new(visible: true)
|
10
|
+
config_app(@app)
|
11
11
|
end
|
12
12
|
|
13
13
|
after(:all) do
|
14
14
|
delete_current_drawing
|
15
|
-
|
15
|
+
begin
|
16
|
+
@app.quit
|
17
|
+
rescue
|
18
|
+
nil
|
19
|
+
end
|
16
20
|
end
|
17
21
|
|
18
22
|
let(:app) { @app }
|
19
23
|
|
20
|
-
it
|
24
|
+
it "should be a function on app" do
|
21
25
|
skip
|
22
|
-
require
|
23
|
-
|
26
|
+
require "pry"
|
27
|
+
binding.pry
|
28
|
+
drawing = app.new_drawing("temp.dgn")
|
24
29
|
pts = app.get_points_by_rectangle
|
25
30
|
puts pts.value
|
26
31
|
end
|
27
32
|
|
28
|
-
describe
|
29
|
-
it
|
33
|
+
describe "#points_by_line" do
|
34
|
+
it "should not error" do
|
30
35
|
skip
|
31
|
-
drawing = app.new_drawing(
|
32
|
-
require
|
36
|
+
drawing = app.new_drawing("temp.dgn")
|
37
|
+
require "pry"
|
38
|
+
binding.pry
|
33
39
|
pts = app.get_points_by_line
|
34
40
|
end
|
35
41
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative "../spec_helper"
|
4
4
|
|
5
|
-
describe
|
5
|
+
describe "Lets start the Microstation once" do
|
6
6
|
include Minitest::Hooks
|
7
7
|
before(:all) do
|
8
8
|
@app = Microstation::App.new
|
@@ -10,107 +10,109 @@ describe 'Lets start the Microstation once' do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
after(:all) do
|
13
|
-
@app.quit
|
13
|
+
@app.quit
|
14
|
+
rescue
|
15
|
+
nil
|
14
16
|
end
|
15
17
|
|
16
|
-
describe
|
17
|
-
let(:drawing) { new_drawing(
|
18
|
+
describe "a new drawing" do
|
19
|
+
let(:drawing) { new_drawing("temp.dgn", seedfile: "seed2d") }
|
18
20
|
|
19
|
-
describe
|
21
|
+
describe "creating a new tag set" do
|
20
22
|
let(:tagsets) { drawing.tagsets }
|
21
23
|
|
22
|
-
it
|
24
|
+
it "should have no initial tagsets" do
|
23
25
|
_(tagsets.size).must_equal 0
|
24
26
|
end
|
25
27
|
|
26
|
-
it
|
27
|
-
ts = tagsets.create(
|
28
|
+
it "should create a tagset" do
|
29
|
+
ts = tagsets.create("test")
|
28
30
|
_(ts).must_be_instance_of Microstation::TagSet
|
29
31
|
end
|
30
32
|
|
31
|
-
it
|
32
|
-
ts = tagsets.create(
|
33
|
-
_(tagsets[
|
33
|
+
it "should be the same as a found tagset" do
|
34
|
+
ts = tagsets.create("test")
|
35
|
+
_(tagsets["test"]).must_equal ts
|
34
36
|
end
|
35
37
|
|
36
|
-
it
|
37
|
-
tagsets.create(
|
38
|
+
it "should allow you to remove a tagset" do
|
39
|
+
tagsets.create("test")
|
38
40
|
_(tagsets.size).must_equal 1
|
39
|
-
tagsets.remove(
|
41
|
+
tagsets.remove("test")
|
40
42
|
_(tagsets.size).must_equal 0
|
41
43
|
end
|
42
44
|
end
|
43
45
|
|
44
|
-
describe
|
45
|
-
let(:drawing) { new_drawing(
|
46
|
+
describe "A TagSet" do
|
47
|
+
let(:drawing) { new_drawing("temp.dgn", seedfile: "seed2d") }
|
46
48
|
|
47
|
-
describe
|
48
|
-
it
|
49
|
-
ts = drawing.create_tagset(
|
49
|
+
describe "#create_tagset" do
|
50
|
+
it "should allow you to create" do
|
51
|
+
ts = drawing.create_tagset("faatitle")
|
50
52
|
_(ts).must_be_instance_of Microstation::TagSet
|
51
53
|
end
|
52
54
|
|
53
|
-
it
|
54
|
-
drawing.create_tagset(
|
55
|
+
it "should yield to block if block_given" do
|
56
|
+
drawing.create_tagset("faatitle") do |ts|
|
55
57
|
_(ts).must_be_instance_of Microstation::TagSet
|
56
58
|
end
|
57
59
|
end
|
58
60
|
|
59
|
-
describe
|
60
|
-
let(:tagset) { drawing.create_tagset(
|
61
|
+
describe "given a TagSet" do
|
62
|
+
let(:tagset) { drawing.create_tagset("faatitle") }
|
61
63
|
|
62
|
-
it
|
64
|
+
it "should initially have no attributes" do
|
63
65
|
_(tagset.attributes).must_be_empty
|
64
66
|
end
|
65
67
|
|
66
|
-
it
|
68
|
+
it "#add_attribute adds TS::Attribute" do
|
67
69
|
_(tagset.attributes).must_be_empty
|
68
|
-
td = tagset.add_attribute(
|
69
|
-
_(td.prompt).must_equal(
|
70
|
+
td = tagset.add_attribute("title", String, prompt: "My title")
|
71
|
+
_(td.prompt).must_equal("My title")
|
70
72
|
_(tagset.attributes.size).must_equal 1
|
71
73
|
_(td).must_be_instance_of Microstation::TS::Attribute
|
72
74
|
end
|
73
75
|
|
74
|
-
it
|
76
|
+
it "should exist and can be found in drawing" do
|
75
77
|
tagset_local = tagset
|
76
|
-
ts = drawing.find_tagset(
|
78
|
+
ts = drawing.find_tagset("faatitle")
|
77
79
|
_(ts.name).must_equal tagset_local.name
|
78
80
|
end
|
79
81
|
end
|
80
82
|
|
81
|
-
describe
|
82
|
-
let(:tagset) { drawing.create_tagset(
|
83
|
+
describe "given a tagset with tag defintions" do
|
84
|
+
let(:tagset) { drawing.create_tagset("faatitle") }
|
83
85
|
|
84
86
|
before do
|
85
|
-
tagset.add_attribute(
|
86
|
-
tagset.add_attribute(
|
87
|
+
tagset.add_attribute("title", String)
|
88
|
+
tagset.add_attribute("city", String)
|
87
89
|
end
|
88
90
|
|
89
|
-
describe
|
90
|
-
it
|
91
|
+
describe "#attributes" do
|
92
|
+
it "should have the correct size" do
|
91
93
|
_(tagset.attributes.size).must_equal 2
|
92
94
|
end
|
93
95
|
|
94
|
-
it
|
96
|
+
it "#attributes should be Array of TS::Attributes" do
|
95
97
|
tagset.attributes.each do |ta|
|
96
98
|
_(ta).must_be_instance_of Microstation::TS::Attribute
|
97
99
|
end
|
98
100
|
end
|
99
101
|
end
|
100
102
|
|
101
|
-
describe
|
102
|
-
it
|
103
|
+
describe "#attribute_names" do
|
104
|
+
it "returns an array of the correct names" do
|
103
105
|
_(tagset.attribute_names).must_equal %w[title city]
|
104
106
|
end
|
105
107
|
end
|
106
108
|
|
107
|
-
describe
|
108
|
-
it
|
109
|
-
_(tagset[
|
109
|
+
describe "#[]" do
|
110
|
+
it "should allow you to retrieve a tagset definition that exists" do
|
111
|
+
_(tagset["title"]).must_be_instance_of Microstation::TS::Attribute
|
110
112
|
end
|
111
113
|
|
112
114
|
it "returns nil if attribute doesn't exist" do
|
113
|
-
_(tagset[
|
115
|
+
_(tagset["bogus"]).must_be_nil
|
114
116
|
end
|
115
117
|
end
|
116
118
|
end
|
@@ -118,40 +120,40 @@ describe 'Lets start the Microstation once' do
|
|
118
120
|
end
|
119
121
|
end
|
120
122
|
|
121
|
-
describe
|
122
|
-
let(:drawing) { open_existing_drawing(
|
123
|
+
describe "a drawing with tagsets placed in drawing" do
|
124
|
+
let(:drawing) { open_existing_drawing("drawing_with_block.dgn") }
|
123
125
|
let(:tagsets) { drawing.tagsets }
|
124
126
|
let(:tset) { tagsets.first }
|
125
127
|
|
126
|
-
it
|
128
|
+
it "has tagsets" do
|
127
129
|
_(tagsets).wont_be_empty
|
128
130
|
end
|
129
131
|
|
130
|
-
it
|
132
|
+
it "has the correct tagsets" do
|
131
133
|
_(tagsets.size).must_equal 1
|
132
|
-
_(tset.name).must_equal
|
134
|
+
_(tset.name).must_equal "electrical_panel_42"
|
133
135
|
end
|
134
136
|
|
135
|
-
it
|
137
|
+
it "has tagset instances" do
|
136
138
|
_(tset.instances.size).must_equal 1
|
137
139
|
tagset_instance = tset.instances.first
|
138
|
-
_(tagset_instance.name).must_equal
|
140
|
+
_(tagset_instance.name).must_equal "electrical_panel_42"
|
139
141
|
_(tagset_instance).must_be_instance_of Microstation::TS::Instance
|
140
142
|
end
|
141
143
|
end
|
142
144
|
|
143
|
-
describe
|
144
|
-
let(:drawing) { open_existing_drawing(
|
145
|
+
describe "a drawing with 3 instances of same tagset in drawing" do
|
146
|
+
let(:drawing) { open_existing_drawing("drawing_with_3_block.dgn") }
|
145
147
|
let(:tagsets) { drawing.tagsets }
|
146
148
|
let(:tset) { tagsets.first }
|
147
149
|
|
148
|
-
it
|
150
|
+
it "has the correct number of tagsets" do
|
149
151
|
_(tagsets.size).must_equal 1
|
150
152
|
_(tagsets.names).must_equal %w[electrical_panel_42]
|
151
|
-
_(tset.name).must_equal
|
153
|
+
_(tset.name).must_equal "electrical_panel_42"
|
152
154
|
end
|
153
155
|
|
154
|
-
it
|
156
|
+
it "has the correct instances" do
|
155
157
|
_(tset.instances.size).must_equal 3
|
156
158
|
_(tset.instances.map(&:name)).must_equal %w[electrical_panel_42 electrical_panel_42 electrical_panel_42]
|
157
159
|
end
|