asif 3.3.4 → 3.4.0
raw patch · 6 files changed
+26/−1 lines, 6 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Arbor.File.Format.Asif.Format: Bool :: Format
+ Arbor.File.Format.Asif.Format: SBool :: Bool -> SegmentValue
+ Arbor.File.Format.Asif.Write: boolSegment :: MonadResource m => (a -> Bool) -> Text -> FoldM m a [Segment Handle]
Files
- asif.cabal +1/−1
- src/Arbor/File/Format/Asif/Format/SegmentValue.hs +5/−0
- src/Arbor/File/Format/Asif/Format/Text.hs +1/−0
- src/Arbor/File/Format/Asif/Format/Type.hs +1/−0
- src/Arbor/File/Format/Asif/Write.hs +8/−0
- test/Arbor/File/Format/Asif/WriteSpec.hs +10/−0
asif.cabal view
@@ -3,7 +3,7 @@ -- see: https://github.com/sol/hpack name: asif-version: 3.3.4+version: 3.4.0 description: Please see the README on Github at <https://github.com/packetloop/asif#readme> category: Services homepage: https://github.com/packetloop/asif#readme
src/Arbor/File/Format/Asif/Format/SegmentValue.hs view
@@ -28,6 +28,7 @@ data SegmentValue = SString LBS.ByteString+ | SBool Bool | SChar Char | STime UTCTime | SIpv4 IPv4@@ -68,6 +69,10 @@ if LBS.null bs then [] else init (LBS.split 0 bs) <&> SString++ F.Bool -> whenNonEmpty bs $+ let toBool = (/=) 0+ in bs & getValues 1 G.getWord8 <&> (SBool . toBool) F.Char -> whenNonEmpty bs $ LBSC.unpack bs <&> SChar
src/Arbor/File/Format/Asif/Format/Text.hs view
@@ -19,6 +19,7 @@ segmentValueToText :: SegmentValue -> Text segmentValueToText = \case SString v -> T.decodeUtf8 (LBS.toStrict v)+ SBool v -> T.pack $ show v SChar v -> T.singleton v STime v -> T.pack $ show v
src/Arbor/File/Format/Asif/Format/Type.hs view
@@ -9,6 +9,7 @@ = Binary | Bitmap | BitString+ | Bool | Char | Int8 | Int16LE
src/Arbor/File/Format/Asif/Write.hs view
@@ -20,6 +20,7 @@ , nullTerminatedStringSegment , textSegment , asciiSegment+ , boolSegment , word8Segment , word16Segment , word32Segment@@ -148,6 +149,13 @@ asciiSegment = genericFold BB.char8 (Known F.Char) -----++-- | Build a segment of 'Bool's, encoded as 'Word8's, where False == 0, and True == 1+boolSegment :: MonadResource m => (a -> Bool) -> T.Text -> FoldM m a [Segment Handle]+boolSegment f = genericFold BB.word8 (Known F.Bool) (bool2word8 . f)+ where+ bool2word8 False = 0+ bool2word8 True = 1 -- | Builds a segment of 'Word8's. word8Segment :: MonadResource m => (a -> Word8) -> T.Text -> FoldM m a [Segment Handle]
test/Arbor/File/Format/Asif/WriteSpec.hs view
@@ -48,6 +48,16 @@ ----- + it "should write out and read back in a bool segment" $ require $ property $ do+ lst <- forAll $ G.list (R.linear 0 50) G.bool++ lbs <- buildAsifBytestring "wxyz" Nothing (boolSegment id "bool") lst++ let Right segments = extractSegments (AP.string "seg:wxyz") lbs+ [names, times, types, seg] <- forAll $ pure (segmentValues <$> segments)++ (SBool <$> lst) === seg+ it "should write out and read back in a word8 segment" $ require $ property $ do lst <- forAll $ G.list (R.linear 0 50) (G.word8 R.linearBounded)