Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
greg-1-anderson committed Oct 5, 2018
2 parents a4a366c + a63ad5d commit 5b7ca3a
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 33 deletions.
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
# Changelog

### Unreleased
### 0.3.0 ~ 0.4.0 - 2018/Oct/4

* List pending changes here.
* [BREAKING] Switch logic operators from & and | to && and ||
* Add an annotation @filter-default-field

### 0.2.0 - 2018/Oct/3

* Factor out filter hooks for better usability.

### 0.1.0 - 2018/Jul/18

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ $ mycmd example p1 p2 --filter='color~=#^red.*#'
The filter decides whether to include or exclude each **top-level element** based on the result of evaluating the provided expression on each element.

- Nested data elements may be tested, e.g. via `attributes.color=red`
- Simple boolean logic may be used, e.g. `color=red&shape=round`
- Simple boolean logic may be used, e.g. `color=red&&shape=round`

Parenthesis are not supported.

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.1-dev
0.4.0-dev
2 changes: 1 addition & 1 deletion src/Operators/LogicalAndOp.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ public function test(Data $row)
*/
public function __toString()
{
return "{$this->lhs}&{$this->rhs}";
return "{$this->lhs}&&{$this->rhs}";
}
}
2 changes: 1 addition & 1 deletion src/Operators/LogicalOrOp.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ public function test(Data $row)
*/
public function __toString()
{
return "{$this->lhs}|{$this->rhs}";
return "{$this->lhs}||{$this->rhs}";
}
}
44 changes: 22 additions & 22 deletions tests/FactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ public function testFactoryParsingValues()
['a!*=b', '!a*=b',],
['a!~=#b#', '!a~=#b#',],

['a=b&c=d',],
['a*=b|c=d',],
['a~=#b#&c~=d',],
['!a=b|!c=d',],
['!a*=b&c*=d',],
['!a~=#b#&c=d',],
['a!=b&c!=d', '!a=b&!c=d',],
['a!*=b|c!*=d', '!a*=b|!c*=d',],
['a!~=#b#&c!~=#d#', '!a~=#b#&!c~=#d#',],

['a=b&c=d&e=f',],
['a=b|c=d&e=f',],
['a=b|c=d|e=f',],
['a=b&&c=d',],
['a*=b||c=d',],
['a~=#b#&&c~=d',],
['!a=b||!c=d',],
['!a*=b&&c*=d',],
['!a~=#b#&&c=d',],
['a!=b&&c!=d', '!a=b&&!c=d',],
['a!*=b||c!*=d', '!a*=b||!c*=d',],
['a!~=#b#&&c!~=#d#', '!a~=#b#&&!c~=#d#',],

['a=b&&c=d&&e=f',],
['a=b||c=d&&e=f',],
['a=b||c=d||e=f',],

];
}
Expand Down Expand Up @@ -100,16 +100,16 @@ public function testFactoryEvaluationValues()
['a.b~=#c#', ['a' => ['b' => 'abcd']], true,],
['a.b~=#c#', ['b' => ['b' => 'c']], false,],

['a=b&c=d', ['a' => 'b', 'c' => 'd'], true,],
['a=b&c=d', ['a' => 'b', 'c' => 'xd'], false,],
['a=b|c=d', ['a' => 'b', 'c' => 'xd'], true,],
['a=b&&c=d', ['a' => 'b', 'c' => 'd'], true,],
['a=b&&c=d', ['a' => 'b', 'c' => 'xd'], false,],
['a=b||c=d', ['a' => 'b', 'c' => 'xd'], true,],

['a*=b&c*=d', ['a' => 'b', 'c' => 'd'], true,],
['a*=b&c*=d', ['a' => 'b', 'c' => 'xd'], true,],
['a*=b&c*=d', ['a' => 'b', 'c' => 'xy'], false,],
['a*=b|c*=d', ['a' => 'b', 'c' => 'xd'], true,],
['a*=b|c*=d', ['a' => 'xb', 'c' => 'xd'], true,],
['a*=b|c*=d', ['a' => 'xy', 'c' => 'xy'], false,],
['a*=b&&c*=d', ['a' => 'b', 'c' => 'd'], true,],
['a*=b&&c*=d', ['a' => 'b', 'c' => 'xd'], true,],
['a*=b&&c*=d', ['a' => 'b', 'c' => 'xy'], false,],
['a*=b||c*=d', ['a' => 'b', 'c' => 'xd'], true,],
['a*=b||c*=d', ['a' => 'xb', 'c' => 'xd'], true,],
['a*=b||c*=d', ['a' => 'xy', 'c' => 'xy'], false,],

['a!=b', ['a' => 'b'], false,],
['a!=b', ['a' => 'abc'], true,],
Expand Down
4 changes: 2 additions & 2 deletions tests/FilterOutputDataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public function testFilterDataValues()

return [
[$source, 'color=red', 'a', ],
[$source, 'color=blue|shape=triangular', 'b,c', ],
[$source, 'color=red&shape=square', '', ],
[$source, 'color=blue||shape=triangular', 'b,c', ],
[$source, 'color=red&&shape=square', '', ],
];
}

Expand Down
6 changes: 3 additions & 3 deletions tests/OpCommandsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ public function exampleTestCommandParameters()
],

[
'a=b&c=d|x=y', self::STATUS_OK,
'parse', 'a=b&c=d|x=y',
'a=b&&c=d||x=y', self::STATUS_OK,
'parse', 'a=b&&c=d||x=y',
],

[
'Could not parse expression a', self::STATUS_ERROR,
'parse', 'a&b',
'parse', 'a&&b',
],

[
Expand Down

0 comments on commit 5b7ca3a

Please sign in to comment.