packages feed

projectroot 0.1.0.1 → 0.2.0.1

raw patch · 3 files changed

+36/−12 lines, 3 filesdep +QuickCheckdep +hspecdep +projectrootdep ~base

Dependencies added: QuickCheck, hspec, projectroot

Dependency ranges changed: base

Files

projectroot.cabal view
@@ -1,10 +1,10 @@ name:                projectroot-version:             0.1.0.1+version:             0.2.0.1 synopsis:            Bindings to the projectroot C logic description: Simple way of finding the root of a project given an              entry-point. This module provides bindings to the              <https://github.com/yamadapc/projectroot projectroot> C library-homepage:            https://gitlab.com/yamadapc/haskell-projectroot+homepage:            https://github.com/yamadapc/haskell-projectroot license:             MIT license-file:        LICENSE author:              Pedro Tacla Yamada@@ -13,7 +13,12 @@ category:            System build-type:          Simple cabal-version:       >=1.10+tested-with: GHC >= 7.6 +source-repository head+  type:     git+  location: git://github.com/yamadapc/haskell-projectroot+ library   exposed-modules:     System.Directory.ProjectRoot   build-depends:       base >=4 && <5@@ -26,3 +31,13 @@                      , ./projectroot/deps/commander/commander.h   cc-options:          -std=c99   include-dirs:        .++test-suite hspec+  main-is: Spec.hs+  type: exitcode-stdio-1.0+  build-depends: base+               , hspec+               , QuickCheck+               , projectroot+  hs-source-dirs: test+  default-language: Haskell2010
src/System/Directory/ProjectRoot.hs view
@@ -12,31 +12,39 @@ module System.Directory.ProjectRoot   where -import           Control.Monad    ((<=<), (>=>))-import           Foreign.C-import           System.Directory (getCurrentDirectory)+import           Control.Applicative ((<$>))+import           Foreign.C           (CString, newCString, peekCString)+import           Foreign.Ptr         (nullPtr)+import           System.Directory    (getCurrentDirectory)  -- * Haskell Wrappers  -- | -- Find the project root given an entry point-getProjectRoot :: FilePath -> IO FilePath-getProjectRoot = (find_project_root <=< newCString) >=> peekCString+getProjectRoot :: FilePath -> IO (Maybe FilePath)+getProjectRoot fp = do+    root <- find_project_root =<< newCString fp+    if root == nullPtr+        then return Nothing+        else Just <$> peekCString root  -- | -- Find the weighted project root given an entry point-getProjectRootWeighted :: FilePath -> IO FilePath-getProjectRootWeighted = (find_project_root_weighted <=< newCString) >=>-                         peekCString+getProjectRootWeighted :: FilePath -> IO (Maybe FilePath)+getProjectRootWeighted fp = do+    root <- find_project_root_weighted =<< newCString fp+    if root == nullPtr+        then return Nothing+        else Just <$> peekCString root  -- | -- Find the project root of the current directory-getProjectRootCurrent :: IO FilePath+getProjectRootCurrent :: IO (Maybe FilePath) getProjectRootCurrent = getCurrentDirectory >>= getProjectRoot  -- | -- Find the weighted project root of the current directory-getProjectRootWeightedCurrent :: IO FilePath+getProjectRootWeightedCurrent :: IO (Maybe FilePath) getProjectRootWeightedCurrent = getCurrentDirectory >>= getProjectRootWeighted  -- * C functions
+ test/Spec.hs view
@@ -0,0 +1,1 @@+{-# OPTIONS_GHC -F -pgmF hspec-discover #-}