pdf-slave-template 1.1.0.0 → 1.2.0.0
raw patch · 3 files changed
+28/−14 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +5/−0
- pdf-slave-template.cabal +1/−1
- src/Text/PDF/Slave/Template.hs +22/−13
CHANGELOG.md view
@@ -1,3 +1,8 @@+1.2.0.0+=======++* Add `bundle` bool flag to distinguish bundle and ordinary template files.+ 1.1.0.0 =======
pdf-slave-template.cabal view
@@ -1,5 +1,5 @@ name: pdf-slave-template-version: 1.1.0.0+version: 1.2.0.0 synopsis: Template format definition for pdf-slave tool description: Please see README.md homepage: https://github.com/ncrashed/pdf-slave#readme
src/Text/PDF/Slave/Template.hs view
@@ -12,7 +12,7 @@ , TemplateFile(..) ) where -import Control.Monad (mzero)+import Control.Monad (mzero, unless) import Data.ByteString (ByteString) import Data.Monoid import Data.Text as T@@ -102,12 +102,15 @@ } deriving (Generic, Show) instance FromJSON Template where- parseJSON (Object o) = Template- <$> o .: "name"- <*> o .:? "input"- <*> o .: "body"- <*> o .:? "dependencies" .!= mempty- <*> o .:? "haskintex-opts" .!= mempty+ parseJSON (Object o) = do+ flag <- o .: "bundle"+ unless flag $ fail "Expected bundle template format, but got ordinary template"+ Template+ <$> o .: "name"+ <*> o .:? "input"+ <*> o .: "body"+ <*> o .:? "dependencies" .!= mempty+ <*> o .:? "haskintex-opts" .!= mempty parseJSON _ = mzero instance ToJSON Template where@@ -117,6 +120,7 @@ , "body" .= templateBody , "dependencies" .= templateDeps , "haskintex-opts" .= templateHaskintexOpts+ , "bundle" .= True ] -- | Same as 'TemplateDependency' but keeps contents in separate files@@ -179,12 +183,17 @@ } deriving (Generic, Show) instance FromJSON TemplateFile where- parseJSON (Object o) = TemplateFile- <$> o .: "name"- <*> o .:? "input"- <*> o .: "body"- <*> o .:? "dependencies" .!= mempty- <*> o .:? "haskintex-opts" .!= mempty+ parseJSON (Object o) = do+ mflag <- o .:? "bundle"+ case mflag of+ Just True -> fail "Expected ordinary template format, but got bundle template"+ _ -> return ()+ TemplateFile+ <$> o .: "name"+ <*> o .:? "input"+ <*> o .: "body"+ <*> o .:? "dependencies" .!= mempty+ <*> o .:? "haskintex-opts" .!= mempty parseJSON _ = mzero instance ToJSON TemplateFile where