ParamsTree
This is a little helper to turn strings like:
"default(id,user(group(division(name)),name)),post(id,title),comment(id,author,text(title,body))"
to:
{
"default" => {
"id" => {},
"user" => {
"group" => {
"division" => {
"name" => {}
},
"name" => {}
},
"post" => {
"id" => {},
"title" => {}
},
"comment" => {
"id" => {},
"author" => {},
"text" => {
"title" => {},
"body" => {}
}
}
}
}
}
Used for rabl-filters
Installation
Add my public key
gem cert --add <(curl -Ls https://raw.github.com/razum2um/params_tree/master/certs/razum2um.pem)
Add this line to your application's Gemfile:
gem 'params_tree'
And then execute:
$ bundle
Or install it yourself as:
$ gem install params_tree # without key
$ gem install params_tree -P HighSecurity # secure, with key added
Usage
ParamsTree::Parser.parse(string) # => nested Hash or nil if non-parseable
Contributing
Use rake generate
to get a .rb
parser, but avoid committing it.
- Fork it ( https://github.com/razum2um/params_tree/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request