packages feed

Spock 0.7.0.0 → 0.7.1.0

raw patch · 10 files changed

+121/−124 lines, 10 filesdep −HListdep ~reroutePVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependencies removed: HList

Dependency ranges changed: reroute

API changes (from Hackage documentation)

- Web.Spock.Specs.All: allSpecs :: Spec
- Web.Spock.Safe: (</>) :: Path as -> Path bs -> Path (HAppendList * as bs)
+ Web.Spock.Safe: (</>) :: Path as -> Path bs -> Path (Append as bs)
- Web.Spock.Safe: delete :: MonadIO m => Path xs -> HListElim xs (ActionT m ()) -> SpockT m ()
+ Web.Spock.Safe: delete :: MonadIO m => Path xs -> HVectElim xs (ActionT m ()) -> SpockT m ()
- Web.Spock.Safe: get :: MonadIO m => Path xs -> HListElim xs (ActionT m ()) -> SpockT m ()
+ Web.Spock.Safe: get :: MonadIO m => Path xs -> HVectElim xs (ActionT m ()) -> SpockT m ()
- Web.Spock.Safe: head :: MonadIO m => Path xs -> HListElim xs (ActionT m ()) -> SpockT m ()
+ Web.Spock.Safe: head :: MonadIO m => Path xs -> HVectElim xs (ActionT m ()) -> SpockT m ()
- Web.Spock.Safe: hookRoute :: Monad m => StdMethod -> Path xs -> HListElim xs (ActionT m ()) -> SpockT m ()
+ Web.Spock.Safe: hookRoute :: Monad m => StdMethod -> Path xs -> HVectElim xs (ActionT m ()) -> SpockT m ()
- Web.Spock.Safe: patch :: MonadIO m => Path xs -> HListElim xs (ActionT m ()) -> SpockT m ()
+ Web.Spock.Safe: patch :: MonadIO m => Path xs -> HVectElim xs (ActionT m ()) -> SpockT m ()
- Web.Spock.Safe: post :: MonadIO m => Path xs -> HListElim xs (ActionT m ()) -> SpockT m ()
+ Web.Spock.Safe: post :: MonadIO m => Path xs -> HVectElim xs (ActionT m ()) -> SpockT m ()
- Web.Spock.Safe: put :: MonadIO m => Path xs -> HListElim xs (ActionT m ()) -> SpockT m ()
+ Web.Spock.Safe: put :: MonadIO m => Path xs -> HVectElim xs (ActionT m ()) -> SpockT m ()
- Web.Spock.Safe: renderRoute :: Path as -> HList as -> Text
+ Web.Spock.Safe: renderRoute :: Path as -> HVect as -> Text
- Web.Spock.Safe: subcomponent :: Monad m => Path '[] -> SpockT m () -> SpockT m ()
+ Web.Spock.Safe: subcomponent :: Monad m => Path [] -> SpockT m () -> SpockT m ()
- Web.Spock.Safe: var :: (Typeable a, PathPiece a) => Path (: * a ([] *))
+ Web.Spock.Safe: var :: (Typeable * a, PathPiece a) => Path ((:) * a ([] *))

Files

