<commit_before># Muskox

A JSON Parser-Generator that takes a json-schema and converts it into a parser.

## Why?

Using a parser to handle inputs makes your app safe from attacks that rely on passing disallowed params, because disallowed params will either be ignored or rejected.

> Be definite about what you accept.(*) 
>
> Treat inputs as a language, accept it with a matching computational
> power, generate its recognizer from its grammar.
>
> Treat input-handling computational power as privilege, and reduce it
> whenever possible.

http://www.cs.dartmouth.edu/~sergey/langsec/postel-principle-patch.txt

## Installation

Add this line to your application's Gemfile:

    gem 'muskox'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install muskox

## Usage

TODO: Write usage instructions here

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request<commit_msg>add usage to readme<commit_after># Muskox

A JSON Parser-Generator that takes a json-schema and converts it into a parser.

## Why?

Using a parser to handle inputs makes your app safe from attacks that rely on passing disallowed params, because disallowed params will either be ignored or rejected.

> Be definite about what you accept.(*) 
>
> Treat inputs as a language, accept it with a matching computational
> power, generate its recognizer from its grammar.
>
> Treat input-handling computational power as privilege, and reduce it
> whenever possible.

http://www.cs.dartmouth.edu/~sergey/langsec/postel-principle-patch.txt

## Installation

Add this line to your application's Gemfile:

    gem 'muskox'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install muskox

## Usage

```ruby
    # to generate a parser, call generate w/ a JSON-Schema
    parser = Muskox.generate({
        "title" => "Schema",
        "type" => "object",
        "properties" => {
          "number" => {
            "type" => "integer"
          }
        },
        "required" => ["number"]
      })

    # then call parse with the string you want to have parsed
    n = parser.parse "{\"number\": 1}"
    # => {"number" => 1}
    
    # invalid types are disallowed
    parser.parse "{\"number\": true}" rescue puts $!
```

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
{'fraction_non_alphanumeric': 0.09577677224736049, 'fraction_numerical': 0.004524886877828055, 'mean_word_length': 3.2859450726979, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1930396', 'n_tokens_mistral': 787, 'n_tokens_neox': 743, 'n_words': 333}