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.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +26 -29
  3. data/Rakefile +45 -44
  4. data/bin/dgn2pdf +5 -6
  5. data/bin/dgn_template +23 -25
  6. data/bin/pw_print +11 -13
  7. data/cad_files/drawing_no_block.dgn +0 -0
  8. data/cad_files/drawing_with_3_block.dgn +0 -0
  9. data/cad_files/drawing_with_block.dgn +0 -0
  10. data/cad_files/drawing_with_text.dgn +0 -0
  11. data/lib/microstation/app.rb +91 -87
  12. data/lib/microstation/cad_input_queue.rb +10 -20
  13. data/lib/microstation/cell.rb +6 -18
  14. data/lib/microstation/changer.rb +3 -3
  15. data/lib/microstation/configuration.rb +33 -50
  16. data/lib/microstation/criteria_creation_t.rb +4 -8
  17. data/lib/microstation/dir.rb +27 -59
  18. data/lib/microstation/directory.rb +2 -7
  19. data/lib/microstation/drawing.rb +103 -102
  20. data/lib/microstation/element.rb +55 -68
  21. data/lib/microstation/enumerator.rb +4 -9
  22. data/lib/microstation/errors.rb +0 -5
  23. data/lib/microstation/event_handler.rb +1 -5
  24. data/lib/microstation/ext/pathname.rb +12 -14
  25. data/lib/microstation/ext/win32ole.rb +0 -2
  26. data/lib/microstation/extensions/faa.rb +12 -34
  27. data/lib/microstation/file_tests.rb +15 -50
  28. data/lib/microstation/functions.rb +10 -20
  29. data/lib/microstation/graphics.rb +6 -13
  30. data/lib/microstation/line.rb +2 -6
  31. data/lib/microstation/model.rb +11 -20
  32. data/lib/microstation/model_trait.rb +40 -40
  33. data/lib/microstation/ole_cad_input_message.rb +25 -34
  34. data/lib/microstation/ole_helper.rb +58 -66
  35. data/lib/microstation/pdf_support.rb +7 -16
  36. data/lib/microstation/point3d.rb +17 -30
  37. data/lib/microstation/primitive_command_interface.rb +8 -14
  38. data/lib/microstation/properties.rb +29 -17
  39. data/lib/microstation/property_handler.rb +6 -8
  40. data/lib/microstation/scan/color.rb +1 -8
  41. data/lib/microstation/scan/criteria.rb +17 -33
  42. data/lib/microstation/scan/klass.rb +8 -12
  43. data/lib/microstation/scan/level.rb +2 -9
  44. data/lib/microstation/scan/line_style.rb +4 -12
  45. data/lib/microstation/scan/line_weight.rb +1 -3
  46. data/lib/microstation/scan/range.rb +2 -8
  47. data/lib/microstation/scan/scan_trait.rb +48 -51
  48. data/lib/microstation/scan/subtype.rb +0 -10
  49. data/lib/microstation/scan/type.rb +9 -15
  50. data/lib/microstation/scan_trait.rb +13 -20
  51. data/lib/microstation/scanner.rb +1 -11
  52. data/lib/microstation/tag.rb +12 -21
  53. data/lib/microstation/tag_set.rb +52 -71
  54. data/lib/microstation/tag_set_trait.rb +6 -10
  55. data/lib/microstation/tagged_element.rb +16 -28
  56. data/lib/microstation/template.rb +15 -14
  57. data/lib/microstation/template_info.rb +35 -49
  58. data/lib/microstation/template_runner.rb +14 -22
  59. data/lib/microstation/text.rb +15 -19
  60. data/lib/microstation/text_node.rb +17 -26
  61. data/lib/microstation/ts/attribute.rb +16 -20
  62. data/lib/microstation/ts/instance.rb +28 -38
  63. data/lib/microstation/ts/tagset_trait.rb +5 -12
  64. data/lib/microstation/types.rb +0 -3
  65. data/lib/microstation/version.rb +1 -3
  66. data/lib/microstation/wrap.rb +3 -10
  67. data/lib/microstation.rb +57 -72
  68. data/spec/microstation/app_spec.rb +49 -46
  69. data/spec/microstation/configuration_spec.rb +45 -43
  70. data/spec/microstation/drawing_spec.rb +103 -101
  71. data/spec/microstation/functions_spec.rb +18 -12
  72. data/spec/microstation/tag_set_spec.rb +57 -55
  73. data/spec/microstation/template_spec.rb +41 -42
  74. data/spec/microstation/text_node_spec.rb +16 -14
  75. data/spec/microstation/text_spec.rb +10 -8
  76. data/spec/microstation_spec.rb +18 -17
  77. data/spec/spec_helper.rb +18 -18
  78. metadata +36 -22
