Hello community,

here is the log from the commit of package ghc-web-routes for openSUSE:Factory 
checked in at 2017-01-31 12:40:45
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ghc-web-routes (Old)
 and      /work/SRC/openSUSE:Factory/.ghc-web-routes.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "ghc-web-routes"

Changes:
--------
--- /work/SRC/openSUSE:Factory/ghc-web-routes/ghc-web-routes.changes    
2017-01-18 21:40:10.650408808 +0100
+++ /work/SRC/openSUSE:Factory/.ghc-web-routes.new/ghc-web-routes.changes       
2017-02-03 17:40:32.676553098 +0100
@@ -1,0 +2,5 @@
+Mon Aug  1 10:36:21 UTC 2016 - [email protected]
+
+- Update to version 0.27.11 revision 0 with cabal2obs.
+
+-------------------------------------------------------------------

Old:
----
  web-routes-0.27.10.tar.gz

New:
----
  web-routes-0.27.11.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ ghc-web-routes.spec ++++++
--- /var/tmp/diff_new_pack.wJwZuT/_old  2017-02-03 17:40:33.012505547 +0100
+++ /var/tmp/diff_new_pack.wJwZuT/_new  2017-02-03 17:40:33.012505547 +0100
@@ -19,15 +19,14 @@
 %global pkg_name web-routes
 %bcond_with tests
 Name:           ghc-%{pkg_name}
-Version:        0.27.10
+Version:        0.27.11
 Release:        0
 Summary:        Portable, type-safe URL routing
 License:        BSD-3-Clause
-Group:          System/Libraries
+Group:          Development/Languages/Other
 Url:            https://hackage.haskell.org/package/%{pkg_name}
 Source0:        
https://hackage.haskell.org/package/%{pkg_name}-%{version}/%{pkg_name}-%{version}.tar.gz
 BuildRequires:  ghc-Cabal-devel
-# Begin cabal-rpm deps:
 BuildRequires:  ghc-blaze-builder-devel
 BuildRequires:  ghc-bytestring-devel
 BuildRequires:  ghc-exceptions-devel
@@ -44,7 +43,6 @@
 BuildRequires:  ghc-QuickCheck-devel
 BuildRequires:  ghc-hspec-devel
 %endif
-# End cabal-rpm deps
 
 %description
 A collection of types and functions that ensure that URLs generated by an
@@ -64,20 +62,14 @@
 %prep
 %setup -q -n %{pkg_name}-%{version}
 
-
 %build
 %ghc_lib_build
 
-
 %install
 %ghc_lib_install
 
-
 %check
-%if %{with tests}
-%{cabal} test
-%endif
-
+%cabal_test
 
 %post devel
 %ghc_pkg_recache

++++++ web-routes-0.27.10.tar.gz -> web-routes-0.27.11.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/web-routes-0.27.10/Web/Routes/Base.hs 
new/web-routes-0.27.11/Web/Routes/Base.hs
--- old/web-routes-0.27.10/Web/Routes/Base.hs   2015-12-18 17:49:17.000000000 
+0100
+++ new/web-routes-0.27.11/Web/Routes/Base.hs   2016-07-26 02:27:35.000000000 
+0200
@@ -14,6 +14,7 @@
 module Web.Routes.Base
        ( encodePathInfo
        , decodePathInfo
+       , decodePathInfoParams
        ) where
 
 import Blaze.ByteString.Builder (Builder, toByteString)
@@ -22,7 +23,7 @@
 import Data.List                (intercalate, intersperse)
 import Data.Text                (Text)
 import Data.Text.Encoding       as Text (encodeUtf8, decodeUtf8)
-import Network.HTTP.Types       (encodePath, decodePathSegments, 
queryTextToQuery)
+import Network.HTTP.Types       (Query, encodePath, decodePath, 
decodePathSegments, queryTextToQuery, queryToQueryText)
 
 {-
 
@@ -281,3 +282,13 @@
 -}
 decodePathInfo :: ByteString -> [Text]
 decodePathInfo = decodePathSegments
