foscam-filename 0.0.3 → 0.0.4
raw patch · 3 files changed
+24/−11 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Data.Foscam.File.Filename: getFilename :: Filename -> String
Files
- changelog +4/−0
- foscam-filename.cabal +1/−1
- src/Data/Foscam/File/Filename.hs +19/−10
changelog view
@@ -6,3 +6,7 @@ * Add folds, getters, traversals. +0.0.4++* Add `getFilename` function.+
foscam-filename.cabal view
@@ -1,5 +1,5 @@ name: foscam-filename-version: 0.0.3+version: 0.0.4 license: BSD3 license-file: LICENSE author: Tony Morris <ʇǝu˙sıɹɹoɯʇ@ןןǝʞsɐɥ> <dibblego>
src/Data/Foscam/File/Filename.hs view
@@ -7,13 +7,14 @@ Filename(..) , AsFilename(..) , filename+, getFilename ) where import Control.Applicative(Applicative((<*>)), (<*), (<$>)) import Control.Category(id)-import Control.Lens(Optic', lens)+import Control.Lens(Optic', lens, ( # )) import Control.Monad(Monad)-import Data.Digit(Digit)+import Data.Digit(Digit, digitC) import Data.Eq(Eq) import Data.Foscam.File.Internal(digitCharacter) import Data.Foscam.File.Alias(AsAlias(_Alias), Alias, alias)@@ -22,7 +23,9 @@ import Data.Foscam.File.ImageId(AsImageId(_ImageId), ImageId, imageId) import Data.Foscam.File.Time(AsTime(_Time), Time, time) import Data.Functor(Functor)+import Data.List((++)) import Data.Ord(Ord)+import Data.String(String) import Text.Parser.Char(CharParsing, char, string) import Text.Parser.Combinators((<?>)) import Prelude(Show)@@ -80,35 +83,35 @@ -- | ----- >>> parse Filename "test" "00626E44C831(house)_1_20150209134121_2629.jpg"+-- >>> parse filename "test" "00626E44C831(house)_1_20150209134121_2629.jpg" -- Right (Filename (DeviceId (DeviceIdCharacter '0') (DeviceIdCharacter '0') (DeviceIdCharacter '6') (DeviceIdCharacter '2') (DeviceIdCharacter '6') (DeviceIdCharacter 'E') (DeviceIdCharacter '4') (DeviceIdCharacter '4') (DeviceIdCharacter 'C') (DeviceIdCharacter '8') (DeviceIdCharacter '3') (DeviceIdCharacter '1')) (Alias (AliasCharacter 'h') [AliasCharacter 'o',AliasCharacter 'u',AliasCharacter 's',AliasCharacter 'e']) 1 (Date 2 0 1 5 0 2 0 9) (Time 1 3 4 1 2 1) (ImageId 2 [6,2,9])) ----- >>> parse Filename "test" "00626E44C829(garage)_1_20140313234556_2660.jpg"+-- >>> parse filename "test" "00626E44C829(garage)_1_20140313234556_2660.jpg" -- Right (Filename (DeviceId (DeviceIdCharacter '0') (DeviceIdCharacter '0') (DeviceIdCharacter '6') (DeviceIdCharacter '2') (DeviceIdCharacter '6') (DeviceIdCharacter 'E') (DeviceIdCharacter '4') (DeviceIdCharacter '4') (DeviceIdCharacter 'C') (DeviceIdCharacter '8') (DeviceIdCharacter '2') (DeviceIdCharacter '9')) (Alias (AliasCharacter 'g') [AliasCharacter 'a',AliasCharacter 'r',AliasCharacter 'a',AliasCharacter 'g',AliasCharacter 'e']) 1 (Date 2 0 1 4 0 3 1 3) (Time 2 3 4 5 5 6) (ImageId 2 [6,6,0])) ----- >>> parse Filename "test" "00626E44C82x(garage)_1_20140313234556_2660.jpg"+-- >>> parse filename "test" "00626E44C82x(garage)_1_20140313234556_2660.jpg" -- Left "test" (line 1, column 13): -- not a device ID character: x ----- >>> parse Filename "test" "00626E44C829(gara*ge)_1_20140313234556_2660.jpg"+-- >>> parse filename "test" "00626E44C829(gara*ge)_1_20140313234556_2660.jpg" -- Left "test" (line 1, column 19): -- not an alias character: * ----- >>> parse Filename "test" "00626E44C829(garage) 1_20140313234556_2660.jpg"+-- >>> parse filename "test" "00626E44C829(garage) 1_20140313234556_2660.jpg" -- Left "test" (line 1, column 20): -- unexpected " " -- expecting ")_" ----- >>> parse Filename "test" "00626E44C829(garage)_x_20140313234556_2660.jpg"+-- >>> parse filename "test" "00626E44C829(garage)_x_20140313234556_2660.jpg" -- Left "test" (line 1, column 23): -- not a digit: x ----- >>> parse Filename "test" "00626E44C829(garage)_1 20140313234556_2660.jpg"+-- >>> parse filename "test" "00626E44C829(garage)_1 20140313234556_2660.jpg" -- Left "test" (line 1, column 23): -- unexpected " " -- expecting "_" ----- >>> parse Filename "test" "00626E44C829(garage)_1_x0140313234556_2660.jpg"+-- >>> parse filename "test" "00626E44C829(garage)_1_x0140313234556_2660.jpg" -- Left "test" (line 1, column 25): -- not a digit: x filename ::@@ -127,3 +130,9 @@ char '_' <*> imageId <* string ".jpg" <?> "file"++getFilename ::+ Filename+ -> String+getFilename (Filename i a x d t m) =+ _DeviceId # i ++ '(' : _Alias # a ++ ")_" ++ [digitC # x, '_'] ++ _Date # d ++ _Time # t ++ '_' : _ImageId # m ++ ".jpg"