FuzzyWhere
An ActiveRecord
implementation of SQLf.
At this moment it allows you to load fuzzy definitions from a yaml file and use
them as WHERE
conditions. More features from SQLf will be added to this gem in future iterations.
Installation
Add this line to your application's Gemfile:
gem 'fuzzy_where'
And then execute:
bundle
Or install it yourself as:
gem install fuzzy_where
Finally generate the configuration files:
rails generate fuzzy_where:config
Usage
Fuzzy predicates are stored in config/fuzzy_predicates.yml
. You can use a generator to populate this file.
rails generate fuzzy_where:predicate PREDICATE min core1 core2 max
Replace PREDICATE with the name you wish to use for you linguistic expression and set the values for the trapezoid function.
Example:
rails generate fuzzy_where:predicate young 10 15 20 25
Will produce:
# config/fuzzy_predicates.yml
young:
min: 10
core1: 15
core2: 20
max: 25
Then you can use your definitions as follows:
Person.fuzzy_where(age: :young)
Contributing
- Fork it ( https://github.com/koombea/fuzzy_where/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
License
MIT License. Copyright 2015-2016 Koombea. http://koombea.com