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