microstation 0.8.5 → 0.8.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,20 +1,21 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative "../spec_helper"
|
4
4
|
|
5
5
|
describe Microstation::App do
|
6
|
-
|
7
6
|
after(:all) do
|
8
|
-
|
7
|
+
app.quit
|
8
|
+
rescue
|
9
|
+
nil
|
9
10
|
end
|
10
|
-
describe
|
11
|
-
describe
|
12
|
-
it
|
11
|
+
describe "#initialize" do
|
12
|
+
describe "visibility" do
|
13
|
+
it "is invisible with no options" do
|
13
14
|
app = Microstation::App.new
|
14
15
|
_(app).wont_be :visible
|
15
16
|
end
|
16
17
|
|
17
|
-
it
|
18
|
+
it "can be set with option" do
|
18
19
|
app = Microstation::App.new(visible: true)
|
19
20
|
_(app).must_be :visible
|
20
21
|
end
|
@@ -22,26 +23,28 @@ describe Microstation::App do
|
|
22
23
|
end
|
23
24
|
end
|
24
25
|
|
25
|
-
describe
|
26
|
+
describe "an open Microstation App" do
|
26
27
|
after(:all) do
|
27
|
-
|
28
|
+
app.quit
|
29
|
+
rescue
|
30
|
+
nil
|
28
31
|
end
|
29
32
|
let(:app) { Microstation::App.new }
|
30
33
|
|
31
|
-
it
|
34
|
+
it "loads the constants" do
|
32
35
|
app
|
33
36
|
_(Microstation::MSD::MsdElementTypeTag).must_equal 37
|
34
37
|
end
|
35
38
|
|
36
|
-
describe
|
37
|
-
it
|
39
|
+
describe "#can_open?" do
|
40
|
+
it "is true for dgn and dwg files" do
|
38
41
|
%w[dgn dwg].each do |ext|
|
39
42
|
name = "test.#{ext}"
|
40
43
|
_(app.can_open?(name)).must_equal true
|
41
44
|
end
|
42
45
|
end
|
43
46
|
|
44
|
-
it
|
47
|
+
it "is false for other filetypes" do
|
45
48
|
%w[pdf doc jpg pgn].each do |ext|
|
46
49
|
name = "test.#{ext}"
|
47
50
|
_(app.can_open?(name)).wont_equal true
|
@@ -49,24 +52,24 @@ describe 'an open Microstation App' do
|
|
49
52
|
end
|
50
53
|
end
|
51
54
|
|
52
|
-
describe
|
53
|
-
describe
|
54
|
-
let(:path) { drawing_path(
|
55
|
+
describe "open_drawing" do
|
56
|
+
describe "when valid drawing" do
|
57
|
+
let(:path) { drawing_path("drawing_with_text.dgn") }
|
55
58
|
|
56
|
-
it
|
59
|
+
it "returns a drawing" do
|
57
60
|
drawing = app.open_drawing(path)
|
58
61
|
_(drawing).must_be_instance_of Microstation::Drawing
|
59
62
|
drawing.close
|
60
63
|
end
|
61
64
|
|
62
|
-
describe
|
63
|
-
it
|
65
|
+
describe "when given a block" do
|
66
|
+
it "yield the drawing to the block" do
|
64
67
|
app.open_drawing(path) do |d|
|
65
68
|
_(d).must_be_instance_of Microstation::Drawing
|
66
69
|
end
|
67
70
|
end
|
68
71
|
|
69
|
-
it
|
72
|
+
it "closes the drawing after block returns" do
|
70
73
|
_(app.active_design_file).must_be_nil
|
71
74
|
app.open_drawing(path) do |d|
|
72
75
|
_(d).must_be_instance_of Microstation::Drawing
|
@@ -77,27 +80,27 @@ describe 'an open Microstation App' do
|
|
77
80
|
end
|
78
81
|
end
|
79
82
|
|
80
|
-
describe
|
81
|
-
it
|
82
|
-
_ { app.open_drawing(
|
83
|
+
describe "when a non existent drawing" do
|
84
|
+
it "raises an error" do
|
85
|
+
_ { app.open_drawing("a_bogus_file.dgn") }.must_raise Microstation::Error
|
83
86
|
end
|
84
87
|
end
|
85
88
|
end
|
86
89
|
|
87
|
-
describe
|
88
|
-
it
|
90
|
+
describe "#ole_obj" do
|
91
|
+
it "returns an instance of the WIN32OLE" do
|
89
92
|
_(app.ole_obj).must_be_instance_of WIN32OLE
|
90
93
|
end
|
91
94
|
end
|
92
95
|
|
93
|
-
describe
|
94
|
-
it
|
96
|
+
describe "#create_scanner" do
|
97
|
+
it "can yield a Microstation::Scan::Criteria" do
|
95
98
|
scan = app.create_scanner do |sc|
|
96
99
|
_(sc).must_be_instance_of Microstation::Scan::Criteria
|
97
100
|
end
|
98
101
|
end
|
99
102
|
|
100
|
-
it
|
103
|
+
it "can accept a name" do
|
101
104
|
scanner = app.create_scanner(:my_scanner) do |sc|
|
102
105
|
sc.include_textual
|
103
106
|
sc.include_tags
|
@@ -107,9 +110,9 @@ describe 'an open Microstation App' do
|
|
107
110
|
end
|
108
111
|
end
|
109
112
|
|
110
|
-
describe
|
111
|
-
it
|
112
|
-
_(app.normalize_name(
|
113
|
+
describe "#normalize_name" do
|
114
|
+
it "returns the name if the name is absolute" do
|
115
|
+
_(app.normalize_name("c:/my_drawings/test.dgn").to_s).must_equal "c:/my_drawings/test.dgn"
|
113
116
|
end
|
114
117
|
|
115
118
|
# describe "with relative path" do
|
@@ -128,40 +131,40 @@ describe 'an open Microstation App' do
|
|
128
131
|
# end
|
129
132
|
end
|
130
133
|
|
131
|
-
it
|
132
|
-
_(app.username).must_equal ENV[
|
134
|
+
it "has a username method" do
|
135
|
+
_(app.username).must_equal ENV["USERNAME"]
|
133
136
|
end
|
134
137
|
|
135
|
-
describe
|
136
|
-
let(:new_path) { output_path(
|
138
|
+
describe "#new_drawing" do
|
139
|
+
let(:new_path) { output_path("new_drawing.dgn") }
|
137
140
|
|
138
141
|
after do
|
139
142
|
app.close_active_drawing
|
140
143
|
File.delete(new_path) if File.exist? new_path
|
141
144
|
end
|
142
145
|
|
143
|
-
it
|
146
|
+
it "needs a filename" do
|
144
147
|
_ { app.new_drawing }.must_raise
|
145
148
|
end
|
146
149
|
|
147
|
-
it
|
148
|
-
path = drawing_path(
|
150
|
+
it "raises an error if drawing exists" do
|
151
|
+
path = drawing_path("drawing_with_text.dgn")
|
149
152
|
_ { app.new_drawing(path) }.must_raise
|
150
153
|
end
|
151
154
|
|
152
|
-
it
|
155
|
+
it "creates a drawing if the drawing path is new" do
|
153
156
|
drawing = app.new_drawing(new_path)
|
154
157
|
_(drawing).must_be_instance_of Microstation::Drawing
|
155
158
|
end
|
156
159
|
|
157
|
-
describe
|
158
|
-
it
|
160
|
+
describe "when given a block" do
|
161
|
+
it "yields the drawing to a block if a block is given" do
|
159
162
|
app.new_drawing(new_path) do |d|
|
160
163
|
_(d).must_be_instance_of Microstation::Drawing
|
161
164
|
end
|
162
165
|
end
|
163
166
|
|
164
|
-
it
|
167
|
+
it "closes drawing after block returns" do
|
165
168
|
_(app.active_design_file).must_be_nil
|
166
169
|
app.new_drawing(new_path) do |d|
|
167
170
|
_(d).must_be_instance_of Microstation::Drawing
|
@@ -172,11 +175,11 @@ describe 'an open Microstation App' do
|
|
172
175
|
end
|
173
176
|
end
|
174
177
|
|
175
|
-
describe
|
176
|
-
describe
|
177
|
-
let(:dgn) { drawing_path(
|
178
|
+
describe "render_template" do
|
179
|
+
describe "with a valid dgn" do
|
180
|
+
let(:dgn) { drawing_path("drawing_with_block.dgn") }
|
178
181
|
|
179
|
-
it
|
182
|
+
it "completes" do
|
180
183
|
app.render_template(dgn)
|
181
184
|
end
|
182
185
|
end
|
@@ -1,91 +1,93 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative "../spec_helper"
|
4
4
|
|
5
5
|
describe Microstation::Configuration do
|
6
6
|
include Minitest::Hooks
|
7
|
-
before(:all) do
|
7
|
+
before(:all) do
|
8
8
|
@app = Microstation::App.new
|
9
9
|
config_app(@app)
|
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
18
|
let(:config) { Microstation::Configuration.new(@app) }
|
17
|
-
let(:defined_name) {
|
18
|
-
let(:defined_value) {
|
19
|
-
let(:undefined_name) {
|
19
|
+
let(:defined_name) { "new_variable" }
|
20
|
+
let(:defined_value) { "new_variable_value" }
|
21
|
+
let(:undefined_name) { "undefined_variable" }
|
20
22
|
|
21
23
|
before do
|
22
24
|
config.remove_variable(undefined_name)
|
23
25
|
config.set!(defined_name, defined_value)
|
24
26
|
end
|
25
27
|
|
26
|
-
describe
|
27
|
-
it
|
28
|
+
describe "#remove_variable" do
|
29
|
+
it "removes an existing variable" do
|
28
30
|
_(config[defined_name]).must_equal defined_value
|
29
31
|
config.remove_variable(defined_name)
|
30
32
|
_(config[defined_name]).must_be_nil
|
31
33
|
end
|
32
34
|
|
33
35
|
it "doesn't error if variable nonexistent" do
|
34
|
-
config.remove_variable
|
36
|
+
config.remove_variable "this_bogus_variable_should_not_exist"
|
35
37
|
end
|
36
38
|
end
|
37
39
|
|
38
|
-
describe
|
39
|
-
it
|
40
|
+
describe "#[]" do
|
41
|
+
it "should check if value exists" do
|
40
42
|
skip
|
41
43
|
config_mock = Minitest::Mock.new
|
42
44
|
config_mock.expect :exists?, true
|
43
45
|
config.stub :[], config_mock do
|
44
|
-
config[
|
46
|
+
config["undefined"]
|
45
47
|
end
|
46
48
|
config_mock.verify
|
47
49
|
end
|
48
50
|
|
49
|
-
it
|
51
|
+
it "should return the configuration variable if exists" do
|
50
52
|
_(config[defined_name]).must_equal defined_value
|
51
53
|
end
|
52
54
|
|
53
|
-
it
|
55
|
+
it "should return nil if not exists" do
|
54
56
|
_(config[undefined_name]).must_be_nil
|
55
57
|
end
|
56
58
|
end
|
57
59
|
|
58
|
-
describe
|
59
|
-
describe
|
60
|
-
it
|
60
|
+
describe "[]=, setting variables" do
|
61
|
+
describe "value not existing yet" do
|
62
|
+
it "should set the variable" do
|
61
63
|
_(config[undefined_name]).must_be_nil
|
62
|
-
config[undefined_name] =
|
63
|
-
_(config[undefined_name]).must_equal
|
64
|
+
config[undefined_name] = "its set"
|
65
|
+
_(config[undefined_name]).must_equal "its set"
|
64
66
|
end
|
65
67
|
end
|
66
68
|
|
67
|
-
describe
|
68
|
-
it
|
69
|
-
_ { config[defined_name] =
|
69
|
+
describe "value existing" do
|
70
|
+
it "should raise variable defined if force option is false" do
|
71
|
+
_ { config[defined_name] = "my new value" }.must_raise ::Microstation::VariableDefined
|
70
72
|
end
|
71
73
|
|
72
|
-
it
|
74
|
+
it "should keep existing value" do
|
73
75
|
_(config[defined_name]).must_equal defined_value
|
74
|
-
_ { config[defined_name] =
|
76
|
+
_ { config[defined_name] = "my new value" }.must_raise
|
75
77
|
_(config[defined_name]).must_equal defined_value
|
76
78
|
end
|
77
79
|
|
78
|
-
it
|
80
|
+
it "should change the variable if force is true" do
|
79
81
|
_(config[defined_name]).must_equal(defined_value)
|
80
|
-
config.set!(defined_name,
|
81
|
-
_(config[defined_name]).must_equal
|
82
|
+
config.set!(defined_name, "my new value")
|
83
|
+
_(config[defined_name]).must_equal "my new value"
|
82
84
|
end
|
83
85
|
end
|
84
86
|
end
|
85
87
|
|
86
|
-
describe
|
87
|
-
it
|
88
|
-
_(
|
88
|
+
describe "#exists" do
|
89
|
+
it "should return true if config variable exists" do
|
90
|
+
_(config.exists?(defined_name)).must_equal true
|
89
91
|
end
|
90
92
|
|
91
93
|
it "should return false if config variable doesn't exist" do
|
@@ -93,39 +95,39 @@ describe Microstation::Configuration do
|
|
93
95
|
end
|
94
96
|
end
|
95
97
|
|
96
|
-
describe
|
97
|
-
describe
|
98
|
-
it
|
98
|
+
describe "#prepend" do
|
99
|
+
describe "variable exists" do
|
100
|
+
it "should prepend the value" do
|
99
101
|
value_before = config[defined_name]
|
100
|
-
config.prepend(defined_name,
|
102
|
+
config.prepend(defined_name, "added")
|
101
103
|
value_after = config[defined_name]
|
102
104
|
_(value_after).must_equal "added;#{value_before}"
|
103
105
|
end
|
104
106
|
|
105
|
-
describe
|
106
|
-
it
|
107
|
+
describe "variable nonexistent" do
|
108
|
+
it "should add the value" do
|
107
109
|
value_before = config[undefined_name]
|
108
|
-
config.prepend(undefined_name,
|
110
|
+
config.prepend(undefined_name, "added")
|
109
111
|
value_after = config[undefined_name]
|
110
|
-
_(value_after).must_equal
|
112
|
+
_(value_after).must_equal "added"
|
111
113
|
end
|
112
114
|
end
|
113
115
|
end
|
114
116
|
end
|
115
117
|
|
116
|
-
describe
|
118
|
+
describe "#expand" do
|
117
119
|
let(:dir) {}
|
118
120
|
|
119
121
|
before do
|
120
|
-
config[
|
122
|
+
config["DIR"] = "c:/Users/Tom"
|
121
123
|
end
|
122
124
|
|
123
125
|
after do
|
124
|
-
config.remove_variable(
|
126
|
+
config.remove_variable("DIR")
|
125
127
|
end
|
126
128
|
|
127
|
-
it
|
128
|
-
_(config.expand(
|
129
|
+
it "should expand the string" do
|
130
|
+
_(config.expand("$(DIR)/project")).must_equal "c:/Users/Tom/project"
|
129
131
|
end
|
130
132
|
end
|
131
133
|
end
|