packages feed

burrito 1.1.0.2 → 1.2.0.0

raw patch · 5 files changed

+27/−24 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Burrito.Internal.Render: render :: Template -> String
- Burrito.Internal.Render: template :: Template -> Builder
+ Burrito.Internal.Type.Template: render :: Template -> String

Files

burrito.cabal view
@@ -1,7 +1,7 @@ cabal-version: 2.2  name: burrito-version: 1.1.0.2+version: 1.2.0.0  synopsis: Parse and render URI templates. description:
src/lib/Burrito.hs view
@@ -28,7 +28,7 @@ -- In short, use @parse@ to parse templates and @expand@ to render them. module Burrito   ( Parse.parse-  , Render.render+  , Template.render   , Expand.expand   , Expand.expandWith   , Match.match@@ -44,7 +44,6 @@ import qualified Burrito.Internal.Expand as Expand import qualified Burrito.Internal.Match as Match import qualified Burrito.Internal.Parse as Parse-import qualified Burrito.Internal.Render as Render import qualified Burrito.Internal.TH as TH import qualified Burrito.Internal.Type.Template as Template import qualified Burrito.Internal.Type.Value as Value
src/lib/Burrito/Internal/Render.hs view
@@ -12,7 +12,6 @@ import qualified Burrito.Internal.Type.Modifier as Modifier import qualified Burrito.Internal.Type.Name as Name import qualified Burrito.Internal.Type.Operator as Operator-import qualified Burrito.Internal.Type.Template as Template import qualified Burrito.Internal.Type.Token as Token import qualified Burrito.Internal.Type.Variable as Variable import qualified Data.List as List@@ -20,23 +19,8 @@ import qualified Data.Text.Lazy as LazyText import qualified Data.Text.Lazy.Builder as Builder --- | Renders a template back into a string. This is essentially the opposite of--- @parse@. Usually you'll want to use @expand@ to actually substitute--- variables in the template, but this can be useful for printing out the--- template itself------ >>> render <$> parse "valid-template"--- Just "valid-template"--- >>> render <$> parse "{var}"--- Just "{var}"-render :: Template.Template -> String-render = builderToString . template- builderToString :: Builder.Builder -> String builderToString = LazyText.unpack . Builder.toLazyText--template :: Template.Template -> Builder.Builder-template = foldMap token . Template.tokens  token :: Token.Token -> Builder.Builder token x = case x of
src/lib/Burrito/Internal/Type/Template.hs view
@@ -1,11 +1,31 @@ {-# LANGUAGE DeriveDataTypeable #-} -module Burrito.Internal.Type.Template (Template(..)) where+module Burrito.Internal.Type.Template (Template (..), render) where +import qualified Burrito.Internal.Render as Render import qualified Burrito.Internal.Type.Token as Token import qualified Data.Data as Data+import qualified Data.Text.Lazy.Builder as Builder  -- | Represents a URI template. newtype Template = Template   { tokens :: [Token.Token]-  } deriving (Data.Data, Eq, Ord, Show)+  } deriving (Data.Data, Eq, Ord)++instance Show Template where+  show = render++-- | Renders a template back into a string. This is essentially the opposite of+-- @parse@. Usually you'll want to use @expand@ to actually substitute+-- variables in the template, but this can be useful for printing out the+-- template itself+--+-- >>> render <$> parse "valid-template"+-- Just "valid-template"+-- >>> render <$> parse "{var}"+-- Just "{var}"+render :: Template -> String+render = Render.builderToString . template++template :: Template -> Builder.Builder+template = foldMap Render.token . tokens
src/test/Main.hs view
@@ -167,7 +167,7 @@     . Hspec.it "round trips"     . QC.property     $ \(Template template) ->-        Burrito.parse (Burrito.render template) == Just template+        Burrito.parse (show template) == Just template  -- brittany-next-binding --columns 160 tests :: [Test]@@ -1169,7 +1169,7 @@         values = testValues test         actual = Burrito.expand values template       actual `Hspec.shouldBe` expected-      Burrito.parse (Burrito.render template) `Hspec.shouldBe` Just template+      Burrito.parse (show template) `Hspec.shouldBe` Just template       let         relevant =           List.sort $ keepRelevant (templateVariables template) values@@ -1261,7 +1261,7 @@  instance Show Template where   show (Template template) =-    unwords [show $ Burrito.render template, "{-", show template, "-}"]+    unwords [show $ show template, "{-", show (Template.tokens template), "-}"]  instance QC.Arbitrary Template where   arbitrary = Template <$> arbitraryTemplate