packages feed

qr-imager 0.2.2.0 → 1.0.0.0

raw patch · 6 files changed

+22/−36 lines, 6 filesdep ~aesondep ~basedep ~qr-imagerPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: aeson, base, qr-imager

API changes (from Hackage documentation)

- Data.QRCodes: byteStringToQRSec :: ByteString -> FilePath -> FilePath -> IO ()
- Data.QRCodes: byteStringToQRSec' :: ByteString -> (PublicKey, PrivateKey) -> FilePath -> IO ()
- Data.QRCodes: readQRStrSec :: FilePath -> FilePath -> IO String
+ Data.QRCodes: readQRStrSec :: (FromJSON a) => FilePath -> FilePath -> IO a
- Data.QRCodes: readQRStrSec' :: FilePath -> (PublicKey, PrivateKey) -> IO String
+ Data.QRCodes: readQRStrSec' :: (FromJSON a) => FilePath -> (PublicKey, PrivateKey) -> IO a

Files

− app/Main.hs
@@ -1,6 +0,0 @@-{-#LANGUAGE OverloadedStrings #-}--import Data.QRCodes.Exe (exec)--main :: IO ()-main = exec
qr-imager.cabal view
@@ -1,5 +1,5 @@ name: qr-imager-version: 0.2.2.0+version: 1.0.0.0 cabal-version: >=1.10 build-type: Simple license: BSD3@@ -29,7 +29,7 @@         Data.QRCodes.Signature     build-depends:         base >=4.7 && <5,-        aeson >=0.11.2.1 && <0.12,+        aeson >=0.11.3.0 && <0.12,         JuicyPixels >=3.2.8 && <3.3,         vector >=0.11.0.0 && <0.12,         bytestring >=0.10.8.1 && <0.11,@@ -47,21 +47,12 @@     other-modules:         Data.QRCodes.Utils -executable qrpipe-    main-is: Main.hs-    build-depends:-        base >=4.9.0.0 && <4.10,-        qr-imager >=0.2.2.0 && <0.3-    default-language: Haskell2010-    hs-source-dirs: app-    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.2.0 && <0.3,+        qr-imager >=1.0.0.0 && <1.1,         hspec >=2.2.4 && <2.3     default-language: Haskell2010     hs-source-dirs: test
src/Data/QRCodes.hs view
@@ -8,8 +8,6 @@                     , createSecureQRCode'                     -- * Functions for `ByteStrings`                     , byteStringToQR-                    , byteStringToQRSec-                    , byteStringToQRSec'                     -- * functions to read QR codes                     , readQRString                     , readQRStrSec@@ -20,7 +18,9 @@ import Codec.Picture.Png (writePng) import Data.ByteString.Lazy (toStrict) import qualified Data.ByteString.Char8 as BS+import qualified Data.ByteString.Lazy.Char8 as BSL import Data.Char (toLower)+import Data.Maybe import Control.Lens.Tuple import Control.Lens (view) import Control.Applicative ((<$>))@@ -73,13 +73,13 @@ -- | given a filepath pointing to a QR code, get the contents & verify signature with the keyfile -- -- > readQRStrSec "output.png" ".key.hk"-readQRStrSec :: FilePath -> FilePath -> IO String-readQRStrSec filepath keyfile = do+readQRStrSec :: (FromJSON a) => FilePath -> FilePath -> IO a+readQRStrSec filepath keyfile = fromJust . decode . BSL.pack <$> do     enc <- (map toLower) . init . (drop 8) . (view _2) <$> readCreateProcessWithExitCode (shell $ "zbarimg " ++ filepath) ""     (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+readQRStrSec' :: (FromJSON a) => FilePath -> (PublicKey, PrivateKey) -> IO a+readQRStrSec' filepath key = fromJust . decode . BSL.pack <$> do     enc <- (map toLower) . init . (drop 8) . (view _2) <$> readCreateProcessWithExitCode (shell $ "zbarimg " ++ filepath) ""     (fmap $ liftEither BS.unpack) . (flip checkSig key) . resolveUpper $ (BS.pack) enc
src/Data/QRCodes/Exe.hs view
@@ -2,6 +2,7 @@ module Data.QRCodes.Exe where  import Options.Applicative+import Data.Aeson import qualified Data.ByteString as B import System.Environment (getArgs) --fix soon! import Data.QRCodes@@ -28,22 +29,22 @@ -- | Takes a `Prog` and returns the appropriate IO action act :: Prog -> IO () act (Prog Output True True filepath) = do-    pipeIn <- B.getContents-    byteStringToQRSec pipeIn ".key.hk" filepath-    readQRStrSec filepath ".key.hk" >>= print+    pipeIn <- getContents+    createSecureQRCode pipeIn ".key.hk" filepath+    (readQRStrSec filepath ".key.hk" :: IO String) >>= print act (Prog Output False True filepath) = do     pipeIn <- B.getContents     byteStringToQR pipeIn filepath     readQRString filepath >>= print act (Prog Output True False filepath) = do-    pipeIn <- B.getContents-    byteStringToQRSec pipeIn ".key.hk" filepath+    pipeIn <- getContents+    createSecureQRCode (pipeIn) ".key.hk" filepath act (Prog Output False False filepath) = do     pipeIn <- B.getContents     byteStringToQR pipeIn filepath-act (Prog Input True _ filepath) = do-    readQRStrSec filepath ".key.hk" >>= print-act (Prog Input False _ filepath) = do+act (Prog Input True _ filepath) = +    (readQRStrSec filepath ".key.hk" :: IO String) >>= print+act (Prog Input False _ filepath) =      readQRString filepath >>= print  -- | Parser for the command line
stack.yaml view
@@ -23,7 +23,7 @@ # resolver: #  name: custom-snapshot #  location: "./custom-snapshot.yaml"-resolver: lts-7.16+resolver: lts-7.18  # User packages to be built. # Various formats can be used as shown in the example below.
test/Spec.hs view
@@ -11,6 +11,6 @@     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")+      createSecureQRCode ("small" :: String) ".key.hk" "qrcode-sec.png" >>= (`shouldBe` ())+    it "reads a secure QR code" $ do+      (readQRStrSec "qrcode-sec.png" ".key.hk" :: IO String) >>= (`shouldBe` "small")