microstation 0.4.1 → 0.8.3
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 +7 -0
- data/.autotest +23 -23
- data/.rspec +2 -2
- data/Gemfile +28 -10
- data/History.txt +6 -6
- data/LICENSE.adoc +22 -0
- data/Manifest.txt +81 -60
- data/README.adoc +131 -0
- data/Rakefile +71 -30
- data/bin/dgn2pdf +36 -37
- data/bin/dgn_template +107 -0
- data/bin/microstation +231 -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/seed2d.dgn +0 -0
- data/cad_files/test.dgn +0 -0
- data/lib/microstation.rb +252 -88
- 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 +690 -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/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
- metadata +301 -86
- 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/microstation_spec.rb +0 -36
- data/spec/scanner_spec.rb +0 -155
- data/spec/spec_app.rb +0 -11
- data/spec/spec_helper.rb +0 -31
- data/spec/tag_set_spec.rb +0 -123
- data/spec/text_node_spec.rb +0 -92
- data/spec/text_spec.rb +0 -62
data/.gemtest
DELETED
|
File without changes
|
data/README.txt
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
= microstation
|
|
2
|
-
|
|
3
|
-
http://github.com/dsisnero/microstation
|
|
4
|
-
|
|
5
|
-
== DESCRIPTION:
|
|
6
|
-
|
|
7
|
-
this is a gem that wraps Bentley Microstation using the WIN32OLE
|
|
8
|
-
library.
|
|
9
|
-
|
|
10
|
-
== FEATURES/PROBLEMS:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
== SYNOPSIS:
|
|
15
|
-
text_in_drawing = []
|
|
16
|
-
Microstation.run do |app|
|
|
17
|
-
sc = create_scanner do
|
|
18
|
-
include_color(3)
|
|
19
|
-
include_level(3)
|
|
20
|
-
end
|
|
21
|
-
app.open_drawing('./test.dgn') do |drawing|
|
|
22
|
-
drawing.scan_text do |text|
|
|
23
|
-
text.reverse! if text =~ /Reverse/ # things that modify thetext_in_drawing
|
|
24
|
-
puts text.to_s
|
|
25
|
-
end
|
|
26
|
-
drawing.scan( sc) do |ele|
|
|
27
|
-
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
drawing.save_as_pdf
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
== REQUIREMENTS:
|
|
36
|
-
|
|
37
|
-
An installed version of Microstation
|
|
38
|
-
|
|
39
|
-
== INSTALL:
|
|
40
|
-
|
|
41
|
-
* sudo gem install microstation
|
|
42
|
-
|
|
43
|
-
== DEVELOPERS:
|
|
44
|
-
|
|
45
|
-
After checking out the source, run:
|
|
46
|
-
|
|
47
|
-
$ rake
|
|
48
|
-
|
|
49
|
-
This task will install any missing dependencies, run the tests/specs,
|
|
50
|
-
and generate the RDoc.
|
|
51
|
-
|
|
52
|
-
== LICENSE:
|
|
53
|
-
|
|
54
|
-
(The MIT License)
|
|
55
|
-
|
|
56
|
-
Copyright (c) 2012 FIX
|
|
57
|
-
|
|
58
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
59
|
-
a copy of this software and associated documentation files (the
|
|
60
|
-
'Software'), to deal in the Software without restriction, including
|
|
61
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
62
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
63
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
64
|
-
the following conditions:
|
|
65
|
-
|
|
66
|
-
The above copyright notice and this permission notice shall be
|
|
67
|
-
included in all copies or substantial portions of the Software.
|
|
68
|
-
|
|
69
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
70
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
71
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
72
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
73
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
74
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
75
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
require 'virtus'
|
|
2
|
-
|
|
3
|
-
module Microstation
|
|
4
|
-
|
|
5
|
-
module Attribute
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class Base < Virtus::Attribute::Object
|
|
9
|
-
|
|
10
|
-
accept_options :is_hidden, :prompt, :readonly
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
class String < Base
|
|
16
|
-
|
|
17
|
-
primitive ::String
|
|
18
|
-
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
class Integer < Base
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
class Float < Base
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
class Hash
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
def map_v
|
|
5
|
-
reduce({}) do |result, array|
|
|
6
|
-
k,v = array
|
|
7
|
-
new_val = yield v
|
|
8
|
-
result.merge( k => new_val)
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def map_k
|
|
13
|
-
reduce({}) do |result, array|
|
|
14
|
-
k,v = array
|
|
15
|
-
new_k = yield k
|
|
16
|
-
result.merge(new_k => v)
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def map_kv
|
|
21
|
-
reduce({}) do |result, array|
|
|
22
|
-
new_k,new_v = yield array
|
|
23
|
-
result.merge(new_k => new_v)
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
end
|
data/spec/app_spec.rb
DELETED
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
require File.join(File.dirname(__FILE__) , 'spec_helper')
|
|
2
|
-
|
|
3
|
-
describe "Microstation::App" do
|
|
4
|
-
|
|
5
|
-
before(:all) do
|
|
6
|
-
@app = Microstation::App.new
|
|
7
|
-
@existing_drawing_path = drawing_path('test.dgn')
|
|
8
|
-
@new_drawing_path = drawing_path('my_new_drawing.dgn')
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
before(:each) do
|
|
12
|
-
File.delete(@new_drawing_path) if File.exist?(@new_drawing_path)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
after(:all) do
|
|
17
|
-
@app.quit if @app
|
|
18
|
-
@app = nil
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
let(:app){@app}
|
|
22
|
-
|
|
23
|
-
describe "#initialize" do
|
|
24
|
-
it "with no options visible is true" do
|
|
25
|
-
app = Microstation::App.new
|
|
26
|
-
app.should be_visible
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
it "works with options" do
|
|
30
|
-
app = Microstation::App.new(:visible => false)
|
|
31
|
-
app.should_not be_visible
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
describe "#can_open?" do
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
it "can open a dwg file" do
|
|
40
|
-
app.can_open?('test.dwg').should be_true
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
it "can open a dgn file" do
|
|
44
|
-
app.can_open?('test.dgn').should be_true
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
it "can't open any other type of files" do
|
|
48
|
-
%w(xls doc txt png tiff odf).each do |format|
|
|
49
|
-
app.can_open?("test.#{format}").should be_false
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
describe "#open_drawing" do
|
|
55
|
-
|
|
56
|
-
after(:each) do
|
|
57
|
-
app.close_active_drawing
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
let (:valid_file){ @existing_drawing_path }
|
|
62
|
-
let (:invalid_file) {"bogus file"}
|
|
63
|
-
|
|
64
|
-
it "returns a drawing if drawing exists" do
|
|
65
|
-
drawing = app.open_drawing(valid_file)
|
|
66
|
-
drawing.class.should == Microstation::Drawing
|
|
67
|
-
app.active_design_file.should.eql? drawing.ole_obj
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
it "raises error if drawing does not exist" do
|
|
71
|
-
expect {
|
|
72
|
-
app.open_drawing(invalid_file)
|
|
73
|
-
}.to raise_error
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
describe "when given a block" do
|
|
77
|
-
|
|
78
|
-
it "yields the drawing to a block if a block is given" do
|
|
79
|
-
app.open_drawing(valid_file) do |drawing|
|
|
80
|
-
drawing.class.should == Microstation::Drawing
|
|
81
|
-
app.active_design_file.should.eql? drawing.ole_obj
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
it "closes drawing after block returns" do
|
|
87
|
-
app.active_design_file.should == nil
|
|
88
|
-
app.open_drawing(valid_file) do |drawing|
|
|
89
|
-
app.active_design_file.should.eql? drawing.ole_obj
|
|
90
|
-
end
|
|
91
|
-
app.active_design_file.should == nil
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
it "has an ole_object" do
|
|
99
|
-
app.ole_obj.class.should == ::WIN32OLE
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
describe "load constants" do
|
|
103
|
-
it "should load the constants" do
|
|
104
|
-
app.load_constants
|
|
105
|
-
Microstation::MSD::MsdElementTypeTag.should == 37
|
|
106
|
-
end
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
describe "create_scanner" do
|
|
110
|
-
it "should yield a scanner object" do
|
|
111
|
-
app.create_scanner do |scan|
|
|
112
|
-
scan.should be_instance_of Microstation::Scan::Criteria
|
|
113
|
-
scan.include_tags
|
|
114
|
-
scan.include_color(3)
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
end
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
describe "#create_ole_scanner" do
|
|
124
|
-
it "returns an ole scanner" do
|
|
125
|
-
pending
|
|
126
|
-
scanner = app.create_ole_scan_criteria
|
|
127
|
-
scanner.ole_type.to_s.should =~ /_ElementScanCriteria/
|
|
128
|
-
end
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
describe "#normalize_name(name)" do
|
|
132
|
-
|
|
133
|
-
it "returns the name if the name is absolute" do
|
|
134
|
-
app.normalize_name("c:/my_drawings/cool.dng").to_s.should == "c:/my_drawings/cool.dgn"
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
context "when given a relative path and project dir is set" do
|
|
138
|
-
it "returns the name joined with the project_dir" do
|
|
139
|
-
app.project_dir = "c:/projects/new"
|
|
140
|
-
app.normalize_name('cool_beans.dng').to_s.should == "c:/projects/new/cool_beans.dgn"
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
context "when project_dir is nil" do
|
|
146
|
-
it "returns name relative to the calling process" do
|
|
147
|
-
app.project_dir = nil
|
|
148
|
-
app.normalize_name('cool_beans.dng').to_s.should == (Pathname.getwd + 'cool_beans.dgn').to_s
|
|
149
|
-
end
|
|
150
|
-
end
|
|
151
|
-
end
|
|
152
|
-
|
|
153
|
-
it "#windows path method" do
|
|
154
|
-
pending
|
|
155
|
-
app.windows_path( drawing_path("")).should == "c:\\test"
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
it "should have a #username" do
|
|
160
|
-
app.username.should == ENV["USERNAME"]
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
describe "#new_drawing" do
|
|
164
|
-
# before(:each) do
|
|
165
|
-
# @new_name = "my_new_drawing.dgn"
|
|
166
|
-
# @new_drawing_path = drawing_path(@new_name)
|
|
167
|
-
# @existing_drawing_path = drawing_path('test.dgn')
|
|
168
|
-
# end
|
|
169
|
-
|
|
170
|
-
after(:each) do
|
|
171
|
-
app.close_active_drawing
|
|
172
|
-
# File.delete(@new_drawing_path) if File.exist?(@new_drawing_path)
|
|
173
|
-
end
|
|
174
|
-
|
|
175
|
-
let(:existing_drawing){ @existing_drawing_path }
|
|
176
|
-
let(:new_drawing) { @new_drawing_path }
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
it "needs a filename" do
|
|
180
|
-
expect{ app.new_drawing()}.to raise_error
|
|
181
|
-
end
|
|
182
|
-
|
|
183
|
-
it "raises an error if drawing exists" do
|
|
184
|
-
expect {
|
|
185
|
-
app.new_drawing(existing_drawing).to raise_error
|
|
186
|
-
}
|
|
187
|
-
end
|
|
188
|
-
|
|
189
|
-
it "creates a drawing if it's a new drawing_name" do
|
|
190
|
-
drawing = app.new_drawing(new_drawing)
|
|
191
|
-
drawing.should be_an_instance_of Microstation::Drawing
|
|
192
|
-
end
|
|
193
|
-
|
|
194
|
-
describe "when given a block" do
|
|
195
|
-
|
|
196
|
-
it "yields the drawing to a block if a block is given" do
|
|
197
|
-
app.new_drawing(new_drawing) do |drawing|
|
|
198
|
-
drawing.class.should == Microstation::Drawing
|
|
199
|
-
app.active_design_file.should.eql? drawing.ole_obj
|
|
200
|
-
end
|
|
201
|
-
end
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
it "closes drawing after block returns" do
|
|
205
|
-
app.active_design_file.should == nil
|
|
206
|
-
app.new_drawing(new_drawing) do |drawing|
|
|
207
|
-
app.active_design_file.should.eql? drawing.ole_obj
|
|
208
|
-
end
|
|
209
|
-
app.active_design_file.should == nil
|
|
210
|
-
end
|
|
211
|
-
|
|
212
|
-
end
|
|
213
|
-
|
|
214
|
-
end
|
|
215
|
-
|
|
216
|
-
describe "an app with an open drawing" do
|
|
217
|
-
before(:each) do
|
|
218
|
-
@drawing = app.new_drawing(@new_drawing_path)
|
|
219
|
-
end
|
|
220
|
-
|
|
221
|
-
after(:each) do
|
|
222
|
-
app.close_active_drawing
|
|
223
|
-
# File.delete(@new_drawing_path) if File.exist? (@new_drawing_path)
|
|
224
|
-
end
|
|
225
|
-
|
|
226
|
-
describe "#scan" do
|
|
227
|
-
it "defaults to all objects without a scan criteria" do
|
|
228
|
-
pending
|
|
229
|
-
expect{app.scan}.to_not raise_error
|
|
230
|
-
end
|
|
231
|
-
|
|
232
|
-
it "resolves the scan criteria" do
|
|
233
|
-
scanner = app.create_scanner do |scan|
|
|
234
|
-
scan.include_textual
|
|
235
|
-
end
|
|
236
|
-
scanner.should_receive("resolve")
|
|
237
|
-
app.scan(scanner)
|
|
238
|
-
end
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
end
|
|
243
|
-
|
|
244
|
-
# describe "#current_drawing" do
|
|
245
|
-
# it "returns the current drawing" do
|
|
246
|
-
# binding.pry
|
|
247
|
-
# app.current_drawing.should == @drawing
|
|
248
|
-
# end
|
|
249
|
-
|
|
250
|
-
# end
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
end
|
|
256
|
-
|
|
257
|
-
# it "forwards method missing" do
|
|
258
|
-
|
|
259
|
-
# @app.ole_obj.should_receive("Open")
|
|
260
|
-
# @app.Open("this is a drawing")
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
# end
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
end
|
|
267
|
-
|
data/spec/configuration_spec.rb
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
require File.join(File.dirname(__FILE__) , 'spec_helper')
|
|
2
|
-
require 'pry'
|
|
3
|
-
|
|
4
|
-
describe Microstation::Configuration do
|
|
5
|
-
|
|
6
|
-
before(:all) do
|
|
7
|
-
@app = Microstation::App.new
|
|
8
|
-
@configuration = Microstation::Configuration.new(@app)
|
|
9
|
-
@defined_variable = "new_variable"
|
|
10
|
-
@defined_variable_value = "variable_value"
|
|
11
|
-
@configuration[@defined_variable] = @defined_variable_value
|
|
12
|
-
@undefined_variable = 'undefined'
|
|
13
|
-
@configuration.remove_variable('undefined')
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
after(:all) do
|
|
17
|
-
@configuration.remove_variable(@defined_variable)
|
|
18
|
-
@app.quit
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
describe "#exists" do
|
|
23
|
-
let(:variable){ @defined_variable}
|
|
24
|
-
let(:undefined){ @undefined_variable}
|
|
25
|
-
subject { @configuration}
|
|
26
|
-
|
|
27
|
-
it "should return true if config variable is exists" do
|
|
28
|
-
subject.exists?(variable).should be_true
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
it "should return false if config variable doesn't exist" do
|
|
32
|
-
subject.exists?(undefined).should be_false
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
describe "#[]" do
|
|
38
|
-
let(:undefined){ @undefined_variable}
|
|
39
|
-
let(:variable){ @defined_variable}
|
|
40
|
-
subject{@configuration}
|
|
41
|
-
|
|
42
|
-
it "should check if value exists" do
|
|
43
|
-
subject.should_receive(:exists?).with('undefined')
|
|
44
|
-
expect(subject[undefined]).to be_nil
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
it "should return the configuration variable if exists" do
|
|
48
|
-
expect(subject[variable]).to eq 'variable_value'
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
it "should return nil if not exists" do
|
|
52
|
-
expect(@configuration[undefined]).to equal nil
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
describe "#should update" do
|
|
59
|
-
|
|
60
|
-
let(:undefined){@undefined}
|
|
61
|
-
let(:variable){@defined_variable}
|
|
62
|
-
|
|
63
|
-
it "should return true if key doesn't exist" do
|
|
64
|
-
@configuration.should_update?(undefined).should be_true
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
it "should return false if key exists? and options[:force] is false or nil" do
|
|
68
|
-
@configuration.should_update?(variable).should be_false
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
it "should return true if key exists? and options[:force] is true" do
|
|
72
|
-
@configuration.should_update?(variable, {:force => true}).should be_true
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
describe "setting variables" do
|
|
78
|
-
|
|
79
|
-
before(:each) do
|
|
80
|
-
@variable = "TEST_VARIABLE"
|
|
81
|
-
@configuration.remove_variable(@variable)
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
context "value not existing yet" do
|
|
85
|
-
|
|
86
|
-
it "should set the variable" do
|
|
87
|
-
@configuration[@variable].should == nil
|
|
88
|
-
@configuration[@variable] = "a new variable"
|
|
89
|
-
@configuration[@variable].should == "a new variable"
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
context "value existing" do
|
|
95
|
-
|
|
96
|
-
let(:variable){@defined_variable}
|
|
97
|
-
subject{ @configuration}
|
|
98
|
-
|
|
99
|
-
it "should raise variable defined if force option is false" do
|
|
100
|
-
@configuration[variable].should == 'variable_value'
|
|
101
|
-
expect{ @configuration[variable]= "my new value"}.to raise_error Microstation::VariableDefined
|
|
102
|
-
@configuration[variable].should == "variable_value"
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
it "should change the variable if force is true" do
|
|
106
|
-
@configuration[variable].should == "variable_value"
|
|
107
|
-
@configuration.set(variable, "my new value", :force => true)
|
|
108
|
-
@configuration[variable].should == "my new value"
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
describe "#expand" do
|
|
114
|
-
it "should be able to expand string" do
|
|
115
|
-
@configuration.expand( "$(_USTN_USER)$(_USTN_USERNAME).txt").should_not be_nil
|
|
116
|
-
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
end
|
|
122
|
-
end
|