lentil-0.1.2.7: src/Lentil/Export.hs
-----------------------------------------------------------------------------
-- |
-- Module : Lentil.Export
-- Copyright : © 2015 Francesco Ariis
-- License : GPLv3 (see the LICENSE file)
--
-- Exporting issues to various formats
-----------------------------------------------------------------------------
module Lentil.Export where
import Text.CSV
import Lentil.Types
import qualified Data.List as L
---------------
-- FUNCTIONS --
---------------
issues2CSV :: [Issue] -> String
issues2CSV is = printCSV (firstLine : map i2r is)
where firstLine = ["Filepath", "Row", "Description", "Tags"]
i2r i = [(prettyFP . iFile) i, show (iRow i),
iPPDesc i, tags2String (iTags i)]
-- compiler-like (gcc/ghc) warnings, parseable by emacs
issues2Compiler :: [Issue] -> String
issues2Compiler is = L.intercalate "\n" (map i2c is)
where i2c i = (prettyFP . iFile) i ++ ":" ++ show (iRow i) ++ ":\n" ++
" " ++ iPPDesc i ++ " " ++
tags2StringPretty (iTags i) ++ "\n"
-----------------
-- ANCILLARIES --
-----------------
-- tag1 tag2 etc
tags2String :: [Tag] -> String
tags2String ts = unwords (map tagString ts)
-- [tag1] [tag2] etc.
tags2StringPretty :: [Tag] -> String
tags2StringPretty ts = L.intercalate " " .
map ((openDel:) . (++[closeDel]) . tagString) $ ts