lib/measures/tbd/resources/ua.rb
# Generate MD-formatted file.
#
# @param [Hash] ua Preprocessed collection of UA-related strings
# @param [String] lang Preferred language ("en" vs "fr")
#
# @return [Array] Returns MD-formatted strings.
Generate MD-formatted file.
Generate MD - formatted file .
def ua_md(ua, lang = :en)
  report = []
  unless ua && ua.is_a?(Hash)
    TBD.log(TBD::DEBUG, "Can't generate UA' MD report - invalid arguments")
    return report
  end
  if ua.empty?
    TBD.log(TBD::DEBUG, "Can't generate UA' MD report - empty summary")
    return report
  end
  unless ua.has_key?(lang)
    TBD.log(TBD::DEBUG, "Can't generate UA' MD report - language mismatch")
    return report
  end
  if ua[lang].has_key?(:objective)
    report << "# #{ua[lang][:objective]}   "
    report << "   "
  end
  if ua[lang].has_key?(:details)
    ua[lang][:details].each { |d| report << "#{d}   " }
    report << "   "
  end
  if ua.has_key?(:model)
    report << "##### SUMMARY   "  if lang == :en
    report << "##### SOMMAIRE   " if lang == :fr
    report << "   "
    report << "#{ua[:model]}   "
    report << "   "
  end
  if ua[lang].has_key?(:b1) && ua[lang][:b1].has_key?(:summary)
    last = ua[lang][:b1].keys.to_a.last
    report << "* #{ua[lang][:b1][:summary]}"
    ua[lang][:b1].each do |k, v|
      next if k == :summary
      report << "  * #{v}" unless k == last
      report << "  * #{v}   " if k == last
      report << "   " if k == last
    end
    report << "   "
  end
  if ua[lang].has_key?(:b2) && ua[lang][:b2].has_key?(:summary)
    last = ua[lang][:b2].keys.to_a.last
    report << "* #{ua[lang][:b2][:summary]}"
    ua[lang][:b2].each do |k, v|
      next if k == :summary
      report << "  * #{v}" unless k == last
      report << "  * #{v}   " if k == last
      report << "   " if k == last
    end
    report << "   "
  end
  if ua.has_key?(:date)
    report << "##### DESCRIPTION   "
    report << "   "
    report << "* project : #{ua[:descr]}" if ua.has_key?(:descr) && lang == :en
    report << "* projet : #{ua[:descr]}"  if ua.has_key?(:descr) && lang == :fr
    model = ""
    model = "* model : #{ua[:file]}" if ua.has_key?(:file) if lang == :en
    model = "* modèle : #{ua[:file]}" if ua.has_key?(:file) if lang == :fr
    model += " (v#{ua[:version]})" if ua.has_key?(:version)
    report << model unless model.empty?
    report << "* TBD : v2.2.1"
    report << "* date : #{ua[:date]}"
    if lang == :en
      report << "* status : #{TBD.msg(TBD.status)}" unless TBD.status.zero?
      report << "* status : success !" if TBD.status.zero?
    elsif lang == :fr
      report << "* statut : #{TBD.msg(TBD.status)}" unless TBD.status.zero?
      report << "* statut : succès !" if TBD.status.zero?
    end
    report << "   "
  end
  if ua[lang].has_key?(:areas)
    report << "##### AREAS   " if lang == :en
    report << "##### AIRES   " if lang == :fr
    report << "   "
    if ua[lang][:areas].has_key?(:walls)
      report << "* #{ua[lang][:areas][:walls]}"
    end
    if ua[lang][:areas].has_key?(:roofs)
      report << "* #{ua[lang][:areas][:roofs]}"
    end
    if ua[lang][:areas].has_key?(:floors)
      report << "* #{ua[lang][:areas][:floors]}"
    end
    report << "   "
  end
  if ua[lang].has_key?(:notes)
    report << "##### NOTES   "
    report << "   "
    report << "#{ua[lang][:notes]}   "
    report << "   "
  end
  report
