packages feed

CLI (empty) → 0.1.0.0

raw patch · 6 files changed

+107/−0 lines, 6 filesdep +basedep +directorydep +doctestsetup-changed

Dependencies added: base, directory, doctest, split, time

Files

+ CLI.cabal view
@@ -0,0 +1,32 @@+-- Initial CLI.cabal generated by cabal init.  For further documentation, +-- see http://haskell.org/cabal/users-guide/++name:                CLI+version:             0.1.0.0+synopsis:            CLI tools+description:         Usful CLI tools+license:             BSD3+license-file:        LICENSE+author:              g960059+maintainer:          g960059@gmail.com+-- copyright:           +category:            Data+build-type:          Simple+-- extra-source-files:  +cabal-version:       >=1.10++library+  exposed-modules:    CLI.FizzBuzz, CLI.Ls +  -- other-modules:       +  -- other-extensions:    +  build-depends:       base >=4.7 && <4.8, split, time, directory+  hs-source-dirs:      src+  default-language:    Haskell2010++test-suite doctests+  type:          exitcode-stdio-1.0+  ghc-options:   -threaded+  main-is:       doctests.hs+  build-depends: base, doctest >= 0.8+  Default-Language:     Haskell2010+  HS-Source-Dirs:       test
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2015, g960059++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.++    * Redistributions in binary form must reproduce the above+      copyright notice, this list of conditions and the following+      disclaimer in the documentation and/or other materials provided+      with the distribution.++    * Neither the name of g960059 nor the names of other+      contributors may be used to endorse or promote products derived+      from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ src/CLI/FizzBuzz.hs view
@@ -0,0 +1,19 @@+module CLI.FizzBuzz ( fizzbuzz ) where+++-- | 文字列中のスペースの個数 --+-- >>> fizzbuzz 1+-- "1"+-- >>> fizzbuzz 2+-- "2"+-- >>> fizzbuzz 3+-- "Fizz" +--++fizzbuzz :: Int -> String +fizzbuzz n = case n `gcd` 15 of +  15 -> "FizzBuzz"+  5 -> "Buzz" +  3 -> "Fizz"+  3 -> "Fizz"   +  _ -> show n
+ src/CLI/Ls.hs view
@@ -0,0 +1,22 @@+module CLI.Ls where++import           Control.Applicative+import           Control.Monad+import           Data.List+import           Data.List.Split+import           Data.Time.LocalTime+import           System.Directory+import           System.IO+++ls filepath = do +  files <-  map ((filepath ++ "/") ++ ) <$> filter (isInfixOf "log") <$> getDirectoryContents filepath+  contents <- mapM readFile files+  return $ timeFilter $ map ( \xs -> (localTimeOfDay $ read (xs!!0 ++" "++ xs!!1), xs!!5 ,xs!!7 ,xs!!9 ))$ filter(\xs -> (length xs)  == 12 ) $ join $ map (splitEvery 12) $ filter(\xs -> (length xs) > 5 )  $ map words $ map concat $ map (filter (isInfixOf "Resources: [G]:") . lines) contents+  +ls2 filepath = do+  files <-  map ((filepath ++ "/") ++ ) <$> filter (isInfixOf "log") <$> getDirectoryContents filepath+  contents <- mapM readFile files+  return $ map ( \xs -> ( todHour.localTimeOfDay $ (read (xs!!0 ++" "++ xs!!1)) ,read (xs!!5) ::Int ,read (xs!!7) ::Int ,read (xs!!9) ::Int) ) $ filter(\xs -> (length xs)  == 12 ) $ join $ map (splitEvery 12) $ filter(\xs -> (length xs) > 5 )  $ map words $ map concat $ map (filter (isInfixOf "Resources: [G]:") . lines) contents++timeFilter  = foldr (\x acc -> (if acc ==[] || ((\(y,_,_,_) -> y) x) < ((\(z,_,_,_) -> z) $ head acc) then x:acc else acc) ) [] 
+ test/doctests.hs view
@@ -0,0 +1,2 @@+import Test.DocTest+main = doctest ["-isrc", "src/CLI/fizzbuzzstart.hs"]