@@ -1,53 +1,51 @@
1
1
  module Microstation
2
-
3
2
  class Capabilities
4
-
5
3
  attr_reader :variable, :capabilities
6
4
 
7
- def initialize(config,variable)
5
+ def initialize(config, variable)
8
6
  @config = config
9
7
  @variable = variable
10
8
  @capabilities = get_capabilities
11
9
  end
12
10
 
13
11
  def get_capabilities
14
- @capabilities = @config[variable].split(';')
12
+ @capabilities = @config[variable].split(";")
15
13
  end
16
14
 
17
-
18
15
  def search(name)
19
- @capabilities.select{|c| c =~ Regexp.new(Regexp.escape(name), Regexp::IGNORECASE)}
16
+ @capabilities.select { |c| c =~ Regexp.new(Regexp.escape(name), Regexp::IGNORECASE) }
20
17
  end
21
18
 
22
19
  def enabled
23
- @capabilities.select{|c| c.start_with?('+')}
20
+ @capabilities.select { |c| c.start_with?("+") }
24
21
  end
25
22
 
26
23
  def disabled
27
- @capabilities.select{|c| c.start_with?('-')}
24
+ @capabilities.select { |c| c.start_with?("-") }
28
25
  end
29
26
 
30
27
  def enabled?(name)
31
28
  capa = remove_prefix(name)
32
- @capabilities.any?{|c| c == "+#{capa}"}
29
+ @capabilities.any? { |c| c == "+#{capa}" }
33
30
  end
34
31
 
35
32
  def disabled?(name)
36
33
  capa = remove_prefix(name)
37
- @capabilities.any?{|c| c == "-#{capa}"}
34
+ @capabilities.any? { |c| c == "-#{capa}" }
38
35
  end
39
36
 
40
37
  def write_configuration
41
- caps = @capabilities.uniq.join(';')
38
+ caps = @capabilities.uniq.join(";")
42
39
  @config.set!(variable, caps)
43
40
  end
44
41
 
45
42
  def prepend(value)
46
- @config.prepend(variable,value)
43
+ @config.prepend(variable, value)
47
44
  end
48
45
 
49
46
  def enable(name)
50
47
  return if enabled?(name) && !disabled?(name)
48
+
51
49
  capa = remove_prefix(name)
52
50
  @capabilities.delete("-#{capa}")
53
51
  @capabilities.unshift("+#{capa}")
@@ -57,7 +55,8 @@ module Microstation
57
55
  end
58
56
 
59
57
  def disable(name)
60
- return if disabled?(name) && !enabled?(name)
58
+ return if disabled?(name) && !enabled?(name)
59
+
61
60
  capa = remove_prefix(name)
62
61
  capabilities.delete("+#{name}")
63
62
  @capabilities.unshift("-#{capa}")
@@ -67,76 +66,67 @@ module Microstation
67
66
  end
68
67
 
69
68
  def remove_prefix(name)
70
- if name =~ /[+-](.+)/
71
- name = Regexp.last_match(1)
72
- end
69
+ name = Regexp.last_match(1) if name =~ /[+-](.+)/
73
70
  name
74
71
  end
75
-
76
-
77
72
  end
78
73
 
79
74
  class VariableDefined < ::StandardError
80
75
  end
81
76
 
82
-
83
77
  class App
84
-
85
78
  def with_config
86
-
87
79
  end
88
-
89
80
  end
90
81
 
91
82
  class Configuration
92
-
93
83
  def initialize(app)
94
84
  @app = app
95
85
  end
96
86
 
97
- def prepend(variable,value)
87
+ def prepend(variable, value)
98
88
  if exists?(variable)
99
89
  old_value = get(variable)
100
90
  new_value = "#{value};#{old_value}"
101
91
  else
102
92
  new_value = value.to_s
103
93
  end
104
- set!(variable,new_value)
94
+ set!(variable, new_value)
105
95
  end