+
+-- | Returns path segments as well as possible query string components
+--
+-- For example:
+--
+-- > decodePathInfoParams "/home?q=1"
+-- (["home"],[("q",Just "1")])
+--
+decodePathInfoParams :: ByteString -> ([Text], [(Text, Maybe Text)])
+decodePathInfoParams = fmap queryToQueryText . decodePath
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/web-routes-0.27.10/Web/Routes/PathInfo.hs 
new/web-routes-0.27.11/Web/Routes/PathInfo.hs
--- old/web-routes-0.27.10/Web/Routes/PathInfo.hs       2015-12-18 
17:49:17.000000000 +0100
+++ new/web-routes-0.27.11/Web/Routes/PathInfo.hs       2016-07-26 
02:27:35.000000000 +0200
@@ -1,4 +1,4 @@
-{-# LANGUAGE CPP, FlexibleInstances, TypeSynonymInstances #-}
+{-# LANGUAGE CPP, FlexibleInstances, TypeSynonymInstances, TupleSections #-}
 
 #if __GLASGOW_HASKELL__ > 702
 {-# LANGUAGE DefaultSignatures, OverloadedStrings, ScopedTypeVariables, 
TypeOperators #-}
@@ -18,6 +18,7 @@
     , toPathInfo
     , toPathInfoParams
     , fromPathInfo
+    , fromPathInfoParams
     , mkSitePI
     , showParseError
 #if __GLASGOW_HASKELL__ > 702
@@ -41,7 +42,7 @@
 import Text.ParserCombinators.Parsec.Error (ParseError, errorPos, 
errorMessages, showErrorMessages)
 import Text.ParserCombinators.Parsec.Pos   (incSourceLine, sourceName, 
sourceLine, sourceColumn)
 import Text.ParserCombinators.Parsec.Prim  ((<?>), GenParser, getInput, 
setInput, getPosition, token, parse, many)
-import Web.Routes.Base (decodePathInfo, encodePathInfo)
+import Web.Routes.Base (decodePathInfoParams, decodePathInfo, encodePathInfo)
 import Web.Routes.Site (Site(..))
 
 #if __GLASGOW_HASKELL__ > 702
@@ -286,11 +287,25 @@
 fromPathInfo :: (PathInfo url) => ByteString -> Either String url
 fromPathInfo pi =
   parseSegments fromPathSegments (decodePathInfo $ dropSlash pi)
+
+-- | parse a 'String' into '(url, Query)' using 'PathInfo'.
+--
+-- returns @Left "parse error"@ on failure
+--
+-- returns @Right (url, Query@ on success
+
+fromPathInfoParams :: (PathInfo url) => ByteString -> Either String (url, 
[(Text, Maybe Text)])
+fromPathInfoParams pi =
+  (,query) <$> parseSegments fromPathSegments url
   where
-    dropSlash s =
-        if ((B.singleton '/') `B.isPrefixOf` s)
-        then B.tail s
-        else s
+    (url, query) = decodePathInfoParams $ dropSlash pi
+
+-- | Removes a leading slash, if it exists
+dropSlash :: ByteString -> ByteString
+dropSlash s =
+  if ((B.singleton '/') `B.isPrefixOf` s)
+  then B.tail s
+  else s
 
 -- | turn a routing function into a 'Site' value using the 'PathInfo' class
 mkSitePI :: (PathInfo url) =>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/web-routes-0.27.10/test/Test.hs 
new/web-routes-0.27.11/test/Test.hs
--- old/web-routes-0.27.10/test/Test.hs 2015-12-18 17:49:17.000000000 +0100
+++ new/web-routes-0.27.11/test/Test.hs 2016-07-26 02:27:35.000000000 +0200
@@ -2,6 +2,7 @@
 
 module Main (main) where
 
+import Data.Text (Text)
 import Test.HUnit
 import Test.QuickCheck
 import Test.Hspec
@@ -28,6 +29,11 @@
     do toPathInfo Home @?= "/home"
        toPathInfo (Article 0) @?= "/article/0"
 
+case_toPathInfoParams :: Assertion
+case_toPathInfoParams =
+    do toPathInfoParams Home [("q",Just "1"),("r",Just "2")] @?= 
"/home?q=1&r=2"
+       toPathInfoParams (Article 0) [("q",Just "1"),("r",Just "2")] @?= 
"/article/0?q=1&r=2"
+
 case_fromPathInfo :: Assertion
 case_fromPathInfo =
     do fromPathInfo "/home" @?= Right Home
@@ -36,8 +42,18 @@
          Left _ -> return ()
          url    -> assertFailure $ "expected a Left, but got: " ++ show url
 
+case_fromPathInfoParams :: Assertion
+case_fromPathInfoParams =
+    do fromPathInfoParams "/home?q=1&r=2" @?= Right (Home, [("q",Just 
"1"),("r",Just "2")])
+       fromPathInfoParams "/article/0?q=1&r=2" @?= Right (Article 0, 
[("q",Just "1"),("r",Just "2")])
+       case fromPathInfoParams "/?q=1&r=2" :: Either String (Sitemap, [(Text, 
Maybe Text)]) of
+         Left _ -> return ()
+         url    -> assertFailure $ "expected a Left, but got: " ++ show url
+
 main :: IO ()
 main = hspec $ do
  prop "toPathInfo" case_toPathInfo
+ prop "toPathInfoParams" case_toPathInfoParams
  prop "fromPathInfo" case_fromPathInfo
- prop "PathInfo_isomorphism"  prop_PathInfo_isomorphism
+ prop "fromPathInfoParams" case_fromPathInfoParams
+ prop "PathInfo_isomorphism" prop_PathInfo_isomorphism
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/web-routes-0.27.10/web-routes.cabal 
new/web-routes-0.27.11/web-routes.cabal
--- old/web-routes-0.27.10/web-routes.cabal     2015-12-18 17:49:17.000000000 
+0100
+++ new/web-routes-0.27.11/web-routes.cabal     2016-07-26 02:27:35.000000000 
+0200
@@ -1,5 +1,5 @@
 Name:             web-routes
-Version:          0.27.10
+Version:          0.27.11
 License:          BSD3
 License-File:     LICENSE
 Author:           [email protected]
@@ -20,6 +20,7 @@
                      HUnit,
                      hspec,
                      QuickCheck,
+                     text,
                      web-routes
 
 Library


Reply via email to