module Data.ProtoLens.Compiler.ModuleName
( protoModuleName ) where
import Data.Char (toUpper)
import Data.List (intercalate)
import System.FilePath
protoModuleName :: FilePath -> String
protoModuleName path = fixModuleName rawModuleName
where
fixModuleName "" = ""
fixModuleName ('.':c:cs) = '.' : toUpper c : fixModuleName cs
fixModuleName ('_':c:cs) = toUpper c : fixModuleName cs
fixModuleName ('-':c:cs) = toUpper c : fixModuleName cs
fixModuleName (c:cs) = c : fixModuleName cs
rawModuleName = intercalate "."
. (prefix :)
. splitDirectories $ dropExtension
$ path
prefix :: String
prefix = "Proto"