106
96
 
107
- def append(variable,value)
97
+ def append(variable, value)
108
98
  if exists?(variable)
109
99
  old_value = get(variable)
110
100
  new_value = "#{old_value};#{value}"
111
101
  else
112
102
  new_value = value.to_s
113
103
  end
114
- set!(variable,new_value)
104
+ set!(variable, new_value)
115
105
  end
116
106
 
117
107
  def [](variable)
118
108
  return nil unless exists? variable
109
+
119
110
  get(variable)
120
111
  end
121
112
 
122
-
123
113
  def remove_variable(variable)
124
114
  workspace.RemoveConfigurationVariable variable
125
115
  end
126
116
 
127
- def set(key,value,options = {})
128
- raise VariableDefined unless should_update?(key,options)
129
- set!(key,value)
130
- end
117
+ def set(key, value, options = {})
118
+ raise VariableDefined unless should_update?(key, options)
131
119
 
132
- def set!(key,value)
133
- self.remove_variable(key)
134
- workspace.AddConfigurationVariable(key,value)
120
+ set!(key, value)
135
121
  end
136
122
 
123
+ def set!(key, value)
124
+ remove_variable(key)
125
+ workspace.AddConfigurationVariable(key, value)
126
+ end
137
127
 
138
- def []=(key,value)
139
- set(key,value)
128
+ def []=(key, value)
129
+ set(key, value)
140
130
  end
141
131
 
142
132
  def exists?(value)
@@ -144,15 +134,15 @@ module Microstation
144
134
  end
145
135
 
146
136
  def capabilities_all
147
- @workmode_all ||= Capabilities.new(self,'_USTN_CAPABILITY')
137
+ @workmode_all ||= Capabilities.new(self, "_USTN_CAPABILITY")
148
138
  end
149
139
 
150
-
151
140
  def expand(string)
152
141
  workspace.ExpandConfigurationVariable(string)
153
142
  end
154
143
 
155
144
  private
145
+
156
146
  def workspace
157
147
  @app.active_workspace
158
148
  end
@@ -161,17 +151,15 @@ module Microstation
161
151
  workspace.ConfigurationVariableValue(variable)
162
152
  end
163
153
 
164
- def should_update?(key,options={force: false})
154
+ def should_update?(key, options = {force: false})
165
155
  return true unless exists? key
166
- force = options.fetch(:force){ false}
167
- return !!force
168
- end
169
156
 
157
+ force = options.fetch(:force) { false }
158
+ !!force
159
+ end
170
160
  end
171
161
 
172
-
173
162
  class App
174
-
175
163
  def capabilities(mode = :all)
176
164
  case mode
177
165
  when :all
@@ -183,11 +171,6 @@ module Microstation
183
171
  else
184
172
  configuration_capabilities_all
185
173
  end
186
-
187
174
  end
188
-
189
175
  end
190
-
191
-
192
-
193
176
  end
@@ -1,23 +1,19 @@
1
1
  module Microstation
2
-
3
2
  module CriteriaCreationT
4
-
5
3
  def text_criteria
6
- app.scanners[:textual] || app.create_scanner(:textual){ include_textual}
4
+ app.scanners[:textual] || app.create_scanner(:textual) { include_textual }
7
5
  end
8
6
 
9
7
  def graphic_criteria
10
- app.scanners[:graphical] || app.create_scanner(:graphical){ ExcludeNonGraphical}
8
+ app.scanners[:graphical] || app.create_scanner(:graphical) { ExcludeNonGraphical }
11
9
  end
12
10
 
13
11
  def tags_criteria
14
- app.scanners[:tags] || app.create_scanner(:tags){ include_tags}
12
+ app.scanners[:tags] || app.create_scanner(:tags) { include_tags }
15
13
  end
16
14
 
17
15
  def cells_criteria
18
- app.scanners[:cells] || app.create_scanner(:cells){ include_cells}
16
+ app.scanners[:cells] || app.create_scanner(:cells) { include_cells }
19
17
  end
20
-
21
18
  end
22
-
23
19
  end
@@ -1,15 +1,13 @@
1
- require_relative 'pdf_support'
2
- require 'fileutils'
1
+ require_relative "pdf_support"
2
+ require "fileutils"
3
3
  module Microstation
4
-
5
4
  class Dir
