zampolit 0.1 → 0.2
raw patch · 2 files changed
+16/−13 lines, 2 filesdep +MissingH
Dependencies added: MissingH
Files
- Zampolit.hs +14/−11
- zampolit.cabal +2/−2
Zampolit.hs view
@@ -22,6 +22,7 @@ import Data.Map (Map,(!)) import qualified Data.Map as Map import Data.Maybe+import Data.String.Utils type Commit = String type Author = String@@ -39,6 +40,7 @@ type Total = (Date,Author,Map Author Int) foldNames "bts" = "brians"+foldNames "Paul Weaver" = "pweaver" foldNames a = a parseCA :: Parser [CA]@@ -47,9 +49,8 @@ c <- count 40 hexDigit newline string "Author: "- a' <- many1 alphaNum- let a = foldNames a'- space+ a' <- many1 (noneOf "<")+ let a = foldNames $ strip a' between (char '<') (char '>') $ many (noneOf ">") newline string "Date: "@@ -59,22 +60,24 @@ return CA {commit = c, author = a, date = d} rTime = readTime defaultTimeLocale "%a %b %e %T %Y %Z"-fTime = formatTime defaultTimeLocale "%s" -- "%m/%d/%y %I:%M:%S %P"+fTime = formatTime defaultTimeLocale "%s" wc ca = do runIO $ "git checkout " ++ commit ca- s <- run $ "find . -name \\*tex -print -o -name \\*txt -print" - -|- "xargs wc -w"+ s <- run $ "find . -name \\*tex -print0 -o -name \\*txt -print0" + -|- "xargs -0 wc -w" -|- "tail -1" -|- "grep -o '[0-9]\\+'" return $ read s runningTotals :: [Total] -> (Author,Date,Int) -> [Total]-runningTotals totals (author,date,wc) = (date,author,new):totals+runningTotals totals (author,date,wc) = new:totals where- new = Map.insertWith (+) author wc $ (\(a,b,c)->c) $ head totals+ new = (date,author,case totals of+ [] -> f Map.empty+ other -> f old)+ f = Map.insertWith (+) author wc+ old = (\(a,b,c)->c) $ head totals -zeroTotals :: [Total]-zeroTotals = [(rTime "Tue Jun 1 00:00:00 2010 +0000","ekate",Map.empty)] printHeader :: FilePath -> String -> [Author] -> IO () printHeader output title authors = @@ -121,7 +124,7 @@ Right cas -> do wcs <- mapM wc cas runIO $ "git checkout master"- let totals = foldl runningTotals zeroTotals . reverse + let totals = foldl runningTotals [] . reverse . zip3 (map author cas) (map date cas) . map (max 0) $ zipWith (-) wcs (tail wcs ++ [head $ reverse wcs])
zampolit.cabal view
@@ -1,5 +1,5 @@ Name: zampolit-Version: 0.1+Version: 0.2 Synopsis: A tool for checking how much work is done on group projects. Description: Zampolit is a tool for checking how much work each contributor to a project is doing. It produces pretty graphs of word count per author. This is helpful when collaborating on projects that are mostly text, and do not necessarily break lines reliably or often. License: BSD3@@ -19,7 +19,7 @@ Main-is: Zampolit.hs -- Packages needed in order to build this package.- Build-depends: base<5,parsec,cmdargs,time,containers,old-locale,directory,filepath,HSH+ Build-depends: base<5,parsec,cmdargs,time,containers,old-locale,directory,filepath,HSH,MissingH -- Modules not exported by this package. -- Other-modules: