<commit_before># go-ruler

json-y object testing in go

## Installation

```
go get github.com/hopkinsth/go-ruler
```

## Introduction

go-ruler is a reimplementaion of [ruler](https://github.com/RedVentures/ruler) in go, partly as an experiment, eventually as an optimization strategy. go-ruler does not yet support programmatically composing rules with function calls like ruler does and exists primarily for processing rules described arrays of JSON objects with this structure:

```json
{
  "comparator": "eq",
  "path": "library.name",
  "value": "go-ruler"
}
```

Each of those objects (or 'filters') describes a condition for a property on some JSON object or json-object-esque structure. (In this go implementation, we're using `map[string]interface{}`.)

## Example

```go
package main

import "github.com/hopkinsth/go-ruler"
import "fmt"

func main() {
  rules := []byte(`[
    {"comparator": "eq", "path": "library.name", "value": "go-ruler"},
    {"comparator": "gt", "path": "library.age", "value": 0.5}
  ]`)

  engine, _ := ruler.NewRulerWithJson(rules)

  result := engine.Test(map[string]interface{}{
    "library": map[string]interface{}{
      "name": "go-ruler",
      "age":  1.24,
    },
  })

  fmt.Println(result == true)
}
```<commit_msg>update README, round 1<commit_after># go-ruler

json-y object testing in go

## Installation

```
go get github.com/hopkinsth/go-ruler
```

## Introduction

go-ruler is an implementaion of [ruler](https://github.com/RedVentures/ruler) in go, partly as an experiment, eventually as an optimization strategy. go-ruler supports programmatically constructing rules in a way similar to js-ruler and can also process rules stored in arrays of JSON objects with this structure:

```json
{
  "comparator": "eq",
  "path": "library.name",
  "value": "go-ruler"
}
```

Each of those objects (or 'filters') describes a condition for a property on some JSON object or json-object-esque structure. (In this go implementation, we're using `map[string]interface{}`.)

## Example

```go
package main

import "github.com/hopkinsth/go-ruler"
import "fmt"

func main() {
  rules := []byte(`[
    {"comparator": "eq", "path": "library.name", "value": "go-ruler"},
    {"comparator": "gt", "path": "library.age", "value": 0.5}
  ]`)

  engine, _ := ruler.NewRulerWithJson(rules)

  result := engine.Test(map[string]interface{}{
    "library": map[string]interface{}{
      "name": "go-ruler",
      "age":  1.24,
    },
  })

  fmt.Println(result == true)
}
```

## License
Copyright 2015 <NAME>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with the License. You may obtain a copy of the License in the LICENSE file, or at:

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
{'fraction_non_alphanumeric': 0.13752838144664287, 'fraction_numerical': 0.006162828413882582, 'mean_word_length': 4.298969072164948, 'pattern_counts': {'":': 24, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 2, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6729717', 'n_tokens_mistral': 982, 'n_tokens_neox': 945, 'n_words': 339}