6
-
7
5
  include PdfSupport
8
6
  include FileUtils::Verbose
9
7
 
10
8
  attr_reader :dir, :relative_pdf_path
11
9
 
12
- def initialize(dir,pdf_path=nil)
10
+ def initialize(dir, pdf_path = nil)
13
11
  @dir = Pathname(dir).expand_path
14
12
  @relative_pdf_path = set_relative_pdf_path(pdf_path)
15
13
  end
@@ -24,7 +22,7 @@ module Microstation
24
22
  end
25
23
 
26
24
  def ==(other)
27
- self.dir == other.dir && self.relative_pdf_path == other.relative_pdf_path
25
+ dir == other.dir && relative_pdf_path == other.relative_pdf_path
28
26
  end
29
27
 
30
28
  def to_path
@@ -43,7 +41,6 @@ module Microstation
43
41
  path.exist?
44
42
  end
45
43
 
46
-
47
44
  def mkdir
48
45
  @dir.mkdir
49
46
  end
@@ -53,23 +50,21 @@ module Microstation
53
50
  end
54
51
 
55
52
  def +(other)
56
- self.class.new( self.path + other)
53
+ self.class.new(path + other)
57
54
  end
58
55
 
59
-
60
- def copy(drawing,dir)
56
+ def copy(drawing, dir)
61
57
  cp drawing, dir
62
58
  end
63
59
 
64
- def select_by_name( re)
60
+ def select_by_name(re)
65
61
  re = Regexp.new(re)
66
- drawing_files.select{|n| n.to_path =~ re}
62
+ drawing_files.select { |n| n.to_path =~ re }
67
63
  end
68
64
 
69
-
70
65
  def find_by_name(re)
71
66
  re = Regexp.new(re)
72
- drawing_files.find{|n| n.to_path =~ re}
67
+ drawing_files.find { |n| n.to_path =~ re }
73
68
  end
74
69
 
75
70
  def drawings
@@ -81,13 +76,13 @@ module Microstation
81
76
  end
82
77
 
83
78
  def sort(array_of_files)
84
- sort_lambda = @sort_by || lambda{|f| f.path.to_s}
79
+ sort_lambda = @sort_by || lambda { |f| f.path.to_s }
85
80
  array_of_files.sort_by(&sort_lambda)
86
81
  end
87
82
 
88
83
  def drawing_files
89
84
  return @drawing_files if @drawing_files
90
- set_drawing_files(drawings.map{|dwg| Microstation::Drawing::File.new(dwg)} )
85
+ set_drawing_files(drawings.map { |dwg| Microstation::Drawing::File.new(dwg) })
91
86
  @drawing_files
92
87
  end
93
88
 
@@ -95,14 +90,12 @@ module Microstation
95
90
  @drawing_files = sort(dfiles)
96
91
  end
97
92
 
98
-
99
93
  def pdf_generation_complete?
100
- drawing_files.all?{|d| not d.needs_pdf?}
94
+ drawing_files.all? { |d| !d.needs_pdf? }
101
95
  end
102
96
 
103
-
104
97
  def pdf_files(dir = pdf_dirname)
105
- sort(drawing_files).map{|p| p.pdf_name(dir)}
98
+ sort(drawing_files).map { |p| p.pdf_name(dir) }
106
99
  end
107
100
 
108
101
  def concat_pdfs(files)
@@ -110,12 +103,12 @@ module Microstation
110
103
  end
111
104
 
112
105
  def drawing_files_needing_pdf(dir = pdf_dirname)
113
- drawing_files.select{|d| d.needs_pdf?(dir) }
106
+ drawing_files.select { |d| d.needs_pdf?(dir) }
114
107
  end
115
108
 
116
109
  def print_pdfs(dir = pdf_dirname)
117
- with_drawing_files( drawing_files_needing_pdf) do |drawing|
118
- drawing.save_as_pdf(:dir => dir)
110
+ with_drawing_files(drawing_files_needing_pdf) do |drawing|
111
+ drawing.save_as_pdf(dir: dir)
119
112
  end
120
113
  end
121
114
 
@@ -125,33 +118,30 @@ module Microstation
125
118
  end
126
119
 
127
120
  def find_pdftk(dirs = nil)
