Method: TraceableSet.processTracesInMdFile

Defined in:
lib/wortsammler/class.Traceable.md.rb

.processTracesInMdFile(mdFile) ⇒ TraceableSet

Returns The set of traceables found in the markdown file.

Returns:

  • (TraceableSet)

    The set of traceables found in the markdown file



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/wortsammler/class.Traceable.md.rb', line 70

def self.processTracesInMdFile(mdFile)

  parser=TraceInMarkdownParser.new
  parser.consume_all_input = true

  raw_md_code_file=File.open(mdFile, "r:bom|utf-8")
  raw_md_code = raw_md_code_file.readlines.join
  raw_md_code_file.close
  #       print mdFile

  result = parser.parse(raw_md_code)
  #       print " ... parsed\n" todo: use logger here


  result_set = TraceableSet.new

  if result
    result.descendant.select{|x| x.getLabel==="trace"}.each{|c|
      id       = c.traceId.payload.text_value
      uptraces = c.uptraces.payload.text_value
      header   = c.traceHead.payload.text_value
      bodytext = c.traceBody.payload.text_value
      uptraces = c.uptraces.payload.text_value
      # Populate the Traceable entry

      theTrace = Traceable.new
      theTrace.info           = mdFile
      theTrace.id             = id
      theTrace.header_orig    = header
      theTrace.body_orig      = bodytext
      theTrace.trace_orig     = c.text_value
      theTrace.contributes_to = uptraces.gsub!(/\s*/, "").split(",")
      theTrace.category       = :SPECIFICATION_ITEM
      result_set.add(theTrace)
    }
    #            puts " .... finished"

  else
    puts ["","-----------", texFile, parser.failure_reason].join("\n")
  end
  result_set
end