wortsammler 0.0.2 → 0.0.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.
- data/.gitignore +1 -0
- data/README.md +44 -1
- data/README.pdf +0 -0
- data/Rakefile +1 -1
- data/changelog.rb.txt +9 -0
- data/lib/wortsammler/class.Traceable.md.rb +7 -7
- data/lib/wortsammler/class.proolib.rb +103 -46
- data/lib/wortsammler/exe.wortsammler.rb +9 -318
- data/lib/wortsammler/version.rb +1 -1
- data/lib/wortsammler.rb +375 -2
- data/resources/default.latex +20 -21
- data/spec/wortsammler_spec.rb +18 -1
- data/testresults/wortsammler_testresults.html +89 -87
- data/testresults/wortsammler_testresults.log +4 -3
- data/wortsammler-gem.sublime-project +8 -0
- data/wortsammler.gemspec +1 -1
- metadata +6 -4
@@ -1,4 +1,5 @@
|
|
1
1
|
require "optparse" # for option parser
|
2
|
+
require 'wortsammler'
|
2
3
|
require 'wortsammler/log_helper'
|
3
4
|
require 'wortsammler/class.proolib.rb'
|
4
5
|
require 'wortsammler/class.Traceable.rb'
|
@@ -56,9 +57,9 @@ optparse = OptionParser.new do|opts|
|
|
56
57
|
|
57
58
|
opts.separator nil
|
58
59
|
|
59
|
-
options[:
|
60
|
-
opts.on( '-i', '--
|
61
|
-
options[:
|
60
|
+
options[:inputpath] = false
|
61
|
+
opts.on( '-i', '--inputpath PATH', 'set input file/project folder for processing') do|path|
|
62
|
+
options[:inputpath] = path
|
62
63
|
end
|
63
64
|
|
64
65
|
options[:manifest] = false
|
@@ -68,13 +69,13 @@ optparse = OptionParser.new do|opts|
|
|
68
69
|
|
69
70
|
opts.separator nil
|
70
71
|
|
71
|
-
options[:outputformats] =
|
72
|
-
opts.on( '-f', '--
|
73
|
-
options[:outputformats] = formatlist
|
72
|
+
options[:outputformats] = 'pdf'
|
73
|
+
opts.on( '-f', '--outputformats formatList', 'set the outputformat to formatList' ) do|formatlist|
|
74
|
+
options[:outputformats] = formatlist
|
74
75
|
end
|
75
76
|
|
76
77
|
options[:outputfolder] = false
|
77
|
-
opts.on( '-o', '--
|
78
|
+
opts.on( '-o', '--outputfolder PATH', 'set the output to PATH' ) do|path|
|
78
79
|
options[:outputfolder] = path
|
79
80
|
end
|
80
81
|
|
@@ -114,315 +115,5 @@ rescue RegexpError => error
|
|
114
115
|
end
|
115
116
|
|
116
117
|
|
117
|
-
module Wortsammler
|
118
|
-
def self.wortsammler_execute(options)
|
119
|
-
##
|
120
|
-
#
|
121
|
-
# print version info
|
122
|
-
#
|
123
|
-
if options[:version] then
|
124
|
-
puts "Wortsammler #{Wortsammler::VERSION}"
|
125
|
-
|
126
|
-
pandoc=`pandocx -v`.split("\n")[0] rescue pandoc="error running pandoc"
|
127
|
-
xetex=`xelatex -v`.split("\n")[0] rescue pandoc="error running xelatex"
|
128
|
-
|
129
|
-
puts "found #{pandoc}"
|
130
|
-
puts "found #{xetex}"
|
131
|
-
|
132
|
-
end
|
133
|
-
|
134
|
-
##
|
135
|
-
# initialize a project
|
136
|
-
#
|
137
|
-
if project_folder=options[:init] then
|
138
|
-
if File.exists?(project_folder)
|
139
|
-
$log.error "directory already exists: '#{project_folder}'"
|
140
|
-
exit(false)
|
141
|
-
end
|
142
|
-
Wortsammler::init_folders(project_folder)
|
143
|
-
end
|
144
|
-
|
145
|
-
|
146
|
-
##
|
147
|
-
#
|
148
|
-
# load the manifest
|
149
|
-
#
|
150
|
-
config=nil
|
151
|
-
if config_file=options[:manifest] then
|
152
|
-
config = ProoConfig.new(config_file)
|
153
|
-
end
|
154
|
-
|
155
|
-
##
|
156
|
-
# process input path
|
157
|
-
#
|
158
|
-
#
|
159
|
-
input_files=nil
|
160
|
-
if input_path = options[:input_path]
|
161
|
-
unless File.exists? input_path then
|
162
|
-
$log.error "path does not exist path '#{input_path}'"
|
163
|
-
exit(false)
|
164
|
-
end
|
165
|
-
if File.file?(input_path) #(RS_Mdc)
|
166
|
-
input_files=[input_path]
|
167
|
-
elsif File.exists?(input_path)
|
168
|
-
input_files=Dir["#{input_path}/**/*.md", "#{input_path}/**/*.markdown"]
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
##
|
173
|
-
#
|
174
|
-
# beautify markdown files
|
175
|
-
#
|
176
|
-
#
|
177
|
-
cleaner = PandocBeautifier.new($log)
|
178
|
-
|
179
|
-
if options[:beautify]
|
180
|
-
|
181
|
-
|
182
|
-
# process path
|
183
|
-
|
184
|
-
if input_files then
|
185
|
-
input_files.each{|f| cleaner.beautify(f)}
|
186
|
-
end
|
187
|
-
|
188
|
-
# process manifest
|
189
|
-
|
190
|
-
if config then
|
191
|
-
config.input.each{|f| cleaner.beautify(f)}
|
192
|
-
end
|
193
|
-
|
194
|
-
unless input_files or config
|
195
|
-
$log.error "no input specified. Please use -m or -i to specify input"
|
196
|
-
exit false
|
197
|
-
end
|
198
|
-
end
|
199
|
-
|
200
|
-
##
|
201
|
-
# process collect in markdown files
|
202
|
-
#
|
203
|
-
|
204
|
-
if options[:collect]
|
205
|
-
|
206
|
-
# collect by path
|
207
|
-
|
208
|
-
if input_files then
|
209
|
-
$log.warn "collect from path not yet implemented"
|
210
|
-
end
|
211
|
-
|
212
|
-
# collect by manifest
|
213
|
-
|
214
|
-
if config then
|
215
|
-
Wortsammler.collect_traces(config)
|
216
|
-
end
|
217
|
-
|
218
|
-
unless input_files or config
|
219
|
-
$log.error "no input specified. Please use -m or -i to specify input"
|
220
|
-
exit false
|
221
|
-
end
|
222
|
-
end
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
##
|
227
|
-
# process files
|
228
|
-
#
|
229
|
-
if options[:process]
|
230
|
-
|
231
|
-
if input_files then
|
232
|
-
|
233
|
-
if options[:outputformats] then
|
234
|
-
outputformats = options[:outputformats]
|
235
|
-
end
|
236
|
-
|
237
|
-
if options[:outputfolder] then
|
238
|
-
outputfolder = options[:outputfolder]
|
239
|
-
else
|
240
|
-
$log.error "no output folder specified"
|
241
|
-
exit false
|
242
|
-
end
|
243
|
-
|
244
|
-
unless File.exists?(outputfolder) then
|
245
|
-
$log.info "creating folder '#{outputfolder}'"
|
246
|
-
FileUtils.mkdir_p(outputfolder)
|
247
|
-
end
|
248
|
-
|
249
|
-
input_files.each{|f| cleaner.render_single_document(f, outputfolder, outputformats)}
|
250
|
-
end
|
251
|
-
|
252
|
-
# collect by manifest
|
253
|
-
|
254
|
-
if config then
|
255
|
-
cleaner.generateDocument(config.input,
|
256
|
-
config.outdir,
|
257
|
-
config.outname,
|
258
|
-
config.format,
|
259
|
-
config.vars,
|
260
|
-
config.editions,
|
261
|
-
config.snippets,
|
262
|
-
config)
|
263
|
-
end
|
264
|
-
|
265
|
-
unless input_files or config
|
266
|
-
$log.error "no input specified. Please use -m or -i to specify input"
|
267
|
-
exit false
|
268
|
-
end
|
269
|
-
end
|
270
|
-
|
271
|
-
end #execute
|
272
|
-
|
273
|
-
|
274
|
-
#
|
275
|
-
# This method can verify wortsammler options delivered by option parser
|
276
|
-
# @param options [Hash] Option hash delivered by option parser
|
277
|
-
#
|
278
|
-
# @return [Boolean] true if successful. otherwise exits the program
|
279
|
-
def self.verify_options(options)
|
280
|
-
if options[:input_path] or options[:manifest] then
|
281
|
-
unless options[:process] or options[:beautify] or options[:collect] then
|
282
|
-
$log.error "no procesing option (p, b, c) specified"
|
283
|
-
exit false
|
284
|
-
end
|
285
|
-
end
|
286
|
-
|
287
|
-
if options[:input_path] and options[:process] then
|
288
|
-
unless options[:outputfolder] then
|
289
|
-
$log.error "no output folder specified for input path"
|
290
|
-
exit false
|
291
|
-
end
|
292
|
-
end
|
293
|
-
|
294
|
-
true
|
295
|
-
end #verify_options
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
#
|
300
|
-
# Initialize a project directory. It creates a bunch of
|
301
|
-
# folders, a root document, a manifest and an intial rakefile
|
302
|
-
#
|
303
|
-
# @param root [String] [The path to the root folder of the sample project]
|
304
|
-
#
|
305
|
-
# @return [Boolean] [always true]
|
306
|
-
def self.init_folders(root)
|
307
|
-
|
308
|
-
folders=["ZSUPP_Manifests",
|
309
|
-
"ZGEN_Documents",
|
310
|
-
"ZSUPP_Tools",
|
311
|
-
"ZSUPP_Styles",
|
312
|
-
"ZGEN_RequirementsTracing",
|
313
|
-
"001_Main"
|
314
|
-
]
|
315
|
-
|
316
|
-
folders.each{|folder|
|
317
|
-
FileUtils.mkdir_p("#{root}/#{folder}")
|
318
|
-
}
|
319
|
-
|
320
|
-
resourcedir=File.dirname(__FILE__)+"/../../resources"
|
321
|
-
Dir["#{resourcedir}/*.yaml"].each{|f|
|
322
|
-
FileUtils.cp(f, "#{root}/ZSUPP_Manifests")
|
323
|
-
}
|
324
|
-
FileUtils.cp("#{resourcedir}/main.md", "#{root}/001_Main")
|
325
|
-
FileUtils.cp("#{resourcedir}/rakefile.rb", "#{root}/ZSUPP_Tools")
|
326
|
-
FileUtils.cp("#{resourcedir}/default.latex", "#{root}/ZSUPP_Styles")
|
327
|
-
FileUtils.cp("#{resourcedir}/logo.jpg", "#{root}/ZSUPP_Styles")
|
328
|
-
|
329
|
-
true
|
330
|
-
end
|
331
|
-
|
332
|
-
|
333
|
-
#
|
334
|
-
# This collects the traces in a doucment specified by a manifest
|
335
|
-
# @param config [ProolibConfig] the manifest model
|
336
|
-
#
|
337
|
-
# @return [type] no specific return
|
338
|
-
def self.collect_traces(config)
|
339
|
-
|
340
|
-
files = config.input # get the input files
|
341
|
-
rootdir = config.rootdir # get the root directory
|
342
|
-
|
343
|
-
downstream_tracefile = config.downstream_tracefile # String to save downstram filenames
|
344
|
-
reqtracefile_base = config.reqtracefile_base # string to determine the requirements tracing results
|
345
|
-
upstream_tracefiles = config.upstream_tracefiles # String to read upstream tracefiles
|
346
|
-
|
347
|
-
traceable_set = TraceableSet.new
|
348
|
-
|
349
|
-
# collect all traceables in input
|
350
|
-
files.each{|f|
|
351
|
-
x=TraceableSet.processTracesInMdFile(f)
|
352
|
-
traceable_set.merge(x)
|
353
|
-
}
|
354
|
-
|
355
|
-
# collect all upstream traceables
|
356
|
-
#
|
357
|
-
upstream_traceable_set=TraceableSet.new
|
358
|
-
unless upstream_tracefiles.nil?
|
359
|
-
upstream_tracefiles.each{|f|
|
360
|
-
x=TraceableSet.processTracesInMdFile(f)
|
361
|
-
upstream_traceable_set.merge(x)
|
362
|
-
}
|
363
|
-
end
|
364
|
-
|
365
|
-
# check undefined traces
|
366
|
-
all_traceable_set=TraceableSet.new
|
367
|
-
all_traceable_set.merge(traceable_set)
|
368
|
-
all_traceable_set.merge(upstream_traceable_set)
|
369
|
-
undefineds=all_traceable_set.undefined_ids
|
370
|
-
$log.warn "undefined traces: #{undefineds.join(' ')}" unless undefineds.empty?
|
371
|
-
|
372
|
-
|
373
|
-
# check duplicates
|
374
|
-
duplicates=all_traceable_set.duplicate_traces
|
375
|
-
if duplicates.count > 0
|
376
|
-
$logger.warn "duplicated trace ids found:"
|
377
|
-
duplicates.each{|d| d.each{|t| $log.warn "#{t.id} in #{t.info}"}}
|
378
|
-
end
|
379
|
-
|
380
|
-
# write traceables to the intermediate Tracing file
|
381
|
-
outname="#{rootdir}/#{reqtracefile_base}.md"
|
382
|
-
|
383
|
-
# poke ths sort order for the traceables
|
384
|
-
all_traceable_set.sort_order=config.traceSortOrder if config.traceSortOrder
|
385
|
-
traceable_set.sort_order=config.traceSortOrder if config.traceSortOrder
|
386
|
-
# generate synopsis of traceableruby 1.8.7 garbage at end of file
|
387
|
-
|
388
|
-
|
389
|
-
tracelist=""
|
390
|
-
File.open(outname, "w"){|fx|
|
391
|
-
fx.puts ""
|
392
|
-
fx.puts "\\clearpage"
|
393
|
-
fx.puts ""
|
394
|
-
fx.puts "# Requirements Tracing"
|
395
|
-
fx.puts ""
|
396
|
-
tracelist=all_traceable_set.reqtraceSynopsis(:SPECIFICATION_ITEM)
|
397
|
-
fx.puts tracelist
|
398
|
-
}
|
399
|
-
|
400
|
-
# output the graphxml
|
401
|
-
# write traceables to the intermediate Tracing file
|
402
|
-
outname="#{rootdir}/#{reqtracefile_base}.graphml"
|
403
|
-
File.open(outname, "w") {|fx| fx.puts all_traceable_set.to_graphml}
|
404
|
-
|
405
|
-
outname="#{rootdir}/#{reqtracefile_base}Compare.txt"
|
406
|
-
File.open(outname, "w") {|fx| fx.puts traceable_set.to_compareEntries}
|
407
|
-
|
408
|
-
# write the downstream_trace file - to be included in downstream - speciifcations
|
409
|
-
outname="#{rootdir}/#{downstream_tracefile}"
|
410
|
-
File.open(outname, "w") {|fx|
|
411
|
-
fx.puts ""
|
412
|
-
fx.puts "\\clearpage"
|
413
|
-
fx.puts ""
|
414
|
-
fx.puts "# Upstream Requirements"
|
415
|
-
fx.puts ""
|
416
|
-
fx.puts traceable_set.to_downstream_tracefile(:SPECIFICATION_ITEM)
|
417
|
-
} unless downstream_tracefile.nil?
|
418
|
-
|
419
|
-
|
420
|
-
# now add the upstream traces to input
|
421
|
-
files.concat( upstream_tracefiles) unless upstream_tracefiles.nil?
|
422
|
-
|
423
|
-
nil
|
424
|
-
end
|
425
|
-
end # module
|
426
|
-
|
427
118
|
Wortsammler.verify_options(options)
|
428
|
-
Wortsammler.
|
119
|
+
Wortsammler.execute(options)
|
data/lib/wortsammler/version.rb
CHANGED