128
- require 'pdf_forms'
129
- @pdftk = PdfForms.new('e:/tools/pdftk-1.44/bin/pdftk.exe')
121
+ require "pdf_forms"
122
+ @pdftk = PdfForms.new("e:/tools/pdftk-1.44/bin/pdftk.exe")
130
123
  end
131
124
 
132
125
  def pdftk
133
- @pdftk ||= find_pdftk(dirs= nil)
126
+ @pdftk ||= find_pdftk(dirs = nil)
134
127
  end
135
128
 
136
-
137
- def concat_pdfs(files,name)
138
- pdftk.cat(files,name.to_s)
129
+ def concat_pdfs(files, name)
130
+ pdftk.cat(files, name.to_s)
139
131
  puts "generated #{name}"
140
132
  end
141
133
 
142
-
143
-
144
134
  def get_meta_for_drawings
145
135
  @drawing_files = nil
146
136
  files = []
147
- with_drawing_files( drawings) do |drawing|
137
+ with_drawing_files(drawings) do |drawing|
148
138
  files << Microstation::Drawing::File.from_drawing(drawing)
149
139
  end
150
140
  set_drawing_files(files)
151
141
  end
152
142
 
153
143
  def with_drawing_files(dwgs = drawing_files, &block)
154
- Microstation.with_drawings(dwgs,&block)
144
+ Microstation.with_drawings(dwgs, &block)
155
145
  end
156
146
 
157
147
  def pdf_dirname
@@ -167,22 +157,15 @@ module Microstation
167
157
  Pathname(rel_path)
168
158
  end
169
159
 
170
-
171
160
  def relative_pdf_path=(path)
172
161
  @relative_pdf_path = set_relative_path(path)
173
162
  end
174
-
175
-
176
-
177
163
  end
178
164
  end
179
165
 
180
166
  module Microstation
181
-
182
167
  class Drawing
183
-
184
168
  class File
185
-
186
169
  include PdfSupport
187
170
 
188
171
  attr_reader :keywords, :creator, :path
@@ -197,7 +180,6 @@ module Microstation
197
180
  @path.to_path
198
181
  end
199
182
 
200
-
201
183
  def initialize(path)
202
184
  @path = Pathname(path)
203
185
  end
@@ -210,12 +192,10 @@ module Microstation
210
192
  @path.dirname
211
193
  end
212
194
 
213
- def drawing=(drawing)
214
- @drawing = drawing
215
- end
195
+ attr_writer :drawing
216
196
 
217
197
  def mtime
218
- self.path.mtime
198
+ path.mtime
219
199
  end
220
200
 
221
201
  def title
@@ -223,11 +203,11 @@ module Microstation
223
203
  end
224
204
 
225
205
  def app_open_drawing(app, &block)
226
- draw = app.open_drawing(self.path,&block)
206
+ draw = app.open_drawing(path, &block)
227
207
  end
228
208
 
229
209
  def open_drawing(&block)
230
- Microstation.open_drawing(self.path,&block)
210
+ Microstation.open_drawing(path, &block)
231
211
  end
232
212
 
233
213
  def get_meta(dwg)
@@ -235,18 +215,6 @@ module Microstation
235
215
  @keywords = dwg.keywords
236
216
  @creator = dwg.creator
237
217
  end
238
-
239
218
  end
240
-
241
-
242
219
  end
243
220
  end
244
-
245
-
246
-
247
-
248
-
249
-
250
-
251
-
252
-
@@ -1,11 +1,9 @@
1
1
  module Microstation
2
-
3
2
  def self.directory(path)
4
3
  Directory.new(path)
5
4
  end
6
5
 
7
6
  class Directory
8
-
9
7
  def self.drawings_in_dir(dir)
10
8
  new(dir).drawings
11
9
  end
@@ -21,7 +19,7 @@ module Microstation
21
19
  end
22
20
 
23
21
  def find_drawing(name)
24
- drawings.find{|pn| pn.to_s == name }
22
+ drawings.find { |pn| pn.to_s == name }
25
23
  end
26
24
 
27
25
  def drawings
@@ -37,10 +35,7 @@ module Microstation
37
35
  end
38
36
 
39
37
  def templates
40
- Pathname.glob(path + '*.yaml')
38
+ Pathname.glob(path + "*.yaml")
41
39
  end
42
-
43
-
44
40
  end
45
-
46
41
  end