Hello community, here is the log from the commit of package ghc-cayley-client for openSUSE:Factory checked in at 2017-03-03 17:48:31 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ghc-cayley-client (Old) and /work/SRC/openSUSE:Factory/.ghc-cayley-client.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-cayley-client" Fri Mar 3 17:48:31 2017 rev:5 rq:461612 version:0.4.0 Changes: -------- --- /work/SRC/openSUSE:Factory/ghc-cayley-client/ghc-cayley-client.changes 2017-01-12 15:47:49.883341773 +0100 +++ /work/SRC/openSUSE:Factory/.ghc-cayley-client.new/ghc-cayley-client.changes 2017-03-03 17:48:32.319188956 +0100 @@ -1,0 +2,5 @@ +Sun Feb 12 14:14:22 UTC 2017 - [email protected] + +- Update to version 0.4.0 with cabal2obs. + +------------------------------------------------------------------- Old: ---- cayley-client-0.2.1.1.tar.gz New: ---- cayley-client-0.4.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-cayley-client.spec ++++++ --- /var/tmp/diff_new_pack.jDjBpG/_old 2017-03-03 17:48:32.835116093 +0100 +++ /var/tmp/diff_new_pack.jDjBpG/_new 2017-03-03 17:48:32.835116093 +0100 @@ -1,7 +1,7 @@ # # spec file for package ghc-cayley-client # -# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -19,7 +19,7 @@ %global pkg_name cayley-client %bcond_with tests Name: ghc-%{pkg_name} -Version: 0.2.1.1 +Version: 0.4.0 Release: 0 Summary: A Haskell client for the Cayley graph database License: BSD-3-Clause ++++++ cayley-client-0.2.1.1.tar.gz -> cayley-client-0.4.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cayley-client-0.2.1.1/Database/Cayley/Client/Internal.hs new/cayley-client-0.4.0/Database/Cayley/Client/Internal.hs --- old/cayley-client-0.2.1.1/Database/Cayley/Client/Internal.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/cayley-client-0.4.0/Database/Cayley/Client/Internal.hs 2017-01-30 09:36:02.000000000 +0100 @@ -0,0 +1,41 @@ +{-# LANGUAGE OverloadedStrings #-} + +module Database.Cayley.Client.Internal where + +import Control.Monad.Catch +import Control.Monad.IO.Class +import Control.Monad.Reader +import qualified Data.Aeson as A +import qualified Data.Text as T (pack) +import Data.Vector (fromList) +import Network.HTTP.Client + +import Database.Cayley.Types + +apiRequest :: Manager + -> String + -> Int + -> RequestBody + -> ReaderT CayleyConfig IO (Maybe A.Value) +apiRequest m u p b = do + r <- parseRequest u >>= \c -> + return c { method = "POST", port = p, requestBody = b } + t <- liftIO $ try $ httpLbs r m + case t of + Right _r -> return $ A.decode $ responseBody _r + Left e -> + return $ + Just $ A.object ["error" A..= T.pack (show (e :: SomeException))] + +toRequestBody :: [Quad] -> RequestBody +toRequestBody = RequestBodyLBS . A.encode . fromList . map A.toJSON + +getManager :: CayleyConnection -> Manager +getManager (CayleyConnection (_,m)) = m + +getConfig :: CayleyConnection -> CayleyConfig +getConfig (CayleyConnection (c,_)) = c + +urlBase :: String -> APIVersion -> String +urlBase s a = "http://" ++ s ++ "/api/v" ++ show a + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cayley-client-0.2.1.1/Database/Cayley/Client.hs new/cayley-client-0.4.0/Database/Cayley/Client.hs --- old/cayley-client-0.2.1.1/Database/Cayley/Client.hs 2016-11-29 22:58:24.000000000 +0100 +++ new/cayley-client-0.4.0/Database/Cayley/Client.hs 2017-01-30 18:33:27.000000000 +0100 @@ -25,7 +25,7 @@ -- * Utils , createQuad , isValid - , successfulResults + , results ) where @@ -41,7 +41,7 @@ import Network.HTTP.Client import Network.HTTP.Client.MultipartFormData -import Database.Cayley.Internal +import Database.Cayley.Client.Internal import Database.Cayley.Types -- | Get a connection to Cayley with the given configuration. @@ -74,18 +74,15 @@ case a ^? L.key "result" of Just v -> Right v Nothing -> - case a ^? L.key "error" of - Just e -> - case A.fromJSON e of - A.Success s -> Left s - A.Error _e -> Left _e - Nothing -> Left "No JSON response from Cayley server" - Nothing -> Left "Can't get any response from Cayley server" + case a ^? L.key "error" . L._String of + Just e -> fail (show e) + Nothing -> fail "No JSON response from Cayley server" + Nothing -> fail "Can't get any response from Cayley server" -- | Return the description of the given executed query. queryShape :: CayleyConnection -> Query - -> IO (A.Result Shape) + -> IO (Either String Shape) queryShape c q = runReaderT (doShape (getManager c) (encodeUtf8 q)) (getConfig c) where @@ -94,12 +91,16 @@ r <- apiRequest m (urlBase serverName apiVersion ++ "/shape/" ++ show queryLang) serverPort (RequestBodyBS _q) - case r of - Just o -> return $ A.fromJSON o - Nothing -> return $ A.Error "API request error" + return $ + case r of + Just o -> + case A.fromJSON o of + A.Success s -> Right s + A.Error e -> Left ("Not a shape (\"" ++ e ++ "\")") + Nothing -> Left "API request error" -- | Write a 'Quad' with the given subject, predicate, object and optional --- label. Throw result or extract amount of query 'successfulResults' +-- label. Throw result or extract amount of query 'results' -- from it. -- -- >λ> writeQuad conn "Humphrey" "loves" "Lauren" (Just "In love") @@ -176,7 +177,7 @@ where writenq m _p = do CayleyConfig{..} <- ask - r <- parseUrl (urlBase serverName apiVersion ++ "/write/file/nquad") + r <- parseRequest (urlBase serverName apiVersion ++ "/write/file/nquad") >>= \r -> return r { port = serverPort } t <- liftIO $ try $ @@ -203,25 +204,25 @@ then Just Quad { subject = s, predicate = p, object = o, label = l } else Nothing --- | Get amount of successful results from a write/delete 'Quad'(s) --- operation, or an explicite error message. +-- | Get amount of results from a write/delete 'Quad'(s) operation, +-- or an explicite error message. -- --- >λ> writeNQuadFile conn "testdata.nq" >>= successfulResults +-- >λ> writeNQuadFile conn "testdata.nq" >>= results -- >Right 11 -- -successfulResults :: Maybe A.Value - -> IO (Either String Int) -successfulResults m = return $ +results :: Maybe A.Value + -> IO (Either String Int) +results m = return $ case m of Just v -> case v ^? L.key "result" . L._String of Just r -> case APT.parse getAmount r of APT.Done "" i -> Right i - _ -> fail "Can't get amount of successful results" + _ -> fail "Can't get amount of results" Nothing -> case v ^? L.key "error" . L._String of - Just e -> fail (T.unpack e) + Just e -> fail (show e) Nothing -> fail "No JSON response from Cayley server" Nothing -> fail "Can't get any response from Cayley server" where diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cayley-client-0.2.1.1/Database/Cayley/Internal.hs new/cayley-client-0.4.0/Database/Cayley/Internal.hs --- old/cayley-client-0.2.1.1/Database/Cayley/Internal.hs 2016-10-30 10:41:46.000000000 +0100 +++ new/cayley-client-0.4.0/Database/Cayley/Internal.hs 1970-01-01 01:00:00.000000000 +0100 @@ -1,41 +0,0 @@ -{-# LANGUAGE OverloadedStrings #-} - -module Database.Cayley.Internal where - -import Control.Monad.Catch -import Control.Monad.IO.Class -import Control.Monad.Reader -import qualified Data.Aeson as A -import qualified Data.Text as T (pack) -import Data.Vector (fromList) -import Network.HTTP.Client - -import Database.Cayley.Types - -apiRequest :: Manager - -> String - -> Int - -> RequestBody - -> ReaderT CayleyConfig IO (Maybe A.Value) -apiRequest m u p b = do - r <- parseUrl u >>= \c -> - return c { method = "POST", port = p, requestBody = b } - t <- liftIO $ try $ httpLbs r m - case t of - Right _r -> return $ A.decode $ responseBody _r - Left e -> - return $ - Just $ A.object ["error" A..= T.pack (show (e :: SomeException))] - -toRequestBody :: [Quad] -> RequestBody -toRequestBody = RequestBodyLBS . A.encode . fromList . map A.toJSON - -getManager :: CayleyConnection -> Manager -getManager (CayleyConnection (_,m)) = m - -getConfig :: CayleyConnection -> CayleyConfig -getConfig (CayleyConnection (c,_)) = c - -urlBase :: String -> APIVersion -> String -urlBase s a = "http://" ++ s ++ "/api/v" ++ show a - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cayley-client-0.2.1.1/cayley-client.cabal new/cayley-client-0.4.0/cayley-client.cabal --- old/cayley-client-0.2.1.1/cayley-client.cabal 2016-11-29 23:07:44.000000000 +0100 +++ new/cayley-client-0.4.0/cayley-client.cabal 2017-01-30 20:20:47.000000000 +0100 @@ -1,54 +1,59 @@ -name: cayley-client -version: 0.2.1.1 -synopsis: A Haskell client for the Cayley graph database -description: cayley-client implements the RESTful API of the Cayley graph database. -homepage: https://github.com/MichelBoucey/cayley-client -license: BSD3 -license-file: LICENSE -author: Michel Boucey -maintainer: [email protected] -copyright: (c) 2015-2016 - Michel Boucey -category: Database -build-type: Simple -cabal-version: >=1.10 -extra-source-files: README.md - , tests/testdata.nq +name: cayley-client +version: 0.4.0 +cabal-version: >=1.10 +build-type: Simple +license: BSD3 +license-file: LICENSE +copyright: (c) 2015-2017 - Michel Boucey +maintainer: [email protected] +homepage: https://github.com/MichelBoucey/cayley-client +synopsis: A Haskell client for the Cayley graph database +description: + cayley-client implements the RESTful API of the Cayley graph database. +category: Database +author: Michel Boucey +extra-source-files: + README.md + tests/testdata.nq -Source-Repository head - Type: git - Location: https://github.com/MichelBoucey/cayley-client.git +source-repository head + type: git + location: https://github.com/MichelBoucey/cayley-client.git library - exposed-modules: Database.Cayley.Client - , Database.Cayley.Types - other-modules: Database.Cayley.Internal - other-extensions: OverloadedStrings - build-depends: base >=4.8 && <5 - , mtl >=2.1 - , transformers >=0.3 - , attoparsec >=0.12 - , binary >=0.7.5 - , bytestring >=0.10 - , text >=1.2 - , vector >=0.10 - , http-conduit >=2.1 - , http-client >=0.4 - , aeson >=0.8 - , lens >= 4.6.0.1 - , lens-aeson >=1.0.0.3 - , unordered-containers >=0.2 - , exceptions >= 0.6 - default-language: Haskell2010 - GHC-Options: -Wall + exposed-modules: + Database.Cayley.Client + Database.Cayley.Types + build-depends: + aeson >=0.8.0.2 && <1.2, + attoparsec >=0.12.1.6 && <0.14, + base >=4.8.1.0 && <5, + bytestring >=0.10.6 && <0.11, + binary >=0.7.5 && <0.9, + exceptions >=0.8.0.2 && <0.9, + http-client >=0.4.30 && <0.6, + http-conduit >=2.1.8 && <2.3, + lens >=4.12.3 && <4.16, + mtl >=2.2.1 && <2.3, + lens-aeson >=1.0.0 && <1.1, + text >=1.2.2 && <1.3, + transformers >=0.4.2 && <0.6, + unordered-containers >=0.2.5.1 && <0.3, + vector >=0.10.12.3 && <0.13 + default-language: Haskell2010 + other-extensions: OverloadedStrings + other-modules: + Database.Cayley.Client.Internal + ghc-options: -Wall test-suite tests - type: exitcode-stdio-1.0 - hs-source-dirs: tests - main-is: hspec.hs - build-depends: hspec >= 2.2.2 - , base >= 4.8 && < 5 - , cayley-client - , aeson >=0.8 - , unordered-containers >= 0.2.5 - default-language: Haskell2010 - + type: exitcode-stdio-1.0 + main-is: hspec.hs + build-depends: + hspec >=2.1.10 && <2.5, + base >=4.8 && <5, + cayley-client >=0.4.0 && <0.5, + aeson >=0.8.0.2 && <1.2, + unordered-containers >=0.2.5 && <0.3 + default-language: Haskell2010 + hs-source-dirs: tests diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cayley-client-0.2.1.1/tests/hspec.hs new/cayley-client-0.4.0/tests/hspec.hs --- old/cayley-client-0.2.1.1/tests/hspec.hs 2016-09-13 17:03:00.000000000 +0200 +++ new/cayley-client-0.4.0/tests/hspec.hs 2017-01-30 17:34:09.000000000 +0100 @@ -12,21 +12,21 @@ describe "write" $ it "writes a quad to Cayley server" $ do c <- connectCayley defaultCayleyConfig - write c Quad { subject = "danny", predicate = "follows", C.object = "sandy", label = Nothing } `shouldReturn` Just (Object (fromList [("result",String "Successfully wrote 1 quads.")])) + write c Quad { subject = "<danny>", predicate = "<follows>", C.object = "<sandy>", label = Nothing } `shouldReturn` Just (Object (fromList [("result",String "Successfully wrote 1 quads.")])) describe "query" $ it "query Cayley server" $ do c <- connectCayley defaultCayleyConfig - Right a <- query c "graph.Vertex('sandy').In('follows').All()" - encode a `shouldBe` "[{\"id\":\"danny\"}]" + Right a <- query c "graph.Vertex('<sandy>').In('<follows>').All()" + encode a `shouldBe` "[{\"id\":\"<danny>\"}]" describe "shape" $ it "returns the description of the last query executed" $ do c <- connectCayley defaultCayleyConfig - queryShape c "graph.Vertex('sandy').In('follows').All()" `shouldReturn` Success (Shape {nodes = [Node {CT.id = 4, tags = Nothing, values = Just ["sandy"], isLinkNode = False, isFixed = True},Node {CT.id = 8, tags = Nothing, values = Just ["follows"], isLinkNode = False, isFixed = True},Node {CT.id = 2, tags = Nothing, values = Nothing, isLinkNode = True, isFixed = False},Node {CT.id = 1, tags = Just ["id"], values = Nothing, isLinkNode = False, isFixed = False}], links = [Link {source = 1, target = 4, linkNode = 2}]}) + queryShape c "graph.Vertex('<sandy>').In('<follows>').All()" `shouldReturn` Right (Shape {nodes = [Node {CT.id = 4, tags = Nothing, values = Just ["<sandy>"], isLinkNode = False, isFixed = True},Node {CT.id = 8, tags = Nothing, values = Just ["<follows>"], isLinkNode = False, isFixed = True},Node {CT.id = 2, tags = Nothing, values = Nothing, isLinkNode = True, isFixed = False},Node {CT.id = 1, tags = Just ["id"], values = Nothing, isLinkNode = False, isFixed = False}], links = [Link {source = 1, target = 4, linkNode = 2}]}) describe "writeNQuadFile" $ it "writes quads from a file to Cayley server" $ do c <- connectCayley defaultCayleyConfig - (writeNQuadFile c "./tests/testdata.nq" >>= successfulResults) `shouldReturn` Right 15 + (writeNQuadFile c "./tests/testdata.nq" >>= results) `shouldReturn` Right 15
