packages feed

os-release (empty) → 0.1.0

raw patch · 8 files changed

+185/−0 lines, 8 filesdep +basedep +hlintdep +hspecsetup-changed

Dependencies added: base, hlint, hspec, os-release, process, regex-compat

Files

+ LICENSE view
@@ -0,0 +1,26 @@+Copyright (c) 2014, Jan Matejka <yac@blesmrt.net>+All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++1. Redistributions of source code must retain the above copyright notice,+   this list of conditions and the following disclaimer.+2. 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.+3. Neither the name of the cbugzilla nor the names of its+   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
+ library/System/OsRelease.hs view
@@ -0,0 +1,19 @@+module System.OsRelease+    ( detect+    , OsRelease (..)+    , detect'+    )+where++data OsRelease = OpenSUSE+    deriving (Eq, Show)++detect :: IO (Maybe OsRelease)+detect = do+    osr <- readFile "/etc/os-release"+    return . detect' $ lines osr++detect' :: [String] -> Maybe OsRelease+detect' [] = Nothing+detect' ("NAME=openSUSE":_) = Just OpenSUSE+detect' (_:xs) = detect' xs
+ os-release.cabal view
@@ -0,0 +1,78 @@+author:         Jan Matějka+category:       System+license-file:   LICENSE+build-type:     Simple+cabal-version:  >= 1.16+copyright:      2014 Jan Matějka <yac@blesmrt.net>+license:        BSD3+maintainer:     <yac@blesmrt.net>+homepage:       https://github.com/yaccz/os-release+name:           os-release+synopsis:       /etc/os-release helpers+version:        0.1.0+description:    /etc/os-release helpers+++source-repository head+  type:     git+  location: https://github.com/yaccz/os-release.git++library+    build-depends:+      base < 5+    default-language:   Haskell2010+    exposed-modules:    System.OsRelease+    ghc-options:+        -Wall+    ghc-prof-options:+        -auto-all+        -prof+    hs-source-dirs:     library++test-suite tests+    build-depends:+        base < 5+      , os-release+      , hspec+    default-language:+        Haskell2010+    ghc-options:+        -Wall+        -Werror+    hs-source-dirs:+        library+        tests+    main-is:+        Spec.hs+    other-modules:+        System.OsRelease+        OsReleaseSpec+    type:+        exitcode-stdio-1.0++test-suite documentation+    build-depends:+        base < 5+      , process == 1.*+      , regex-compat == 0.*+    default-language:+        Haskell2010+    hs-source-dirs:+        tests+    main-is:+        Haddock.hs+    type:+        exitcode-stdio-1.0++test-suite style+    build-depends:+        base < 5+      , hlint == 1.*+    default-language:+        Haskell2010+    hs-source-dirs:+        tests+    main-is:+        HLint.hs+    type:+        exitcode-stdio-1.0
+ tests/HLint.hs view
@@ -0,0 +1,16 @@+module Main (main) where++import           Language.Haskell.HLint (hlint)+import           System.Exit            (exitFailure, exitSuccess)++arguments :: [String]+arguments =+    [+      "library"+    , "tests"+    ]++main :: IO ()+main = do+    hints <- hlint arguments+    if null hints then exitSuccess else exitFailure
+ tests/Haddock.hs view
@@ -0,0 +1,30 @@+module Main (main) where++import           Data.List      (genericLength)+import           Data.Maybe     (catMaybes)+import           System.Exit    (exitFailure, exitSuccess)+import           System.Process (readProcess)+import           Text.Regex     (matchRegex, mkRegex)++arguments :: [String]+arguments =+    [ "haddock"+    ]++average :: (Fractional a, Real b) => [b] -> a+average xs = realToFrac (sum xs) / genericLength xs++expected :: Fractional a => a+expected = 0++main :: IO ()+main = do+    output <- readProcess "cabal" arguments ""+    if average (match output) >= expected+        then exitSuccess+        else putStr output >> exitFailure++match :: String -> [Int]+match = fmap read . concat . catMaybes . fmap (matchRegex pattern) . lines+  where+    pattern = mkRegex "^ *([0-9]*)% "
+ tests/OsReleaseSpec.hs view
@@ -0,0 +1,13 @@+module OsReleaseSpec (spec) where++import           Test.Hspec+import           System.OsRelease++spec :: Spec+spec = do+    describe "detect" $ do+        it "parses" $ do+            detect' ["NAME=openSUSE"]      `shouldBe` Just OpenSUSE+            detect' []                     `shouldBe` Nothing+            detect' ["NAME=open"]          `shouldBe` Nothing+            detect' ["NAME=\"openSUSE\""]  `shouldBe` Nothing
+ tests/Spec.hs view
@@ -0,0 +1,1 @@+{-# OPTIONS_GHC -F -pgmF hspec-discover #-}