yst 0.4.0.1 → 0.4.1
raw patch · 5 files changed
+33/−12 lines, 5 filesdep +scientificdep ~aeson
Dependencies added: scientific
Dependency ranges changed: aeson
Files
- README.markdown +9/−5
- Yst/Data.hs +9/−4
- Yst/Types.hs +6/−1
- changelog +6/−0
- yst.cabal +3/−2
README.markdown view
@@ -279,16 +279,20 @@ > Selects only items that meet a condition. -> A *condition* in a `WHERE` statement is a Boolean combination (using+> A *condition* in a `WHERE` statement is a Boolean combination (using `NOT`, `AND`, `OR`, and parentheses for disambiguation) of *basic-conditions*. A *basic condition* is of the form `value op value`,-where `value` may be either a fieldname or a constant. Note that-all constants must be enclosed in quotes. `op` may be one of the-following: `=`, `>=`, `<=`, `>`, `<` and 'contains'.+conditions*. A *basic condition* is either of the form `value op+value`, where `value` may be either a fieldname or a constant, or of+the form `HAS fieldname' where `fieldname' is a string constant. Note+that all constants must be enclosed in quotes. `op` may be one of the+following: `=`, `>=`, `<=`, `>`, `<` and 'contains'. > The basic condition `arg1 contains arg2` succeeds if and only if `arg1` is a fieldname whose value is a list containing the value of `arg2`.++> The basic condition `HAS fieldname' succeeds if and only if the item+has the fieldname as a field. For example, `HAS "data"'. Note that the order of transformations is significant. You can get different results if you use `LIMIT` before or after `ORDER BY`,
Yst/Data.hs view
@@ -77,9 +77,11 @@ applyDataOption _ _ = error "order by and group by can be used only on lists" satisfiesCond :: FilterCond -> Node -> Bool-satisfiesCond (And c1 c2) n = satisfiesCond c1 n && satisfiesCond c2 n-satisfiesCond (Or c1 c2) n = satisfiesCond c1 n || satisfiesCond c2 n-satisfiesCond (Not c1) n = not (satisfiesCond c1 n)+satisfiesCond (And c1 c2) n = satisfiesCond c1 n && satisfiesCond c2 n+satisfiesCond (Or c1 c2) n = satisfiesCond c1 n || satisfiesCond c2 n+satisfiesCond (Not c1) n = not (satisfiesCond c1 n)+satisfiesCond (Has s) (NMap ns) = elem s (map fst ns)+satisfiesCond (Has _) _ = False satisfiesCond (Filter test arg1 arg2) n = (filterTestPred test) (filterArgToNode arg1 n) (filterArgToNode arg2 n) @@ -221,7 +223,7 @@ return $ Where cond pBooleanCondition :: GenParser Char st FilterCond-pBooleanCondition = spaces >> (pNot <|> pAnd <|> pOr <|> pInParens pBooleanCondition <|> pBasicCond)+pBooleanCondition = spaces >> ( pHas <|> pNot <|> pAnd <|> pOr <|> pInParens pBooleanCondition <|> pBasicCond) pInParens :: GenParser Char st a -> GenParser Char st a pInParens innerParser = try $ do@@ -234,6 +236,9 @@ pNot :: GenParser Char st FilterCond pNot = try $ pString "not" >> pSpace >> liftM Not pBooleanCondition++pHas :: GenParser Char st FilterCond+pHas = try $ pString "has" >> pSpace >> liftM Has (pQuoted '"' <|> pQuoted '\'') pAnd :: GenParser Char st FilterCond pAnd = try $ do
Yst/Types.hs view
@@ -27,6 +27,7 @@ import Data.Aeson import qualified Data.Map as M import System.Locale (defaultTimeLocale)+import Data.Scientific (coefficient, base10Exponent) import Control.Monad data Site = Site {@@ -70,6 +71,7 @@ | And FilterCond FilterCond | Or FilterCond FilterCond | Not FilterCond+ | Has String deriving (Show, Read, Eq) data FilterArg = AttrValue String@@ -121,7 +123,10 @@ Success y -> return $ NList y _ -> mzero parseJSON (Bool b) = return $ NString $ show b- parseJSON (Number y) = return $ NString $ show y+ parseJSON (Number n)+ | base10Exponent n >= 0 = return $ NString $ show $+ coefficient n * (10 ^ base10Exponent n)+ | otherwise = return $ NString $ show n parseJSON _ = return $ NNil handleMerges :: H.HashMap T.Text Value -> H.HashMap T.Text Value
changelog view
@@ -1,3 +1,9 @@+yst 0.4.1 (released 30 May 2014)++ * Fix rendering of integers in YAML when compiled against+ recent versions of aeson.+ * Added HAS to WHERE condition in queries (Ohad Kammar).+ yst 0.4.0.1 (released 15 Sep 2013) * Removed unneeded build-depends.
yst.cabal view
@@ -1,5 +1,5 @@ name: yst-version: 0.4.0.1+version: 0.4.1 Tested-With: GHC == 7.4.1 Cabal-version: >= 1.8 build-type: Simple@@ -56,7 +56,8 @@ Yst.Render, Yst.Build, Yst.CSV, Yst.Sqlite3 build-depends: base >=3 && < 5, unordered-containers, HStringTemplate >= 0.6.1 && < 0.6.9 || > 0.6.11 && < 0.8,- yaml, csv, aeson, text,+ yaml, csv, aeson >= 0.7 && < 0.8, text,+ scientific >= 0.2 && < 0.4, filepath, containers, directory, time, old-locale, old-time, parsec, xhtml, pandoc >= 1.10 && < 1.13,