From 98c169fc91a30026bfc26fb579854aaba77b67c7 Mon Sep 17 00:00:00 2001 From: Marcin Tolysz Date: Fri, 30 Jan 2015 13:47:00 +0000 Subject: [PATCH] bump version add travis build add macro for old and new utf8-string --- .travis.yml | 36 ++++++++++++++++++++++++++++++++++++ Text/Feed/Import.hs | 14 +++++++++++++- feed.cabal | 2 +- 3 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..9e495cf --- /dev/null +++ b/.travis.yml @@ -0,0 +1,36 @@ +language: haskell +before_install: +env: + - GHCVER=7.4.2 CABALVER=1.18 + - GHCVER=7.6.3 CABALVER=1.18 + - GHCVER=7.8.4 CABALVER=1.18 + - GHCVER=7.10.1 CABALVER=1.22 + - GHCVER=head CABALVER=head + +matrix: + allow_failures: + - env: GHCVER=7.10.1 CABALVER=1.22 + - env: GHCVER=head CABALVER=head + - env: GHCVER=7.4.2 CABALVER=1.18 + +before_install: + - travis_retry sudo add-apt-repository -y ppa:hvr/ghc + - travis_retry sudo apt-get update + - travis_retry sudo apt-get install cabal-install-$CABALVER ghc-$GHCVER + - export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$HOME/.cabal/bin:$PATH + - cabal --version + +install: + - cabal update +# - cabal install alex happy + - cabal install --only-dependencies --enable-tests + +script: +# - cabal configure --enable-tests --enable-library-coverage || cabal configure --enable-tests --enable-coverage + - cabal configure --enable-tests + - cabal build + - cabal test + +#after_script: +# - cabal install hpc-coveralls +# - hpc-coveralls --exclude-dir=test test diff --git a/Text/Feed/Import.hs b/Text/Feed/Import.hs index 8fde5f9..b0e031b 100644 --- a/Text/Feed/Import.hs +++ b/Text/Feed/Import.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} -------------------------------------------------------------------- -- | -- Module : Text.Feed.Import @@ -32,13 +33,24 @@ import Text.XML.Light.Lexer ( XmlSource ) import Control.Monad +#if MIN_VERSION_utf8_string(1,0,0) +import Codec.Binary.UTF8.String (decodeString) +import System.IO (IOMode(..), hGetContents, openBinaryFile ) +utf8readFile :: FilePath -> IO String +utf8readFile fp = fmap decodeString (hGetContents =<< openBinaryFile fp ReadMode) +#else import System.IO.UTF8 as UTF8 ( readFile ) +utf8readFile :: FilePath -> IO String +utf8readFile = UTF8.readFile +#endif + + -- | 'parseFeedFromFile fp' reads in the contents of the file at @fp@; -- the assumed encoding is UTF-8. parseFeedFromFile :: FilePath -> IO Feed parseFeedFromFile fp = do - ls <- UTF8.readFile fp + ls <- utf8readFile fp case parseFeedString ls of Nothing -> fail ("parseFeedFromFile: not a well-formed XML content in: " ++ fp) Just f -> return f diff --git a/feed.cabal b/feed.cabal index 06787fa..f753a33 100644 --- a/feed.cabal +++ b/feed.cabal @@ -1,5 +1,5 @@ Name: feed -Version: 0.3.9.2 +Version: 0.3.9.3 License: BSD3 License-file: LICENSE Category: Text