Spock.cabal view
@@ -1,5 +1,5 @@ name:                Spock-version:             0.7.0.0+version:             0.7.1.0 synopsis:            Another Haskell web framework for rapid development description:         This toolbox provides everything you need to get a quick start into web hacking with haskell: routing, middleware, json, blaze, sessions, cookies, database helper, csrf-protection, global state Homepage:            https://github.com/agrafix/Spock@@ -15,8 +15,7 @@ library   hs-source-dirs:      src   exposed-modules:     Web.Spock.Simple,-                       Web.Spock.Safe,-                       Web.Spock.Specs.All+                       Web.Spock.Safe   other-modules:       Web.Spock.Internal.SessionManager,                        Web.Spock.Internal.Monad,                        Web.Spock.Internal.Types,@@ -25,10 +24,7 @@                        Web.Spock.Internal.Core,                        Web.Spock.Internal.CoreAction,                        Web.Spock.Internal.Wrapper,-                       Web.Spock.Internal.Wire,-                       Web.Spock.Specs.SimpleSpec,-                       Web.Spock.Specs.SafeSpec,-                       Web.Spock.Specs.FrameworkSpecHelper+                       Web.Spock.Internal.Wire   build-depends:       aeson >= 0.6.2.1 && <0.9,                        base >= 4 && < 5,                        base64-bytestring ==1.*,@@ -40,9 +36,6 @@                        digestive-functors ==0.7.*,                        directory ==1.2.*,                        hashable ==1.2.*,-                       hspec2 >=0.4 && <0.5,-                       hspec-wai >=0.5 && <0.6,-                       HList >=0.3,                        http-types ==0.8.*,                        monad-control ==0.3.*,                        mtl >=2.1 && <2.3,@@ -50,7 +43,7 @@                        path-pieces >=0.1.4,                        random ==1.*,                        regex-compat ==0.95.*,-                       reroute >=0.1 && <0.2,+                       reroute >=0.2 && <0.3,                        resource-pool ==0.2.*,                        resourcet >= 0.4 && <1.2,                        safe >=0.3,@@ -72,8 +65,14 @@   type:                exitcode-stdio-1.0   hs-source-dirs:      test   main-is:             Spec.hs+  other-modules:       Web.Spock.SimpleSpec,+                       Web.Spock.SafeSpec,+                       Web.Spock.FrameworkSpecHelper   build-depends:       hspec2 >=0.4 && <0.5,+                       hspec-wai >=0.5 && <0.6,+                       wai >=3.0 && <4.0,                        base >= 4 && < 5,+                       text >= 0.11.3.1 && <1.3,                        Spock   ghc-options: -Wall -fno-warn-orphans 
src/Web/Spock/Safe.hs view
@@ -60,6 +60,7 @@ import Control.Applicative import Control.Monad.Trans import Data.Monoid+import Data.HVect import Network.HTTP.Types.Method import Prelude hiding (head) import Web.Routing.SafeRouting@@ -103,32 +104,32 @@     W.buildApp SafeRouter liftFun app  -- | Specify an action that will be run when the HTTP verb 'GET' and the given route match-get :: MonadIO m => Path xs -> HListElim xs (ActionT m ()) -> SpockT m ()+get :: MonadIO m => Path xs -> HVectElim xs (ActionT m ()) -> SpockT m () get = hookRoute GET  -- | Specify an action that will be run when the HTTP verb 'POST' and the given route match-post :: MonadIO m => Path xs -> HListElim xs (ActionT m ()) -> SpockT m ()+post :: MonadIO m => Path xs -> HVectElim xs (ActionT m ()) -> SpockT m () post = hookRoute POST  -- | Specify an action that will be run when the HTTP verb 'HEAD' and the given route match-head :: MonadIO m => Path xs -> HListElim xs (ActionT m ()) -> SpockT m ()+head :: MonadIO m => Path xs -> HVectElim xs (ActionT m ()) -> SpockT m () head = hookRoute HEAD  -- | Specify an action that will be run when the HTTP verb 'PUT' and the given route match-put :: MonadIO m => Path xs -> HListElim xs (ActionT m ()) -> SpockT m ()+put :: MonadIO m => Path xs -> HVectElim xs (ActionT m ()) -> SpockT m () put = hookRoute PUT  -- | Specify an action that will be run when the HTTP verb 'DELETE' and the given route match-delete :: MonadIO m => Path xs -> HListElim xs (ActionT m ()) -> SpockT m ()+delete :: MonadIO m => Path xs -> HVectElim xs (ActionT m ()) -> SpockT m () delete = hookRoute DELETE  -- | Specify an action that will be run when the HTTP verb 'PATCH' and the given route match-patch :: MonadIO m => Path xs -> HListElim xs (ActionT m ()) -> SpockT m ()+patch :: MonadIO m => Path xs -> HVectElim xs (ActionT m ()) -> SpockT m () patch = hookRoute PATCH  -- | Specify an action that will be run when a HTTP verb and the given route match-hookRoute :: Monad m => StdMethod -> Path xs -> HListElim xs (ActionT m ()) -> SpockT m ()-hookRoute m path action = SpockT $ C.hookRoute m (SafeRouterPath path) (HListElim' action)+hookRoute :: Monad m => StdMethod -> Path xs -> HVectElim xs (ActionT m ()) -> SpockT m ()+hookRoute m path action = SpockT $ C.hookRoute m (SafeRouterPath path) (HVectElim' action)  -- | Define a subcomponent. Usage example: --
− src/Web/Spock/Specs/All.hs
@@ -1,11 +0,0 @@-module Web.Spock.Specs.All where--import qualified Web.Spock.Specs.SimpleSpec-import qualified Web.Spock.Specs.SafeSpec--import Test.Hspec--allSpecs :: Spec-allSpecs =-    do Web.Spock.Specs.SimpleSpec.spec-       Web.Spock.Specs.SafeSpec.spec
− src/Web/Spock/Specs/FrameworkSpecHelper.hs
@@ -1,37 +0,0 @@-{-# LANGUAGE OverloadedStrings #-}-module Web.Spock.Specs.FrameworkSpecHelper where--import Test.Hspec-import Test.Hspec.Wai--import qualified Network.Wai as Wai--frameworkSpec :: IO Wai.Application -> Spec-frameworkSpec app =-    with app $-    do routingSpec-       actionSpec--routingSpec :: SpecWith Wai.Application-routingSpec =-    describe "Routing Framework" $-      do it "allows root actions" $-            get "/" `shouldRespondWith` "root" { matchStatus = 200 }-         it "routes different HTTP-verbs to different actions" $-            do verbTest get "GET"-               verbTest (\p -> post p "") "POST"-               verbTest (\p -> put p "") "PUT"-               verbTest delete "DELETE"-               verbTest (\p -> patch p "") "PATCH"-         it "can extract params from routes" $-            get "/param-test/42" `shouldRespondWith` "int42" { matchStatus = 200 }-         it "can handle multiple matching routes" $-            get "/param-test/static" `shouldRespondWith` "static" { matchStatus = 200 }-    where-      verbTest verb verbVerbose =-          (verb "/verb-test")-          `shouldRespondWith` (verbVerbose { matchStatus = 200 })--actionSpec :: SpecWith Wai.Application-actionSpec =-    describe "Action Framework" $ return ()
− src/Web/Spock/Specs/SafeSpec.hs
@@ -1,26 +0,0 @@-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE ScopedTypeVariables #-}-module Web.Spock.Specs.SafeSpec where--import Web.Spock.Safe-import Web.Spock.Specs.FrameworkSpecHelper--import Data.Monoid-import Test.Hspec-import qualified Data.Text as T--app :: SpockT IO ()-app =-    do get root $ text "root"-       get "verb-test" $ text "GET"-       post "verb-test" $ text "POST"-       put "verb-test" $ text "PUT"-       delete "verb-test" $ text "DELETE"-       patch "verb-test" $ text "PATCH"-       get ("param-test" </> var) $ \(i :: Int) ->-           text $ "int" <> (T.pack $ show i)-       get ("param-test" </> "static") $-           text "static"--spec :: Spec-spec = describe "SafeRouting" $ frameworkSpec (spockApp id app)
− src/Web/Spock/Specs/SimpleSpec.hs
@@ -1,26 +0,0 @@-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE ScopedTypeVariables #-}-module Web.Spock.Specs.SimpleSpec where--import Web.Spock.Simple-import Web.Spock.Specs.FrameworkSpecHelper--import Data.Monoid-import Test.Hspec-import qualified Data.Text as T--app :: SpockT IO ()-app =-    do get "/" $ text "root"-       get "/verb-test" $ text "GET"-       post "/verb-test" $ text "POST"-       put "/verb-test" $ text "PUT"-       delete "/verb-test" $ text "DELETE"-       patch "/verb-test" $ text "PATCH"-       get "/param-test/:int" $-           do Just (i :: Int) <- param "int"-              text $ "int" <> (T.pack $ show i)-       get "/param-test/static" $-           text "static"-spec :: Spec-spec = describe "SimpleRouting" $ frameworkSpec (spockApp id app)
test/Spec.hs view
@@ -1,5 +1,1 @@-import Test.Hspec-import Web.Spock.Specs.All--main :: IO ()-main = hspec allSpecs+{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
+ test/Web/Spock/FrameworkSpecHelper.hs view
@@ -0,0 +1,40 @@+{-# LANGUAGE OverloadedStrings #-}+module Web.Spock.FrameworkSpecHelper where++import Test.Hspec+import Test.Hspec.Wai++import qualified Network.Wai as Wai++frameworkSpec :: IO Wai.Application -> Spec+frameworkSpec app =+    with app $+    do routingSpec+       actionSpec++routingSpec :: SpecWith Wai.Application+routingSpec =+    describe "Routing Framework" $+      do it "allows root actions" $+            get "/" `shouldRespondWith` "root" { matchStatus = 200 }+         it "routes different HTTP-verbs to different actions" $+            do verbTest get "GET"+               verbTest (\p -> post p "") "POST"+               verbTest (\p -> put p "") "PUT"+               verbTest delete "DELETE"+               verbTest (\p -> patch p "") "PATCH"+         it "can extract params from routes" $+            get "/param-test/42" `shouldRespondWith` "int42" { matchStatus = 200 }+         it "can handle multiple matching routes" $+            get "/param-test/static" `shouldRespondWith` "static" { matchStatus = 200 }+         it "works with subcomponents" $+            do get "/subcomponent/foo" `shouldRespondWith` "foo" { matchStatus = 200 }+               get "/subcomponent/subcomponent2/bar" `shouldRespondWith` "bar" { matchStatus = 200 }+    where+      verbTest verb verbVerbose =+          (verb "/verb-test")+          `shouldRespondWith` (verbVerbose { matchStatus = 200 })++actionSpec :: SpecWith Wai.Application+actionSpec =+    describe "Action Framework" $ return ()
+ test/Web/Spock/SafeSpec.hs view
@@ -0,0 +1,30 @@+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE ScopedTypeVariables #-}+module Web.Spock.SafeSpec (spec) where++import Web.Spock.Safe+import Web.Spock.FrameworkSpecHelper++import Data.Monoid+import Test.Hspec+import qualified Data.Text as T++app :: SpockT IO ()+app =+    do get root $ text "root"+       get "verb-test" $ text "GET"+       post "verb-test" $ text "POST"+       put "verb-test" $ text "PUT"+       delete "verb-test" $ text "DELETE"+       patch "verb-test" $ text "PATCH"+       get ("param-test" </> var) $ \(i :: Int) ->+           text $ "int" <> (T.pack $ show i)+       get ("param-test" </> "static") $+           text "static"+       subcomponent "/subcomponent" $+         do get "foo" $ text "foo"+            subcomponent "/subcomponent2" $+              do get "bar" $ text "bar"++spec :: Spec+spec = describe "SafeRouting" $ frameworkSpec (spockApp id app)
+ test/Web/Spock/SimpleSpec.hs view
@@ -0,0 +1,31 @@+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE ScopedTypeVariables #-}+module Web.Spock.SimpleSpec (spec) where++import Web.Spock.Simple+import Web.Spock.FrameworkSpecHelper++import Data.Monoid+import Test.Hspec+import qualified Data.Text as T++app :: SpockT IO ()+app =+    do get "/" $ text "root"+       get "/verb-test" $ text "GET"+       post "/verb-test" $ text "POST"+       put "/verb-test" $ text "PUT"+       delete "/verb-test" $ text "DELETE"+       patch "/verb-test" $ text "PATCH"+       get "/param-test/:int" $+           do Just (i :: Int) <- param "int"+              text $ "int" <> (T.pack $ show i)+       get "/param-test/static" $+           text "static"+       subcomponent "/subcomponent" $+         do get "foo" $ text "foo"+            subcomponent "/subcomponent2" $+              do get "bar" $ text "bar"++spec :: Spec+spec = describe "SimpleRouting" $ frameworkSpec (spockApp id app)