Skip to content

Commit 6d343d6

Browse files
committed
chore: cleaned up print statements
1 parent d772e3a commit 6d343d6

File tree

3 files changed

+8
-16
lines changed

3 files changed

+8
-16
lines changed

README.md

+7-9
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ JSON Rules is an abstraction layer over the [Golang Rules Engine](https://github
44

55
This package allows you to represent rules in JSON format instead of using the original ANTLR query syntax from the nikunjy/rules implementation.
66

7-
## Example Queries
8-
9-
You can find example queries in the [examples/](test/examples/) directory.
10-
117
## Operations
128

139
The following operations are supported, matching those available in the [Golang Rules Engine](https://github.com/nikunjy/rules):
@@ -33,18 +29,15 @@ The following operations are supported, matching those available in the [Golang
3329
| pr | present, will be true if you have a key as true |
3430
| not | not of a logical expression |
3531

36-
## JSON Rule Example
32+
## JSON Rule Guide
3733

3834
To create a JSON rule, follow these steps:
3935

4036
1. The `and` and `or` operation accepts a list of conditions. The and operation evaluates to true only if all conditions in the list are true, while the or operation evaluates to true if at least one condition is true. They are formatted as follows:
4137

4238
```json
4339
{
44-
"and": [
45-
{ "==": [{ "var": "y" }, 4] },
46-
{ ">": [{ "var": "x" }, 1] }
47-
]
40+
"and": [{ "==": [{ "var": "y" }, 4] }, { ">": [{ "var": "x" }, 1] }]
4841
}
4942
```
5043

@@ -66,7 +59,12 @@ To create a JSON rule, follow these steps:
6659
}
6760
```
6861

62+
## Examples
63+
64+
You can find more example json rules in the [examples/](test/examples/) directory.
65+
6966
## How to use
67+
7068
This example demonstrates how to initialize the parser with a JSON rule and evaluate it against a data set. You can adjust the paths and data as necessary for your specific use case.
7169

7270
```Go

parser/parser.go

-4
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,4 @@ func (p *Parser) formatRule(node map[string]interface{}) string {
6161

6262
func (p *Parser) Evaluate(items map[string]interface{}) bool {
6363
return parser.Evaluate(p.rule, items)
64-
}
65-
66-
func (p *Parser) GetRule() string {
67-
return p.rule
6864
}

test/parser_test.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package test
22

33
import (
4-
"fmt"
54
"path/filepath"
65
"testing"
76

@@ -16,7 +15,6 @@ func TestEqual(t *testing.T) {
1615
t.Errorf("%v", err)
1716
}
1817

19-
fmt.Println(p.GetRule())
2018
testData := map[string]interface{}{
2119
"x" : 1,
2220
}
@@ -139,7 +137,7 @@ func TestEqualAndGT(t *testing.T) {
139137
}
140138

141139
result := p.Evaluate(testData)
142-
assert.False(t, result, p.GetRule())
140+
assert.False(t, result)
143141
}
144142

145143

0 commit comments

Comments
 (0)