microstation 0.4.1 → 0.8.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. checksums.yaml +7 -0
  2. data/.autotest +23 -23
  3. data/.rspec +2 -2
  4. data/Gemfile +29 -10
  5. data/History.txt +6 -6
  6. data/LICENSE.adoc +22 -0
  7. data/Manifest.txt +91 -60
  8. data/README.adoc +131 -0
  9. data/Rakefile +72 -30
  10. data/bin/dgn2pdf +36 -37
  11. data/bin/dgn_template +107 -0
  12. data/bin/pw_print +35 -0
  13. data/cad_files/drawing_faatitle_in_non_default_model.dgn +0 -0
  14. data/cad_files/drawing_no_block.dgn +0 -0
  15. data/cad_files/drawing_with_3_block.dgn +0 -0
  16. data/cad_files/drawing_with_block.dgn +0 -0
  17. data/cad_files/drawing_with_text.dgn +0 -0
  18. data/cad_files/seed2d.dgn +0 -0
  19. data/cad_files/seed3d.dgn +0 -0
  20. data/lib/microstation/app.rb +781 -286
  21. data/lib/microstation/cad_input_queue.rb +100 -25
  22. data/lib/microstation/cell.rb +191 -0
  23. data/lib/microstation/changer.rb +70 -0
  24. data/lib/microstation/configuration.rb +193 -57
  25. data/lib/microstation/criteria_creation_t.rb +23 -0
  26. data/lib/microstation/dir.rb +252 -252
  27. data/lib/microstation/directory.rb +46 -0
  28. data/lib/microstation/drawing.rb +686 -189
  29. data/lib/microstation/element.rb +311 -0
  30. data/lib/microstation/enumerator.rb +32 -29
  31. data/lib/microstation/errors.rb +17 -0
  32. data/lib/microstation/event_handler.rb +28 -0
  33. data/lib/microstation/ext/pathname.rb +23 -25
  34. data/lib/microstation/ext/win32ole.rb +7 -0
  35. data/lib/microstation/extensions/faa.rb +124 -0
  36. data/lib/microstation/file_tests.rb +68 -0
  37. data/lib/microstation/functions.rb +60 -0
  38. data/lib/microstation/graphics.rb +35 -0
  39. data/lib/microstation/line.rb +19 -0
  40. data/lib/microstation/model.rb +45 -0
  41. data/lib/microstation/model_trait.rb +189 -0
  42. data/lib/microstation/ole_cad_input_message.rb +101 -0
  43. data/lib/microstation/ole_helper.rb +152 -0
  44. data/lib/microstation/pdf_support.rb +40 -40
  45. data/lib/microstation/point3d.rb +71 -0
  46. data/lib/microstation/primitive_command_interface.rb +66 -0
  47. data/lib/microstation/properties.rb +61 -57
  48. data/lib/microstation/property_handler.rb +48 -0
  49. data/lib/microstation/scan/color.rb +38 -38
  50. data/lib/microstation/scan/criteria.rb +89 -85
  51. data/lib/microstation/scan/klass.rb +43 -43
  52. data/lib/microstation/scan/level.rb +38 -38
  53. data/lib/microstation/scan/line_style.rb +45 -45
  54. data/lib/microstation/scan/line_weight.rb +33 -33
  55. data/lib/microstation/scan/range.rb +19 -0
  56. data/lib/microstation/scan/scan_trait.rb +51 -0
  57. data/lib/microstation/scan/subtype.rb +40 -40
  58. data/lib/microstation/scan/type.rb +134 -109
  59. data/lib/microstation/scan_trait.rb +62 -0
  60. data/lib/microstation/scanner.rb +24 -24
  61. data/lib/microstation/tag.rb +87 -58
  62. data/lib/microstation/tag_set.rb +385 -280
  63. data/lib/microstation/tag_set_trait.rb +51 -0
  64. data/lib/microstation/tagged_element.rb +105 -0
  65. data/lib/microstation/template.rb +90 -84
  66. data/lib/microstation/template_info.rb +172 -0
  67. data/lib/microstation/template_runner.rb +65 -0
  68. data/lib/microstation/text.rb +79 -54
  69. data/lib/microstation/text_node.rb +124 -74
  70. data/lib/microstation/ts/attribute.rb +140 -139
  71. data/lib/microstation/ts/instance.rb +146 -112
  72. data/lib/microstation/ts/tagset_trait.rb +49 -0
  73. data/lib/microstation/types.rb +91 -91
  74. data/lib/microstation/version.rb +5 -0
  75. data/lib/microstation/wrap.rb +28 -214
  76. data/lib/microstation.rb +252 -88
  77. data/plot/pdf-bw.plt +164 -164
  78. data/plot/pdf.plt +163 -163
  79. data/plot/png.plt +383 -383
  80. data/plot/tiff.plt +384 -384
  81. data/plot/wmbw.tbl +324 -66
  82. data/plot/wmcolor.tbl +62 -62
  83. data/spec/microstation/app_spec.rb +184 -0
  84. data/spec/microstation/configuration_spec.rb +131 -0
  85. data/spec/microstation/drawing_spec.rb +245 -0
  86. data/spec/microstation/functions_spec.rb +36 -0
  87. data/spec/microstation/tag_set_spec.rb +159 -0
  88. data/spec/microstation/template_spec.rb +159 -0
  89. data/spec/microstation/text_node_spec.rb +67 -0
  90. data/spec/microstation/text_spec.rb +42 -0
  91. data/spec/microstation_spec.rb +47 -36
  92. data/spec/spec_helper.rb +97 -31
  93. metadata +308 -84
  94. data/.gemtest +0 -0
  95. data/README.txt +0 -75
  96. data/lib/microstation/attributes.rb +0 -35
  97. data/lib/microstation/extensions/hash.rb +0 -27
  98. data/spec/app_spec.rb +0 -267
  99. data/spec/configuration_spec.rb +0 -122
  100. data/spec/drawing_spec.rb +0 -247
  101. data/spec/drawings/new_drawing.dgn +0 -0
  102. data/spec/drawings/test.dgn +0 -0
  103. data/spec/drawings/test1.dgn +0 -0
  104. data/spec/drawings/testfile.pdf +0 -0
  105. data/spec/enumerator_spec.rb +0 -60
  106. data/spec/scanner_spec.rb +0 -155
  107. data/spec/spec_app.rb +0 -11
  108. data/spec/tag_set_spec.rb +0 -123
  109. data/spec/text_node_spec.rb +0 -92
  110. data/spec/text_spec.rb +0 -62
