packages feed

qr-imager 0.2.1.3 → 0.2.2.0

raw patch · 4 files changed

+24/−9 lines, 4 filesdep +hspecdep ~basedep ~qr-imager

Dependencies added: hspec

Dependency ranges changed: base, qr-imager

Files

README.md view
@@ -1,4 +1,6 @@ # QR Imager Library+[![Build Status](https://travis-ci.org/vmchale/QR-writer.svg?branch=master)](https://travis-ci.org/vmchale/QR-writer)+ This is a library to generate `.png` files from QR codes.  ## Dependencies
qr-imager.cabal view
@@ -1,5 +1,5 @@ name: qr-imager-version: 0.2.1.3+version: 0.2.2.0 cabal-version: >=1.10 build-type: Simple license: BSD3@@ -41,6 +41,7 @@         process >=1.4.2.0 && <1.5,         MissingH >=1.4.0.1 && <1.5,         optparse-applicative >=0.12.1.0 && <0.13+    pkgconfig-depends: libqrencode -any     default-language: Haskell2010     hs-source-dirs: src     other-modules:@@ -50,18 +51,18 @@     main-is: Main.hs     build-depends:         base >=4.9.0.0 && <4.10,-        qr-imager >=0.2.1.3 && <0.3+        qr-imager >=0.2.2.0 && <0.3     default-language: Haskell2010     hs-source-dirs: app-    ghc-options: -threaded -rtsopts -with-rtsopts=-N -O3 -fllvm -optlo-O3+    ghc-options: -threaded -rtsopts -with-rtsopts=-N  test-suite test-lib     type: exitcode-stdio-1.0     main-is: Spec.hs     build-depends:         base >=4.9.0.0 && <4.10,-        qr-imager >=0.2.1.3 && <0.3,-        process >=1.4.2.0 && <1.5+        qr-imager >=0.2.2.0 && <0.3,+        hspec >=2.2.4 && <2.3     default-language: Haskell2010     hs-source-dirs: test     ghc-options: -threaded -rtsopts -with-rtsopts=-N
src/Data/QRCodes.hs view
@@ -76,10 +76,10 @@ readQRStrSec :: FilePath -> FilePath -> IO String readQRStrSec filepath keyfile = do     enc <- (map toLower) . init . (drop 8) . (view _2) <$> readCreateProcessWithExitCode (shell $ "zbarimg " ++ filepath) ""-    (fmap $ liftEither show) . (flip checkSigFile keyfile) . resolveUpper $ (BS.pack) enc+    (fmap $ liftEither BS.unpack) . (flip checkSigFile keyfile) . resolveUpper $ (BS.pack) enc  -- | Read an image containing a QR code, decode and verify the signature using the given key. readQRStrSec' :: FilePath -> (PublicKey, PrivateKey) -> IO String readQRStrSec' filepath key = do     enc <- (map toLower) . init . (drop 8) . (view _2) <$> readCreateProcessWithExitCode (shell $ "zbarimg " ++ filepath) ""-    (fmap $ liftEither show) . (flip checkSig key) . resolveUpper $ (BS.pack) enc+    (fmap $ liftEither BS.unpack) . (flip checkSig key) . resolveUpper $ (BS.pack) enc
test/Spec.hs view
@@ -1,4 +1,16 @@-import System.Process+{-# LANGUAGE OverloadedStrings #-}  +import Data.QRCodes+import Test.Hspec+ main :: IO ()-main = readCreateProcess (shell "echo 'hello friend' | qrpipe write -v -s output.png") "" >>= putStrLn+main = hspec $ do+  describe "Data.QRCodes" $ do+    it "writes a QR code" $ do+      byteStringToQR "hello world" "qrcode.png" >>= (`shouldBe` ())+    it "reads a QR code" $ do+      readQRString "qrcode.png" >>= (`shouldBe` "hello world")+    it "writes a secure QR code" $ do+      byteStringToQRSec "helloworld" ".key.hk" "qrcode-sec.png" >>= (`shouldBe` ())+    it "reads a secire QR code" $ do+      readQRStrSec "qrcode-sec.png" ".key.hk" >>= (`shouldBe` "helloworld")