end
def ua_md ( ua , lang = :en ) report = [ ] unless ua && ua . is_a? ( Hash ) TBD . log ( TBD :: DEBUG , "Can't generate UA' MD report - invalid arguments" ) return report end if ua . empty? TBD . log ( TBD :: DEBUG , "Can't generate UA' MD report - empty summary" ) return report end unless ua . has_key? ( lang ) TBD . log ( TBD :: DEBUG , "Can't generate UA' MD report - language mismatch" ) return report end if ua [ lang ] . has_key? ( :objective ) report << "# #{ua[lang][:objective]}   " report << "   " end if ua [ lang ] . has_key? ( :details ) ua [ lang ] [ :details ] . each { | d | report << "#{d}   " } report << "   " end if ua . has_key? ( :model ) report << "##### SUMMARY   " if lang == :en report << "##### SOMMAIRE   " if lang == :fr report << "   " report << "#{ua[:model]}   " report << "   " end if ua [ lang ] . has_key? ( :b1 ) && ua [ lang ] [ :b1 ] . has_key? ( :summary ) last = ua [ lang ] [ :b1 ] . keys . to_a . last report << "* #{ua[lang][:b1][:summary]}" ua [ lang ] [ :b1 ] . each do | k , v | next if k == :summary report << "  * #{v}" unless k == last report << "  * #{v}   " if k == last report << "   " if k == last end report << "   " end if ua [ lang ] . has_key? ( :b2 ) && ua [ lang ] [ :b2 ] . has_key? ( :summary ) last = ua [ lang ] [ :b2 ] . keys . to_a . last report << "* #{ua[lang][:b2][:summary]}" ua [ lang ] [ :b2 ] . each do | k , v | next if k == :summary report << "  * #{v}" unless k == last report << "  * #{v}   " if k == last report << "   " if k == last end report << "   " end if ua . has_key? ( :date ) report << "##### DESCRIPTION   " report << "   " report << "* project : #{ua[:descr]}" if ua . has_key? ( :descr ) && lang == :en report << "* projet : #{ua[:descr]}" if ua . has_key? ( :descr ) && lang == :fr model = "" model = "* model : #{ua[:file]}" if ua . has_key? ( :file ) if lang == :en model = "* modèle : #{ua[:file]}"  f  a. h as_key?( : file) f  ang  =  fr model += " (v#{ua[:version]})" if ua . has_key? ( :version ) report << model unless model . empty? report << "* TBD : v2.2.1" report << "* date : #{ua[:date]}" if lang == :en report << "* status : #{TBD.msg(TBD.status)}" unless TBD . status . zero? report << "* status : success !" if TBD . status . zero? elsif lang == :fr report << "* statut : #{TBD.msg(TBD.status)}" unless TBD . status . zero? report << "* statut : succès !"  f  BD. s tatus. z ero? end report << "   " end if ua [ lang ] . has_key? ( :areas ) report << "##### AREAS   " if lang == :en report << "##### AIRES   " if lang == :fr report << "   " if ua [ lang ] [ :areas ] . has_key? ( :walls ) report << "* #{ua[lang][:areas][:walls]}" end if ua [ lang ] [ :areas ] . has_key? ( :roofs ) report << "* #{ua[lang][:areas][:roofs]}" end if ua [ lang ] [ :areas ] . has_key? ( :floors ) report << "* #{ua[lang][:areas][:floors]}" end report << "   " end if ua [ lang ] . has_key? ( :notes ) report << "##### NOTES   " report << "   " report << "#{ua[lang][:notes]}   " report << "   " end report end
Generate MD-formatted file.
Generate MD - formatted file .
Returns MD-formatted strings.
Returns MD - formatted strings .
Array
ua
lang
lang Preferred language ("en" vs "fr")
lang Preferred language ( " en " vs " fr " )