@@ -0,0 +1,60 @@
1
+ require 'dry/monads'
2
+ module Microstation
3
+
4
+ class App
5
+ include Dry::Monads[:result]
6
+ end
7
+
8
+ module Functions
9
+
10
+ extend Dry::Monads[:result]
11
+
12
+ def get_points_by_rectangle
13
+ queue = cad_input_queue
14
+ queue.show_command('Get points by block')
15
+ start_point = queue.get_point
16
+ if start_point.failure?
17
+ return Failure(:point1_reset)
18
+ end
19
+ queue.send_command "PLACE BLOCK"
20
+ queue.send_data_point start_point.value!
21
+ end_point = queue.get_point
22
+ if end_point.failure?
23
+ return Failure(:point2_reset)
24
+ end
25
+ Success([start_point.value!, end_point.value!])
26
+ end
27
+
28
+ def get_points_by_line
29
+ queue = cad_input_queue
30
+ queue.show_command("Get points by line")
31
+ start_point = queue.get_point
32
+ if start_point.failure?
33
+ return Failure(:point1_reset)
34
+ end
35
+ queue.send_command "PLACE LINE"
36
+ queue.send_data_point start_point.value!
37
+ end_point = queue.get_point("Enter next vertex")
38
+ if end_point.failure?
39
+ return Failure(:point2_reset)
40
+ end
41
+ Success([start_point.value!, end_point.value!])
42
+ end
43
+
44
+ def clear_ui
45
+ cad_input_queue.clear_ui
46
+ end
47
+
48
+ def get_point
49
+ cad_input_queue.get_point
50
+ end
51
+
52
+
53
+ end
54
+
55
+
56
+ class App
57
+ include Functions
58
+ end
59
+ end
60
+
@@ -0,0 +1,35 @@
1
+ module Microstation
2
+
3
+ module Graphics
4
+
5
+
6
+ def line(p1,p2,el = WIN32OLE_VARIANT::Nothing)
7
+ pt1 = app.to_ole_point3d(p1)
8
+ pt2 = app.to_ole_point3d(p2)
9
+ begin
10
+ ole = app.ole_obj.CreateLineElement2(el,pt1,pt2)
11
+ rescue Exception => ex
12
+ binding.pry
13
+ return nil
14
+ end
15
+ add_element(ole) if ole
16
+ end
17
+
18
+
19
+ def line_from_pts(pts, el = WIN32OLE_VARIANT::Nothing)
20
+ ole_points = pts.map{ |pt| app.to_ole_point3d(pt) }
21
+ ole = app.ole_obj.CreateLineElement1(el, ole_points)
22
+ if ole
23
+ add_element(ole)
24
+ else
25
+ binding.pry
26
+ end
27
+ rescue Exception => e
28
+ binding.pry
29
+ return nil
30
+ end
31
+ end
32
+
33
+
34
+ end
35
+
@@ -0,0 +1,19 @@
1
+ require 'microstation/element'
2
+
3
+ module Microstation
4
+
5
+ class Line < Element
6
+
7
+ def length
8
+ ole_obj.Length
9
+ end
10
+
11
+
12
+ def vertices
13
+ ole_obj.AsVertexList
14
+ n = ole_obj.VerticesCount
15
+ list = ole_obj.GetVertices
16
+ list
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,45 @@
1
+ #require_relative 'scan/scan_trait'
2
+ require 'microstation/wrap'
3
+ require_relative 'model_trait'
4
+
5
+ #require_relative 'ts/tagset_trait'
6
+ #require_relative 'graphics'
7
+ #require_relative 'ts/instance'
8
+
9
+
10
+ module Microstation
11
+
12
+ class DefaultModel
13
+
14
+ include ::Microstation::ModelTrait
15
+
16
+ attr_reader :app,:ole_obj
17
+
18
+ def initialize(app,ole)
19
+ @app = app
20
+ @ole_obj = ole
21
+ end
22
+
23
+ def drawing
24
+ @drawing ||= ::Microstation::Drawing.from_ole_obj(app,ole_obj)
25
+ end
26
+
27
+
28
+ end
29
+
30
+
31
+ class Model
32
+
33
+ include ::Microstation::ModelTrait
34
+
35
+ attr_reader :app,:drawing,:ole_obj
36
+
37
+ def initialize(app,drawing,ole)
38
+ @app = app
39
+ @drawing = drawing
40
+ @ole_obj = ole
41
+ end
42
+
43
+ end
44
+
45
+ end
@@ -0,0 +1,189 @@
1
+ require_relative 'graphics'
2
+ require_relative 'scan_trait'
3
+
4
+ module Microstation
5
+ module ModelTrait
6
+
7
+ include Graphics
8
+
9
+ include ScanTrait
10
+ # include TS::TagSetTrait
11
+
12
+ def name
13
+ ole_obj.name
14
+ end
15
+
16
+ def find_by_id(id)
17
+ ele = ole_obj.GetElementById64(id) rescue nil
18
+ return nil unless ele
19
+ app.ole_to_ruby(ele)
20
+ end
21
+
22
+ def active?
23
+ ole_obj.IsActive
24
+ end
25
+
26
+ def get_selected_elements
27
+ Enumerator.new(ole_obj.GetSelectedElements,app)
28
+ end
29
+
30
+ def get_selected_text
31
+ get_selected_elements.select{|t| t.textual?}
32
+ end
33
+
34
+ def get_matching_text(re)
35
+ result = []
36
+ get_selected_text.each do |t|
37
+ md = re.match( t)
38
+ if md
39
+ if block_given?
40
+ yield t,md
41
+ else
42
+ result << t
43
+ end
44
+ end
45
+ result
46
+ end
47
+ end
48
+
49
+ def change_text_suffix(reg,offset)
50
+ get_matching_text(reg) do |t,md|
51
+ pre = md[1]
52
+ suff = Integer( md[2] ) + offset
53
+ t.replace "#{pre}#{suff}"
54
+ end
55
+ end
56
+
57
+ def unselect_element(el)
58
+ ole_obj.UnselectElement(el.ole_obj)
59
+ end
60
+
61
+ def select_element(el)
62
+ ole_obj.SelectElement(el.ole_obj)
63
+ end
64
+
65
+ def readonly?
66
+ ole_obj.IsReadOnly
67
+ end
68
+
69
+ def activate
70
+ ole_obj.Activate
71
+ end
72
+
73
+ def locked?
74
+ ole_obj.IsLocked?
75
+ end
76
+
77
+ def to_s
78
+ "Microstation::Model-#{name}"
79
+ end
80
+
81
+
82
+ def add_element(el)
83
+ if el.respond_to? :ole_obj
84
+ el = el.ole_obj
85
+ ole_obj.AddElement(el)
86
+ self
87
+ end
88
+ end
89
+
90
+ def select_tagset_instances
91
+
92
+ end
93
+
94
+ def scan_tags_filtered( ts_name: nil, base_element_id: nil,&block)
95
+ case [ts_name, base_element_id]
96
+ in [nil, nil]
97
+ scan_tags(&block)
98
+ in [String,nil]
99
+ scan_tags.select{ |t| t.tagset_name == ts_name }
100
+ in [String, Numeric]
101
+ scan_tags.select{ |t| t.tagset_name == ts_name && t.base_element_id == base_element_id }
102
+ in [nil, Numeric]
103
+ scan_tags.select{ |t| t.base_element_id == base_element_id }
104
+
105
+ end
106
+ end
107
+
108
+ def tags_to_hash(tags)
109
+ return to_enum(__callee__,tags) unless block_given?
110
+ tsets = tags.group_by{ |t| t.tagset_name }
111
+ tsets.each do |tsname, tags|
112
+ elements = tags.group_by{|t| t.base_element_id}
113
+ elements.each do |id, tag_elts|
114
+ result_hash = {
115
+ name: tsname,
116
+ model: name,
117
+ tags: tag_elts,
118
+ base_element_id: id,
119
+ }
120
+ yield result_hash
121
+ end
122
+ end
123
+ end
124
+
125
+ def get_tagsets_in_model_hash(ts_name: nil, base_element_id: nil,&block)
126
+ tags = scan_tags_filtered(ts_name: ts_name, base_element_id: base_element_id)
127
+ tags_to_hash(tags, &block)
128
+ end
129
+
130
+ def get_tagsets_in_model_hash_old
131
+ results = []
132
+ tsets = scan_tags.group_by{|t| t.tagset_name}
133
+ tsets.each do |tsname, tags|
134
+ elements = tags.group_by{|t| t.base_element_id}
135
+ elements.each do |id, tag_elts|
136
+ result_hash = {
137
+ name: tsname,
138
+ model: name,
139
+ tags: tag_elts,
140
+ base_element_id: id,
141
+ }
142
+ if block_given?
143
+ yield result_hash
144
+ else
145
+ results << result_hash
146
+ end
147
+ end
148
+ results unless block_given?
149
+ end
150
+
151
+ end
152
+
153
+
154
+ # Scan the model with
155
+ # @param [Scan::Criteria] criteria - the criteria to scan
156
+ # @yield the item
157
+ def scan_model(criteria=nil)
158
+ # binding.pry
159
+ criteria = criteria || create_scanner(:nullscanner)
160
+ scan_result = ole_run_scan(criteria)
161
+ return [] unless scan_result
162
+ # binding.pry
163
+ scan_enum = ::Microstation::Enumerator.new(scan_result, app)
164
+ result = []
165
+ if block_given?
166
+ scan_enum.each do |item|
167
+ yield item
168
+ end
169
+ else
170
+ scan_enum.each do |item|
171
+ result << item
172
+ end
173
+ end
174
+
175
+ return result unless block_given?
176
+ end
177
+
178
+
179
+ private
180
+
181
+ def ole_run_scan(criteria)
182
+ criteria.resolve
183
+ scan_result = self.ole_obj.Scan(criteria.ole_obj) rescue nil
184
+ end
185
+
186
+
187
+ end
188
+
189
+ end
@@ -0,0 +1,101 @@
1
+ module Microstation
2
+
3
+
4
+ module InputType
5
+
6
+ Command = 1
7
+ Reset = 2
8
+ DataPoint = 3
9
+ Keyin = 4
10
+ Any = 5
11
+ Unassigned = 6
12
+
13
+ end
14
+
15
+
16
+ class OLE_CadInputMessage
17
+
18
+ include WIN32OLE::VARIANT
19
+ attr_reader :lastargs,:ole_obj, :app
20
+
21
+
22
+ def initialize(ole,app)
23
+ @ole_obj = ole
24
+ @app = app
25
+ end
26
+
27
+ def reset?
28
+ input_type == InputType::Reset
29
+ end
30
+
31
+ def command?
32
+ input_type == InputType::Command
33
+ end
34
+
35
+ def data_point?
36
+ input_type == InputType::DataPoint
37
+ end
38
+
39
+ def key_in?
40
+ input_type == InputType::Keyin
41
+ end
42
+
43
+ def any?
44
+ input_type == InputType::Any
45
+ end
46
+
47
+ def unassigned?
48
+ input_type == InputType::Unassigned
49
+ end
50
+
51
+ def input_type
52
+ @input_type ||= get_input_type
53
+ end
54
+
55
+ # MsdCadInputType InputType
56
+ def get_input_type()
57
+ ole_obj.InputType
58
+ end
59
+
60
+ # BSTR Keyin
61
+ def get_keyin()
62
+ ret = ole_obj._getproperty(1610743809, [], [])
63
+ @lastargs = WIN32OLE::ARGV
64
+ ret
65
+ end
66
+
67
+ # Point3d Point
68
+ def get_point()
69
+ app.to_point3d(ole_obj.Point)
70
+ end
71
+
72
+ # BSTR CommandKeyin
73
+ def get_command_keyin()
74
+ ret = ole_obj._getproperty(1610743811, [], [])
75
+ @lastargs = WIN32OLE::ARGV
76
+ ret
77
+ end
78
+
79
+ # _View View
80
+ def get_view()
81
+ ret = ole_obj._getproperty(1610743812, [], [])
82
+ @lastargs = WIN32OLE::ARGV
83
+ ret
84
+ end
85
+
86
+ # Point3d ScreenPoint
87
+ def get_screen_point()
88
+ ret = ole_obj._getproperty(1610743813, [], [])
89
+ @lastargs = WIN32OLE::ARGV
90
+ ret
91
+ end
92
+
93
+ # I4 CursorButton
94
+ def get_cursor_button()
95
+ ret = ole_obj._getproperty(1610743814, [], [])
96
+ @lastargs = WIN32OLE::ARGV
97
+ ret
98
+ end
99
+ end
100
+
101
+ end
@@ -0,0 +1,152 @@
1
+ module OleHelper
2
+
3
+ def select_ole_type(name)
4
+ if name.class == String
5
+ name = Regexp.new(name)
6
+ end
7
+ reg = Regexp.new(name.source,Regexp::IGNORECASE)
8
+ typelib.ole_classes.select do |k|
9
+ reg =~ k.name
10
+ end
11
+ end
12
+
13
+ def select_ole_method(name)
14
+ if name.class == String
15
+ name = Regexp.new(name)
16
+ end
17
+ reg = Regexp.new(name.source,Regexp::IGNORECASE)
18
+ self.ole_methods.select do |k|
19
+ reg =~ k.name
20
+ end
21
+ end
22
+
23
+ def ole_classes
24
+ typelib.ole_classes
25
+ end
26
+
27
+ def create_ole_type(type)
28
+ WIN32OLE.new(type.guid)
29
+ end
30
+
31
+ def ole_classes_detail
32
+ s = String.new
33
+ ole_classes.sort_by{|k| k.ole_type}.each do |k|
34
+ s << "#{k.name}\n\n"
35
+ s << "Type: #{k.ole_type}\n"
36
+ s << "progid: #{k.progid}\n"
37
+ s << "quid: #{k.guid}\n"
38
+ s << "------------\n\n"
39
+ end
40
+ s
41
+ end
42
+
43
+
44
+ def ole_methods_detail
45
+ s = String.new
46
+ ole_methods.each do |m|
47
+ s << "Method #{m.name}\n\n"
48
+ s << "dispid: #{m.dispid}\n"
49
+ s << "Event? #{m.event?}\n"
50
+ s << "Event interface: #{m.event_interface}\n"
51
+ s << "invoke kind: #{m.invoke_kind}\n"
52
+ s << "return type: #{m.return_type_detail}\n"
53
+ s << "visible: #{m.visible?}\n"
54
+ s << "params...\n"
55
+ m.params.each do |p|
56
+ s << "Param Name: #{p.name}\n"
57
+ s << "Optional: #{p.optional?}\n"
58
+ s << "Output? #{p.output?}\n"
59
+ s << "Detail\n"
60
+ s << "#{p.ole_type_detail}"
61
+ s << "\n\n"
62
+ end
63
+ s << "------------\n\n"
64
+ end
65
+ s
66
+ end
67
+
68
+
69
+ def each_ole_type
70
+ return enum_for(:each_ole_type) unless block_given?
71
+ typelib.ole_classes.each do |t|
72
+ yield t
73
+ end
74
+ end
75
+
76
+ def get_ole_type(name)
77
+ if name.class == String
78
+ return ole_classes.find{|t| t.name == name}
79
+ end
80
+ reg = Regexp.new(name.source, Regexp::IGNORECASE)
81
+ ole_classes.find do |t|
82
+ t.name =~ name
83
+ end
84
+ end
85
+
86
+ def typelib
87
+ self.ole_typelib
88
+ end
89
+
90
+
91
+ end
92
+
93
+
94
+ class WIN32OLE
95
+
96
+ include OleHelper
97
+
98
+ end
99
+
100
+
101
+ # def select_ole_type(name)
102
+ # if name.class == String
103
+ # name = Regexp.new(name)
104
+ # end
105
+ # reg = Regexp.new(name.source,Regexp::IGNORECASE)
106
+ # typelib.ole_classes.select do |k|
107
+ # reg =~ k.name
108
+ # end
109
+ # end
110
+
111
+ # def select_ole_method(name)
112
+ # if name.class == String
113
+ # name = Regexp.new(name)
114
+ # end
115
+ # reg = Regexp.new(name.source,Regexp::IGNORECASE)
116
+ # ole_obj.ole_methods.select do |k|
117
+ # reg =~ k.name
118
+ # end
119
+ # end
120
+
121
+ # def ole_classes
122
+ # typelib.ole_classes
123
+ # end
124
+
125
+ # def create_ole_type(type)
126
+ # WIN32OLE.new(type.guid)
127
+ # end
128
+
129
+ # def each_ole_type
130
+ # return enum_for(:each_ole_type) unless block_given?
131
+ # typelib.ole_classes.each do |t|
132
+ # yield t
133
+ # end
134
+ # end
135
+
136
+ # def get_ole_type(name)
137
+ # if name.class == String
138
+ # name = Regexp.new name
139
+ # end
140
+ # reg = Regexp.new(name.source, Regexp::IGNORECASE)
141
+ # typelib.ole_classes.find do |t|
142
+ # t.name =~ name
143
+ # end
144
+ # end
145
+
146
+
147
+
148
+ # alias :find_ole_type :get_ole_type
149
+
150
+ # def typelib
151
+ # ole_obj.ole_typelib
152
+ # end
@@ -1,40 +1,40 @@
1
- module Microstation
2
-
3
-
4
- module PdfSupport
5
-
6
- def pdf_name(output_dir=nil)
7
- name = self.basename
8
- dir = output_dir || self.dirname
9
- pdfname = Pathname(name).ext('pdf')
10
- (dir + pdfname).expand_path
11
- end
12
-
13
- def pdf_exists?(output_dir = nil)
14
- pdf_name(output_dir).file?
15
- end
16
-
17
- def file_exists?(file)
18
- file.file?
19
- end
20
-
21
- def needs_pdf?(output_dir=nil)
22
- pdf_path = pdf_name(output_dir)
23
- !file_exists?(pdf_path) || pdf_older?(pdf_path)
24
- end
25
-
26
- def pdf_older?(pdf)
27
- self.mtime > pdf.mtime
28
- end
29
-
30
-
31
- def mtime
32
- self.path.mtime
33
- end
34
-
35
-
36
- end
37
-
38
-
39
- end
40
-
1
+ module Microstation
2
+
3
+
4
+ module PdfSupport
5
+
6
+ def pdf_name(output_dir=nil)
7
+ name = self.basename
8
+ dir = output_dir || self.dirname
9
+ pdfname = Pathname(name).ext('pdf')
10
+ (dir + pdfname).expand_path
11
+ end
12
+
13
+ def pdf_exists?(output_dir = nil)
14
+ pdf_name(output_dir).file?
15
+ end
16
+
17
+ def file_exists?(file)
18
+ file.file?
19
+ end
20
+
21
+ def needs_pdf?(output_dir=nil)
22
+ pdf_path = pdf_name(output_dir)
23
+ !file_exists?(pdf_path) || pdf_older?(pdf_path)
24
+ end
25
+
26
+ def pdf_older?(pdf)
27
+ self.mtime > pdf.mtime
28
+ end
29
+
30
+
31
+ def mtime
32
+ self.path.mtime
33
+ end
34
+
35
+
36
+ end
37
+
38
+
39
+ end
40
+