fuzzy_where 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/.yardopts +9 -0
- data/CHANGELOG.md +32 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/MIT-LICENSE +21 -0
- data/README.md +70 -0
- data/Rakefile +42 -0
- data/config/fuzzy_predicates.yml +5 -0
- data/config/initializers/fuzzy_where_config.rb +5 -0
- data/fuzzy_where.gemspec +31 -0
- data/gemfiles/active_record_40.gemfile +16 -0
- data/gemfiles/active_record_40.gemfile.lock +97 -0
- data/gemfiles/active_record_41.gemfile +15 -0
- data/gemfiles/active_record_41.gemfile.lock +95 -0
- data/gemfiles/active_record_42.gemfile +16 -0
- data/gemfiles/active_record_42.gemfile.lock +116 -0
- data/lib/fuzzy_where/active_record_model_extension.rb +23 -0
- data/lib/fuzzy_where/config.rb +68 -0
- data/lib/fuzzy_where/exceptions.rb +7 -0
- data/lib/fuzzy_where/fuzzy_derivation.rb +43 -0
- data/lib/fuzzy_where/fuzzy_relation_builder.rb +102 -0
- data/lib/fuzzy_where/predicate_membership_degree.rb +92 -0
- data/lib/fuzzy_where/railtie.rb +9 -0
- data/lib/fuzzy_where/version.rb +5 -0
- data/lib/fuzzy_where.rb +27 -0
- data/lib/generators/fuzzy_where/config_generator.rb +23 -0
- data/lib/generators/fuzzy_where/predicate_generator.rb +33 -0
- data/lib/generators/fuzzy_where/templates/fuzzy_predicates.yml +5 -0
- data/lib/generators/fuzzy_where/templates/fuzzy_where_config.rb +4 -0
- metadata +219 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: aa498361adfc7a10bed85361701c827d76dab857
         | 
| 4 | 
            +
              data.tar.gz: e02dbd3f7b9c3084a03285f55b83a9e4b0ab3927
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: 0e50389f16325c33d55c6c6ec848f91d32419198bee5a02f81ad104a344f1f08eb0b6c108f9deeddff8849a811d5d795429b84e9d32d1f1abad03714cb9207f6
         | 
| 7 | 
            +
              data.tar.gz: 98fd24be1cc9c2f230889c12a0423bb749695352e4436ac1745f8b790f6948e42a15191948256c1c359d452faf059052176996e00fa458aa1212e029ee7a3b54
         | 
    
        data/.gitignore
    ADDED
    
    
    
        data/.rspec
    ADDED
    
    
    
        data/.travis.yml
    ADDED
    
    
    
        data/.yardopts
    ADDED
    
    
    
        data/CHANGELOG.md
    ADDED
    
    | @@ -0,0 +1,32 @@ | |
| 1 | 
            +
            ### 0.5.0
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            * enhancements
         | 
| 4 | 
            +
                * add fuzzy predicate generator
         | 
| 5 | 
            +
                * add configuration for membership degree column name
         | 
| 6 | 
            +
                * improve classes design for ActiveRecord_Relation construction
         | 
| 7 | 
            +
                * code style improvements
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            ### 0.1.4 - 2015-06-21
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            * bug fixes
         | 
| 12 | 
            +
                * Fiz query derivation
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            ### 0.1.3 - 2015-06-09
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            * enhancements
         | 
| 17 | 
            +
                * rename methods to be concise with fuzzy set theory
         | 
| 18 | 
            +
            * bug fixes
         | 
| 19 | 
            +
                * fix membership degree calculation
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            ### 0.1.2 - 2015-06-09
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            * bug fixes
         | 
| 24 | 
            +
                * restore fuzzy where config file
         | 
| 25 | 
            +
             | 
| 26 | 
            +
            ### 0.1.1 - 2015-06-09
         | 
| 27 | 
            +
             | 
| 28 | 
            +
            Rename of full gem for clashing gem on RubyGems
         | 
| 29 | 
            +
             | 
| 30 | 
            +
            ### 0.1.0 - 2015-06-09
         | 
| 31 | 
            +
             | 
| 32 | 
            +
            Initial release of the gem, basic functionality for making SQLf conditions on where
         | 
    
        data/CODE_OF_CONDUCT.md
    ADDED
    
    | @@ -0,0 +1,13 @@ | |
| 1 | 
            +
            # Contributor Code of Conduct
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
         | 
    
        data/Gemfile
    ADDED
    
    
    
        data/MIT-LICENSE
    ADDED
    
    | @@ -0,0 +1,21 @@ | |
| 1 | 
            +
            The MIT License (MIT)
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Copyright (c) 2015 Koombea
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Permission is hereby granted, free of charge, to any person obtaining a copy
         | 
| 6 | 
            +
            of this software and associated documentation files (the "Software"), to deal
         | 
| 7 | 
            +
            in the Software without restriction, including without limitation the rights
         | 
| 8 | 
            +
            to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         | 
| 9 | 
            +
            copies of the Software, and to permit persons to whom the Software is
         | 
| 10 | 
            +
            furnished to do so, subject to the following conditions:
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            The above copyright notice and this permission notice shall be included in
         | 
| 13 | 
            +
            all copies or substantial portions of the Software.
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         | 
| 16 | 
            +
            IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         | 
| 17 | 
            +
            FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         | 
| 18 | 
            +
            AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         | 
| 19 | 
            +
            LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         | 
| 20 | 
            +
            OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
         | 
| 21 | 
            +
            THE SOFTWARE.
         | 
    
        data/README.md
    ADDED
    
    | @@ -0,0 +1,70 @@ | |
| 1 | 
            +
            # FuzzyWhere
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            An `ActiveRecord` implementation of [SQLf](http://en.wikipedia.org/wiki/SQLf).
         | 
| 4 | 
            +
            At this moment it allows you to load fuzzy definitions from a yaml file and use
         | 
| 5 | 
            +
            them as where conditions. More features from SQLf will be added to this gem.
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            ## Installation
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            Add this line to your application's Gemfile:
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            ```ruby
         | 
| 12 | 
            +
            gem 'fuzzy_where'
         | 
| 13 | 
            +
            ```
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            And then execute:
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                $ bundle
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            Or install it yourself as:
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                $ gem install fuzzy_where
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            Generate configuration files:
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                $ rails g fuzzy_where:config
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            ## Usage
         | 
| 28 | 
            +
             | 
| 29 | 
            +
            Fuzzy predicates are stored in `config/fuzzy_predicates.yml`. You can use a generator to populate the file.
         | 
| 30 | 
            +
             | 
| 31 | 
            +
            ```console
         | 
| 32 | 
            +
            rails g fuzzy_where:predicate PREDICATE min core1 core2 max
         | 
| 33 | 
            +
            ```
         | 
| 34 | 
            +
             | 
| 35 | 
            +
            Replace PREDICATE with the name you wish to use for you linguistic expression and set the values for the trapezoid function.
         | 
| 36 | 
            +
             | 
| 37 | 
            +
            ### Example:
         | 
| 38 | 
            +
             | 
| 39 | 
            +
            ```console
         | 
| 40 | 
            +
            rails g fuzzy_where:predicate young 10 15 20 25
         | 
| 41 | 
            +
            ```
         | 
| 42 | 
            +
             | 
| 43 | 
            +
            Will produce:
         | 
| 44 | 
            +
             | 
| 45 | 
            +
            ```yaml
         | 
| 46 | 
            +
            # config/fuzzy_predicates.yml
         | 
| 47 | 
            +
            young:
         | 
| 48 | 
            +
              min: 10
         | 
| 49 | 
            +
              core1: 15
         | 
| 50 | 
            +
              core2: 20
         | 
| 51 | 
            +
              max: 25
         | 
| 52 | 
            +
            ```
         | 
| 53 | 
            +
             | 
| 54 | 
            +
            Then you can use your definitions as follow:
         | 
| 55 | 
            +
             | 
| 56 | 
            +
            ```ruby
         | 
| 57 | 
            +
            Person.fuzzy_where(age: :young)
         | 
| 58 | 
            +
            ```
         | 
| 59 | 
            +
             | 
| 60 | 
            +
            ## Contributing
         | 
| 61 | 
            +
             | 
| 62 | 
            +
            1. Fork it ( https://github.com/koombea/fuzzy_where/fork )
         | 
| 63 | 
            +
            2. Create your feature branch (`git checkout -b my-new-feature`)
         | 
| 64 | 
            +
            3. Commit your changes (`git commit -am 'Add some feature'`)
         | 
| 65 | 
            +
            4. Push to the branch (`git push origin my-new-feature`)
         | 
| 66 | 
            +
            5. Create a new Pull Request
         | 
| 67 | 
            +
             | 
| 68 | 
            +
            ## License
         | 
| 69 | 
            +
             | 
| 70 | 
            +
            MIT License. Copyright 2015 Koombea. http://koombea.com
         | 
    
        data/Rakefile
    ADDED
    
    | @@ -0,0 +1,42 @@ | |
| 1 | 
            +
            # encoding: utf-8
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'bundler'
         | 
| 4 | 
            +
            Bundler::GemHelper.install_tasks
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            require 'rspec/core'
         | 
| 7 | 
            +
            require 'rspec/core/rake_task'
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            RSpec::Core::RakeTask.new(:spec) do |spec|
         | 
| 10 | 
            +
              spec.pattern = FileList['spec/**/*_spec.rb']
         | 
| 11 | 
            +
            end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            task default: 'spec:all'
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            namespace :spec do
         | 
| 16 | 
            +
              mappers = %w(
         | 
| 17 | 
            +
                active_record_40
         | 
| 18 | 
            +
                active_record_41
         | 
| 19 | 
            +
                active_record_42
         | 
| 20 | 
            +
              )
         | 
| 21 | 
            +
             | 
| 22 | 
            +
              mappers.each do |gemfile|
         | 
| 23 | 
            +
                desc "Run Tests against #{gemfile}"
         | 
| 24 | 
            +
                task gemfile do
         | 
| 25 | 
            +
                  sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle install --quiet"
         | 
| 26 | 
            +
                  sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle exec rake -t spec"
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
              end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
              desc 'Run Tests against all ORMs'
         | 
| 31 | 
            +
              task :all do
         | 
| 32 | 
            +
                mappers.each do |gemfile|
         | 
| 33 | 
            +
                  sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle install --quiet"
         | 
| 34 | 
            +
                  sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle exec rake spec"
         | 
| 35 | 
            +
                end
         | 
| 36 | 
            +
              end
         | 
| 37 | 
            +
            end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
            desc 'generate rdoc'
         | 
| 40 | 
            +
            task :rdoc do
         | 
| 41 | 
            +
              sh 'yardoc'
         | 
| 42 | 
            +
            end
         | 
    
        data/fuzzy_where.gemspec
    ADDED
    
    | @@ -0,0 +1,31 @@ | |
| 1 | 
            +
            # coding: utf-8
         | 
| 2 | 
            +
            lib = File.expand_path('../lib', __FILE__)
         | 
| 3 | 
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         | 
| 4 | 
            +
            require 'fuzzy_where/version'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            Gem::Specification.new do |spec|
         | 
| 7 | 
            +
              spec.name          = 'fuzzy_where'
         | 
| 8 | 
            +
              spec.version       = FuzzyWhere::VERSION
         | 
| 9 | 
            +
              spec.authors       = ['Gustavo Bazan']
         | 
| 10 | 
            +
              spec.email         = ['gustavo.bazan@koombea.com']
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              spec.summary       = 'SQLf'
         | 
| 13 | 
            +
              spec.description   = 'SQLf'
         | 
| 14 | 
            +
              spec.homepage      = 'https://github.com/koombea/fuzzy_where'
         | 
| 15 | 
            +
              spec.license       = 'MIT'
         | 
| 16 | 
            +
             | 
| 17 | 
            +
              spec.files         = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
         | 
| 18 | 
            +
              spec.bindir        = 'exe'
         | 
| 19 | 
            +
              spec.executables   = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
         | 
| 20 | 
            +
              spec.require_paths = ['lib']
         | 
| 21 | 
            +
             | 
| 22 | 
            +
              spec.add_dependency 'activesupport', '~> 4.0', '>= 4.0.0'
         | 
| 23 | 
            +
              spec.add_dependency 'actionpack', '~> 4.0', '>= 4.0.0'
         | 
| 24 | 
            +
              spec.add_dependency 'activerecord', '~> 4.0', '>= 4.0.0'
         | 
| 25 | 
            +
             | 
| 26 | 
            +
              spec.add_development_dependency 'bundler', '~> 1.8'
         | 
| 27 | 
            +
              spec.add_development_dependency 'rake', '~> 10.0'
         | 
| 28 | 
            +
              spec.add_development_dependency 'rspec', '~> 3.2', '>= 3.2.0'
         | 
| 29 | 
            +
              spec.add_development_dependency 'database_cleaner', '~> 1.4.1'
         | 
| 30 | 
            +
              spec.add_development_dependency 'yard', '~> 0.8.7', '>= 0.8.0'
         | 
| 31 | 
            +
            end
         | 
| @@ -0,0 +1,16 @@ | |
| 1 | 
            +
            source 'https://rubygems.org'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            gem 'activerecord', '~> 4.0.0', :require => 'active_record'
         | 
| 4 | 
            +
            gem 'rspec-rails', '~> 3.2.0'
         | 
| 5 | 
            +
            gem 'generator_spec', '~>0.9.0'
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            platforms :ruby do
         | 
| 8 | 
            +
              if RUBY_VERSION > "2.1.0"
         | 
| 9 | 
            +
                gem 'sqlite3'
         | 
| 10 | 
            +
                gem 'test-unit'
         | 
| 11 | 
            +
              else
         | 
| 12 | 
            +
                gem 'sqlite3', '1.3.8'
         | 
| 13 | 
            +
              end
         | 
| 14 | 
            +
            end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            gemspec :path => '../'
         | 
| @@ -0,0 +1,97 @@ | |
| 1 | 
            +
            PATH
         | 
| 2 | 
            +
              remote: ../
         | 
| 3 | 
            +
              specs:
         | 
| 4 | 
            +
                fuzzy_where (0.1.4)
         | 
| 5 | 
            +
                  actionpack (~> 4.0, >= 4.0.0)
         | 
| 6 | 
            +
                  activerecord (~> 4.0, >= 4.0.0)
         | 
| 7 | 
            +
                  activesupport (~> 4.0, >= 4.0.0)
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            GEM
         | 
| 10 | 
            +
              remote: https://rubygems.org/
         | 
| 11 | 
            +
              specs:
         | 
| 12 | 
            +
                actionpack (4.0.13)
         | 
| 13 | 
            +
                  activesupport (= 4.0.13)
         | 
| 14 | 
            +
                  builder (~> 3.1.0)
         | 
| 15 | 
            +
                  erubis (~> 2.7.0)
         | 
| 16 | 
            +
                  rack (~> 1.5.2)
         | 
| 17 | 
            +
                  rack-test (~> 0.6.2)
         | 
| 18 | 
            +
                activemodel (4.0.13)
         | 
| 19 | 
            +
                  activesupport (= 4.0.13)
         | 
| 20 | 
            +
                  builder (~> 3.1.0)
         | 
| 21 | 
            +
                activerecord (4.0.13)
         | 
| 22 | 
            +
                  activemodel (= 4.0.13)
         | 
| 23 | 
            +
                  activerecord-deprecated_finders (~> 1.0.2)
         | 
| 24 | 
            +
                  activesupport (= 4.0.13)
         | 
| 25 | 
            +
                  arel (~> 4.0.0)
         | 
| 26 | 
            +
                activerecord-deprecated_finders (1.0.4)
         | 
| 27 | 
            +
                activesupport (4.0.13)
         | 
| 28 | 
            +
                  i18n (~> 0.6, >= 0.6.9)
         | 
| 29 | 
            +
                  minitest (~> 4.2)
         | 
| 30 | 
            +
                  multi_json (~> 1.3)
         | 
| 31 | 
            +
                  thread_safe (~> 0.1)
         | 
| 32 | 
            +
                  tzinfo (~> 0.3.37)
         | 
| 33 | 
            +
                arel (4.0.2)
         | 
| 34 | 
            +
                builder (3.1.4)
         | 
| 35 | 
            +
                database_cleaner (1.4.1)
         | 
| 36 | 
            +
                diff-lcs (1.2.5)
         | 
| 37 | 
            +
                erubis (2.7.0)
         | 
| 38 | 
            +
                generator_spec (0.9.3)
         | 
| 39 | 
            +
                  activesupport (>= 3.0.0)
         | 
| 40 | 
            +
                  railties (>= 3.0.0)
         | 
| 41 | 
            +
                i18n (0.7.0)
         | 
| 42 | 
            +
                minitest (4.7.5)
         | 
| 43 | 
            +
                multi_json (1.11.0)
         | 
| 44 | 
            +
                power_assert (0.2.3)
         | 
| 45 | 
            +
                rack (1.5.5)
         | 
| 46 | 
            +
                rack-test (0.6.3)
         | 
| 47 | 
            +
                  rack (>= 1.0)
         | 
| 48 | 
            +
                railties (4.0.13)
         | 
| 49 | 
            +
                  actionpack (= 4.0.13)
         | 
| 50 | 
            +
                  activesupport (= 4.0.13)
         | 
| 51 | 
            +
                  rake (>= 0.8.7)
         | 
| 52 | 
            +
                  thor (>= 0.18.1, < 2.0)
         | 
| 53 | 
            +
                rake (10.4.2)
         | 
| 54 | 
            +
                rspec (3.2.0)
         | 
| 55 | 
            +
                  rspec-core (~> 3.2.0)
         | 
| 56 | 
            +
                  rspec-expectations (~> 3.2.0)
         | 
| 57 | 
            +
                  rspec-mocks (~> 3.2.0)
         | 
| 58 | 
            +
                rspec-core (3.2.3)
         | 
| 59 | 
            +
                  rspec-support (~> 3.2.0)
         | 
| 60 | 
            +
                rspec-expectations (3.2.1)
         | 
| 61 | 
            +
                  diff-lcs (>= 1.2.0, < 2.0)
         | 
| 62 | 
            +
                  rspec-support (~> 3.2.0)
         | 
| 63 | 
            +
                rspec-mocks (3.2.1)
         | 
| 64 | 
            +
                  diff-lcs (>= 1.2.0, < 2.0)
         | 
| 65 | 
            +
                  rspec-support (~> 3.2.0)
         | 
| 66 | 
            +
                rspec-rails (3.2.3)
         | 
| 67 | 
            +
                  actionpack (>= 3.0, < 4.3)
         | 
| 68 | 
            +
                  activesupport (>= 3.0, < 4.3)
         | 
| 69 | 
            +
                  railties (>= 3.0, < 4.3)
         | 
| 70 | 
            +
                  rspec-core (~> 3.2.0)
         | 
| 71 | 
            +
                  rspec-expectations (~> 3.2.0)
         | 
| 72 | 
            +
                  rspec-mocks (~> 3.2.0)
         | 
| 73 | 
            +
                  rspec-support (~> 3.2.0)
         | 
| 74 | 
            +
                rspec-support (3.2.2)
         | 
| 75 | 
            +
                sqlite3 (1.3.10)
         | 
| 76 | 
            +
                test-unit (3.1.2)
         | 
| 77 | 
            +
                  power_assert
         | 
| 78 | 
            +
                thor (0.19.1)
         | 
| 79 | 
            +
                thread_safe (0.3.5)
         | 
| 80 | 
            +
                tzinfo (0.3.44)
         | 
| 81 | 
            +
                yard (0.8.7.6)
         | 
| 82 | 
            +
             | 
| 83 | 
            +
            PLATFORMS
         | 
| 84 | 
            +
              ruby
         | 
| 85 | 
            +
             | 
| 86 | 
            +
            DEPENDENCIES
         | 
| 87 | 
            +
              activerecord (~> 4.0.0)
         | 
| 88 | 
            +
              bundler (~> 1.8)
         | 
| 89 | 
            +
              database_cleaner (~> 1.4.1)
         | 
| 90 | 
            +
              fuzzy_where!
         | 
| 91 | 
            +
              generator_spec (~> 0.9.0)
         | 
| 92 | 
            +
              rake (~> 10.0)
         | 
| 93 | 
            +
              rspec (~> 3.2, >= 3.2.0)
         | 
| 94 | 
            +
              rspec-rails (~> 3.2.0)
         | 
| 95 | 
            +
              sqlite3
         | 
| 96 | 
            +
              test-unit
         | 
| 97 | 
            +
              yard (~> 0.8.7, >= 0.8.0)
         | 
| @@ -0,0 +1,15 @@ | |
| 1 | 
            +
            source 'https://rubygems.org'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            gem 'activerecord', '~> 4.1.0', :require => 'active_record'
         | 
| 4 | 
            +
            gem 'rspec-rails', '~> 3.2.0'
         | 
| 5 | 
            +
            gem 'generator_spec', '~>0.9.0'
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            platforms :ruby do
         | 
| 8 | 
            +
              if RUBY_VERSION > "2.1.0"
         | 
| 9 | 
            +
                gem 'sqlite3'
         | 
| 10 | 
            +
              else
         | 
| 11 | 
            +
                gem 'sqlite3', '1.3.8'
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
            end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            gemspec :path => '../'
         | 
| @@ -0,0 +1,95 @@ | |
| 1 | 
            +
            PATH
         | 
| 2 | 
            +
              remote: ../
         | 
| 3 | 
            +
              specs:
         | 
| 4 | 
            +
                fuzzy_where (0.1.4)
         | 
| 5 | 
            +
                  actionpack (~> 4.0, >= 4.0.0)
         | 
| 6 | 
            +
                  activerecord (~> 4.0, >= 4.0.0)
         | 
| 7 | 
            +
                  activesupport (~> 4.0, >= 4.0.0)
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            GEM
         | 
| 10 | 
            +
              remote: https://rubygems.org/
         | 
| 11 | 
            +
              specs:
         | 
| 12 | 
            +
                actionpack (4.1.10)
         | 
| 13 | 
            +
                  actionview (= 4.1.10)
         | 
| 14 | 
            +
                  activesupport (= 4.1.10)
         | 
| 15 | 
            +
                  rack (~> 1.5.2)
         | 
| 16 | 
            +
                  rack-test (~> 0.6.2)
         | 
| 17 | 
            +
                actionview (4.1.10)
         | 
| 18 | 
            +
                  activesupport (= 4.1.10)
         | 
| 19 | 
            +
                  builder (~> 3.1)
         | 
| 20 | 
            +
                  erubis (~> 2.7.0)
         | 
| 21 | 
            +
                activemodel (4.1.10)
         | 
| 22 | 
            +
                  activesupport (= 4.1.10)
         | 
| 23 | 
            +
                  builder (~> 3.1)
         | 
| 24 | 
            +
                activerecord (4.1.10)
         | 
| 25 | 
            +
                  activemodel (= 4.1.10)
         | 
| 26 | 
            +
                  activesupport (= 4.1.10)
         | 
| 27 | 
            +
                  arel (~> 5.0.0)
         | 
| 28 | 
            +
                activesupport (4.1.10)
         | 
| 29 | 
            +
                  i18n (~> 0.6, >= 0.6.9)
         | 
| 30 | 
            +
                  json (~> 1.7, >= 1.7.7)
         | 
| 31 | 
            +
                  minitest (~> 5.1)
         | 
| 32 | 
            +
                  thread_safe (~> 0.1)
         | 
| 33 | 
            +
                  tzinfo (~> 1.1)
         | 
| 34 | 
            +
                arel (5.0.1.20140414130214)
         | 
| 35 | 
            +
                builder (3.2.2)
         | 
| 36 | 
            +
                database_cleaner (1.4.1)
         | 
| 37 | 
            +
                diff-lcs (1.2.5)
         | 
| 38 | 
            +
                erubis (2.7.0)
         | 
| 39 | 
            +
                generator_spec (0.9.3)
         | 
| 40 | 
            +
                  activesupport (>= 3.0.0)
         | 
| 41 | 
            +
                  railties (>= 3.0.0)
         | 
| 42 | 
            +
                i18n (0.7.0)
         | 
| 43 | 
            +
                json (1.8.3)
         | 
| 44 | 
            +
                minitest (5.7.0)
         | 
| 45 | 
            +
                rack (1.5.5)
         | 
| 46 | 
            +
                rack-test (0.6.3)
         | 
| 47 | 
            +
                  rack (>= 1.0)
         | 
| 48 | 
            +
                railties (4.1.10)
         | 
| 49 | 
            +
                  actionpack (= 4.1.10)
         | 
| 50 | 
            +
                  activesupport (= 4.1.10)
         | 
| 51 | 
            +
                  rake (>= 0.8.7)
         | 
| 52 | 
            +
                  thor (>= 0.18.1, < 2.0)
         | 
| 53 | 
            +
                rake (10.4.2)
         | 
| 54 | 
            +
                rspec (3.2.0)
         | 
| 55 | 
            +
                  rspec-core (~> 3.2.0)
         | 
| 56 | 
            +
                  rspec-expectations (~> 3.2.0)
         | 
| 57 | 
            +
                  rspec-mocks (~> 3.2.0)
         | 
| 58 | 
            +
                rspec-core (3.2.3)
         | 
| 59 | 
            +
                  rspec-support (~> 3.2.0)
         | 
| 60 | 
            +
                rspec-expectations (3.2.1)
         | 
| 61 | 
            +
                  diff-lcs (>= 1.2.0, < 2.0)
         | 
| 62 | 
            +
                  rspec-support (~> 3.2.0)
         | 
| 63 | 
            +
                rspec-mocks (3.2.1)
         | 
| 64 | 
            +
                  diff-lcs (>= 1.2.0, < 2.0)
         | 
| 65 | 
            +
                  rspec-support (~> 3.2.0)
         | 
| 66 | 
            +
                rspec-rails (3.2.3)
         | 
| 67 | 
            +
                  actionpack (>= 3.0, < 4.3)
         | 
| 68 | 
            +
                  activesupport (>= 3.0, < 4.3)
         | 
| 69 | 
            +
                  railties (>= 3.0, < 4.3)
         | 
| 70 | 
            +
                  rspec-core (~> 3.2.0)
         | 
| 71 | 
            +
                  rspec-expectations (~> 3.2.0)
         | 
| 72 | 
            +
                  rspec-mocks (~> 3.2.0)
         | 
| 73 | 
            +
                  rspec-support (~> 3.2.0)
         | 
| 74 | 
            +
                rspec-support (3.2.2)
         | 
| 75 | 
            +
                sqlite3 (1.3.10)
         | 
| 76 | 
            +
                thor (0.19.1)
         | 
| 77 | 
            +
                thread_safe (0.3.5)
         | 
| 78 | 
            +
                tzinfo (1.2.2)
         | 
| 79 | 
            +
                  thread_safe (~> 0.1)
         | 
| 80 | 
            +
                yard (0.8.7.6)
         | 
| 81 | 
            +
             | 
| 82 | 
            +
            PLATFORMS
         | 
| 83 | 
            +
              ruby
         | 
| 84 | 
            +
             | 
| 85 | 
            +
            DEPENDENCIES
         | 
| 86 | 
            +
              activerecord (~> 4.1.0)
         | 
| 87 | 
            +
              bundler (~> 1.8)
         | 
| 88 | 
            +
              database_cleaner (~> 1.4.1)
         | 
| 89 | 
            +
              fuzzy_where!
         | 
| 90 | 
            +
              generator_spec (~> 0.9.0)
         | 
| 91 | 
            +
              rake (~> 10.0)
         | 
| 92 | 
            +
              rspec (~> 3.2, >= 3.2.0)
         | 
| 93 | 
            +
              rspec-rails (~> 3.2.0)
         | 
| 94 | 
            +
              sqlite3
         | 
| 95 | 
            +
              yard (~> 0.8.7, >= 0.8.0)
         | 
| @@ -0,0 +1,16 @@ | |
| 1 | 
            +
            source 'https://rubygems.org'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            gem 'activerecord', '~> 4.2.0', :require => 'active_record'
         | 
| 4 | 
            +
            gem 'test-unit'
         | 
| 5 | 
            +
            gem 'rspec-rails', '~> 3.2.0'
         | 
| 6 | 
            +
            gem 'generator_spec', '~>0.9.0'
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            platforms :ruby do
         | 
| 9 | 
            +
              if RUBY_VERSION > "2.1.0"
         | 
| 10 | 
            +
                gem 'sqlite3'
         | 
| 11 | 
            +
              else
         | 
| 12 | 
            +
                gem 'sqlite3', '1.3.8'
         | 
| 13 | 
            +
              end
         | 
| 14 | 
            +
            end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            gemspec :path => '../'
         | 
| @@ -0,0 +1,116 @@ | |
| 1 | 
            +
            PATH
         | 
| 2 | 
            +
              remote: ../
         | 
| 3 | 
            +
              specs:
         | 
| 4 | 
            +
                fuzzy_where (0.1.4)
         | 
| 5 | 
            +
                  actionpack (~> 4.0, >= 4.0.0)
         | 
| 6 | 
            +
                  activerecord (~> 4.0, >= 4.0.0)
         | 
| 7 | 
            +
                  activesupport (~> 4.0, >= 4.0.0)
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            GEM
         | 
| 10 | 
            +
              remote: https://rubygems.org/
         | 
| 11 | 
            +
              specs:
         | 
| 12 | 
            +
                actionpack (4.2.3)
         | 
| 13 | 
            +
                  actionview (= 4.2.3)
         | 
| 14 | 
            +
                  activesupport (= 4.2.3)
         | 
| 15 | 
            +
                  rack (~> 1.6)
         | 
| 16 | 
            +
                  rack-test (~> 0.6.2)
         | 
| 17 | 
            +
                  rails-dom-testing (~> 1.0, >= 1.0.5)
         | 
| 18 | 
            +
                  rails-html-sanitizer (~> 1.0, >= 1.0.2)
         | 
| 19 | 
            +
                actionview (4.2.3)
         | 
| 20 | 
            +
                  activesupport (= 4.2.3)
         | 
| 21 | 
            +
                  builder (~> 3.1)
         | 
| 22 | 
            +
                  erubis (~> 2.7.0)
         | 
| 23 | 
            +
                  rails-dom-testing (~> 1.0, >= 1.0.5)
         | 
| 24 | 
            +
                  rails-html-sanitizer (~> 1.0, >= 1.0.2)
         | 
| 25 | 
            +
                activemodel (4.2.3)
         | 
| 26 | 
            +
                  activesupport (= 4.2.3)
         | 
| 27 | 
            +
                  builder (~> 3.1)
         | 
| 28 | 
            +
                activerecord (4.2.3)
         | 
| 29 | 
            +
                  activemodel (= 4.2.3)
         | 
| 30 | 
            +
                  activesupport (= 4.2.3)
         | 
| 31 | 
            +
                  arel (~> 6.0)
         | 
| 32 | 
            +
                activesupport (4.2.3)
         | 
| 33 | 
            +
                  i18n (~> 0.7)
         | 
| 34 | 
            +
                  json (~> 1.7, >= 1.7.7)
         | 
| 35 | 
            +
                  minitest (~> 5.1)
         | 
| 36 | 
            +
                  thread_safe (~> 0.3, >= 0.3.4)
         | 
| 37 | 
            +
                  tzinfo (~> 1.1)
         | 
| 38 | 
            +
                arel (6.0.0)
         | 
| 39 | 
            +
                builder (3.2.2)
         | 
| 40 | 
            +
                database_cleaner (1.4.1)
         | 
| 41 | 
            +
                diff-lcs (1.2.5)
         | 
| 42 | 
            +
                erubis (2.7.0)
         | 
| 43 | 
            +
                generator_spec (0.9.3)
         | 
| 44 | 
            +
                  activesupport (>= 3.0.0)
         | 
| 45 | 
            +
                  railties (>= 3.0.0)
         | 
| 46 | 
            +
                i18n (0.7.0)
         | 
| 47 | 
            +
                json (1.8.3)
         | 
| 48 | 
            +
                loofah (2.0.2)
         | 
| 49 | 
            +
                  nokogiri (>= 1.5.9)
         | 
| 50 | 
            +
                mini_portile (0.6.2)
         | 
| 51 | 
            +
                minitest (5.7.0)
         | 
| 52 | 
            +
                nokogiri (1.6.6.2)
         | 
| 53 | 
            +
                  mini_portile (~> 0.6.0)
         | 
| 54 | 
            +
                power_assert (0.2.3)
         | 
| 55 | 
            +
                rack (1.6.4)
         | 
| 56 | 
            +
                rack-test (0.6.3)
         | 
| 57 | 
            +
                  rack (>= 1.0)
         | 
| 58 | 
            +
                rails-deprecated_sanitizer (1.0.3)
         | 
| 59 | 
            +
                  activesupport (>= 4.2.0.alpha)
         | 
| 60 | 
            +
                rails-dom-testing (1.0.6)
         | 
| 61 | 
            +
                  activesupport (>= 4.2.0.beta, < 5.0)
         | 
| 62 | 
            +
                  nokogiri (~> 1.6.0)
         | 
| 63 | 
            +
                  rails-deprecated_sanitizer (>= 1.0.1)
         | 
| 64 | 
            +
                rails-html-sanitizer (1.0.2)
         | 
| 65 | 
            +
                  loofah (~> 2.0)
         | 
| 66 | 
            +
                railties (4.2.3)
         | 
| 67 | 
            +
                  actionpack (= 4.2.3)
         | 
| 68 | 
            +
                  activesupport (= 4.2.3)
         | 
| 69 | 
            +
                  rake (>= 0.8.7)
         | 
| 70 | 
            +
                  thor (>= 0.18.1, < 2.0)
         | 
| 71 | 
            +
                rake (10.4.2)
         | 
| 72 | 
            +
                rspec (3.2.0)
         | 
| 73 | 
            +
                  rspec-core (~> 3.2.0)
         | 
| 74 | 
            +
                  rspec-expectations (~> 3.2.0)
         | 
| 75 | 
            +
                  rspec-mocks (~> 3.2.0)
         | 
| 76 | 
            +
                rspec-core (3.2.3)
         | 
| 77 | 
            +
                  rspec-support (~> 3.2.0)
         | 
| 78 | 
            +
                rspec-expectations (3.2.1)
         | 
| 79 | 
            +
                  diff-lcs (>= 1.2.0, < 2.0)
         | 
| 80 | 
            +
                  rspec-support (~> 3.2.0)
         | 
| 81 | 
            +
                rspec-mocks (3.2.1)
         | 
| 82 | 
            +
                  diff-lcs (>= 1.2.0, < 2.0)
         | 
| 83 | 
            +
                  rspec-support (~> 3.2.0)
         | 
| 84 | 
            +
                rspec-rails (3.2.3)
         | 
| 85 | 
            +
                  actionpack (>= 3.0, < 4.3)
         | 
| 86 | 
            +
                  activesupport (>= 3.0, < 4.3)
         | 
| 87 | 
            +
                  railties (>= 3.0, < 4.3)
         | 
| 88 | 
            +
                  rspec-core (~> 3.2.0)
         | 
| 89 | 
            +
                  rspec-expectations (~> 3.2.0)
         | 
| 90 | 
            +
                  rspec-mocks (~> 3.2.0)
         | 
| 91 | 
            +
                  rspec-support (~> 3.2.0)
         | 
| 92 | 
            +
                rspec-support (3.2.2)
         | 
| 93 | 
            +
                sqlite3 (1.3.10)
         | 
| 94 | 
            +
                test-unit (3.1.2)
         | 
| 95 | 
            +
                  power_assert
         | 
| 96 | 
            +
                thor (0.19.1)
         | 
| 97 | 
            +
                thread_safe (0.3.5)
         | 
| 98 | 
            +
                tzinfo (1.2.2)
         | 
| 99 | 
            +
                  thread_safe (~> 0.1)
         | 
| 100 | 
            +
                yard (0.8.7.6)
         | 
| 101 | 
            +
             | 
| 102 | 
            +
            PLATFORMS
         | 
| 103 | 
            +
              ruby
         | 
| 104 | 
            +
             | 
| 105 | 
            +
            DEPENDENCIES
         | 
| 106 | 
            +
              activerecord (~> 4.2.0)
         | 
| 107 | 
            +
              bundler (~> 1.8)
         | 
| 108 | 
            +
              database_cleaner (~> 1.4.1)
         | 
| 109 | 
            +
              fuzzy_where!
         | 
| 110 | 
            +
              generator_spec (~> 0.9.0)
         | 
| 111 | 
            +
              rake (~> 10.0)
         | 
| 112 | 
            +
              rspec (~> 3.2, >= 3.2.0)
         | 
| 113 | 
            +
              rspec-rails (~> 3.2.0)
         | 
| 114 | 
            +
              sqlite3
         | 
| 115 | 
            +
              test-unit
         | 
| 116 | 
            +
              yard (~> 0.8.7, >= 0.8.0)
         | 
| @@ -0,0 +1,23 @@ | |
| 1 | 
            +
            require 'fuzzy_where/fuzzy_relation_builder'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            # SQLf implementation for ActiveRecord
         | 
| 4 | 
            +
            module FuzzyWhere
         | 
| 5 | 
            +
              # Methods to extend ActiveRecord
         | 
| 6 | 
            +
              module ActiveRecordModelExtension
         | 
| 7 | 
            +
                extend ActiveSupport::Concern
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                included do
         | 
| 10 | 
            +
                  class << self
         | 
| 11 | 
            +
                    define_method(FuzzyWhere.config.where_method_name) do |conditions|
         | 
| 12 | 
            +
                      conditions ||= {}
         | 
| 13 | 
            +
                      unless conditions.respond_to?(:key)
         | 
| 14 | 
            +
                        fail ArgumentError,
         | 
| 15 | 
            +
                             "conditions must be a Hash, got #{conditions.inspect}"
         | 
| 16 | 
            +
                      end
         | 
| 17 | 
            +
                      FuzzyRelationBuilder.new(quoted_table_name, where(nil), conditions)
         | 
| 18 | 
            +
                        .build
         | 
| 19 | 
            +
                    end
         | 
| 20 | 
            +
                  end
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
            end
         | 
| @@ -0,0 +1,68 @@ | |
| 1 | 
            +
            require 'yaml'
         | 
| 2 | 
            +
            require 'active_support/core_ext/hash'
         | 
| 3 | 
            +
            require 'active_support/hash_with_indifferent_access'
         | 
| 4 | 
            +
            require 'active_support/configurable'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            # SQLf implementation for ActiveRecord
         | 
| 7 | 
            +
            module FuzzyWhere
         | 
| 8 | 
            +
              # Configures global settings for FuzzyWhere
         | 
| 9 | 
            +
              #   FuzzyWhere.configure do |config|
         | 
| 10 | 
            +
              #     config.where_method_name = :fuzzy_where
         | 
| 11 | 
            +
              #   end
         | 
| 12 | 
            +
              def self.configure(&_block)
         | 
| 13 | 
            +
                yield @config ||= FuzzyWhere::Configuration.new
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              # Global settings for FuzzyWhere
         | 
| 17 | 
            +
              def self.config
         | 
| 18 | 
            +
                @config
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              # {FuzzyWhere} Configuration class
         | 
| 22 | 
            +
              class Configuration #:nodoc:
         | 
| 23 | 
            +
                include ActiveSupport::Configurable
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                # @!attribute [rw] where_method_name
         | 
| 26 | 
            +
                #   @return [String] search method name definition
         | 
| 27 | 
            +
                config_accessor :where_method_name
         | 
| 28 | 
            +
                # @!attribute [rw] membership_degree_column_name
         | 
| 29 | 
            +
                #   @return [String] membership degree column name definition
         | 
| 30 | 
            +
                config_accessor :membership_degree_column_name
         | 
| 31 | 
            +
                # @!attribute [rw] predicates_file
         | 
| 32 | 
            +
                #   configuration file location
         | 
| 33 | 
            +
                config_accessor :predicates_file
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                # Return a fuzzy predicate definition
         | 
| 36 | 
            +
                # @param key [Key] predicate name
         | 
| 37 | 
            +
                # @return [Hash] fuzzy predicate definition
         | 
| 38 | 
            +
                def fuzzy_predicate(key)
         | 
| 39 | 
            +
                  @fuzzy_predicates = load_yml(predicates_file)
         | 
| 40 | 
            +
                  @fuzzy_predicates["#{key}"]
         | 
| 41 | 
            +
                end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                private
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                # Load YAML file
         | 
| 46 | 
            +
                # @param path [Object] predicates definition location
         | 
| 47 | 
            +
                # @return [Hash] fuzzy predicate definitions
         | 
| 48 | 
            +
                def load_yml(path)
         | 
| 49 | 
            +
                  fail ConfigError, 'The configuration file is not defined.' unless path
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                  path = path.is_a?(Pathname) ? path : Pathname.new(path)
         | 
| 52 | 
            +
             | 
| 53 | 
            +
                  if !path.exist?
         | 
| 54 | 
            +
                    fail ConfigError, "The configuration file #{@path} was not found."
         | 
| 55 | 
            +
                  elsif !path.file?
         | 
| 56 | 
            +
                    fail ConfigError, "The configuration file #{@path} is not a file."
         | 
| 57 | 
            +
                  elsif !path.readable?
         | 
| 58 | 
            +
                    fail ConfigError, "The configuration file #{@path} is not readable."
         | 
| 59 | 
            +
                  end
         | 
| 60 | 
            +
                  HashWithIndifferentAccess.new(YAML.load_file(path))
         | 
| 61 | 
            +
                end
         | 
| 62 | 
            +
              end
         | 
| 63 | 
            +
             | 
| 64 | 
            +
              configure do |config|
         | 
| 65 | 
            +
                config.where_method_name = :fuzzy_where
         | 
| 66 | 
            +
                config.membership_degree_column_name = :membership_degree
         | 
| 67 | 
            +
              end
         | 
| 68 | 
            +
            end
         | 
| @@ -0,0 +1,43 @@ | |
| 1 | 
            +
            # SQLf implementation for ActiveRecord
         | 
| 2 | 
            +
            module FuzzyWhere
         | 
| 3 | 
            +
              # Class to take a column and a fuzzy predicate and return the equivalent
         | 
| 4 | 
            +
              # standard query
         | 
| 5 | 
            +
              class FuzzyDerivation
         | 
| 6 | 
            +
                # @!attribute [r] query
         | 
| 7 | 
            +
                #   @return [ActiveRecord_Relation] the current standard query
         | 
| 8 | 
            +
                attr_reader :query
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                # New FuzzyDerivation intance
         | 
| 11 | 
            +
                # @param query [ActiveRecord_Relation] query tu append
         | 
| 12 | 
            +
                # @param table [String] table name
         | 
| 13 | 
            +
                # @param column [String] column name
         | 
| 14 | 
            +
                # @param fuzzy_predicate [Hash] fuzzy predicate
         | 
| 15 | 
            +
                def initialize(query, table, column, fuzzy_predicate)
         | 
| 16 | 
            +
                  @table = table
         | 
| 17 | 
            +
                  @query = query
         | 
| 18 | 
            +
                  @column = column
         | 
| 19 | 
            +
                  @fuzzy_predicate = fuzzy_predicate
         | 
| 20 | 
            +
                end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                # Take instance attributtes and return a derivated query
         | 
| 23 | 
            +
                # @return [ActiveRecord_Relation] the current standard query
         | 
| 24 | 
            +
                def derivative_condition
         | 
| 25 | 
            +
                  min = @fuzzy_predicate[:min]
         | 
| 26 | 
            +
                  max = @fuzzy_predicate[:max]
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                  increasing_conditions(min) if min && min != 'infinite'.freeze
         | 
| 29 | 
            +
                  decreasing_conditions(max) if max && max != 'infinite'.freeze
         | 
| 30 | 
            +
                  @query
         | 
| 31 | 
            +
                end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                private
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                def increasing_conditions(min)
         | 
| 36 | 
            +
                  @query = @query.where("#{@table}.#{@column} > ?", min)
         | 
| 37 | 
            +
                end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                def decreasing_conditions(max)
         | 
| 40 | 
            +
                  @query = @query.where("#{@table}.#{@column} < ?", max)
         | 
| 41 | 
            +
                end
         | 
| 42 | 
            +
              end
         | 
| 43 | 
            +
            end
         | 
| @@ -0,0 +1,102 @@ | |
| 1 | 
            +
            require 'fuzzy_where/fuzzy_derivation'
         | 
| 2 | 
            +
            require 'fuzzy_where/predicate_membership_degree'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            # SQLf implementation for ActiveRecord
         | 
| 5 | 
            +
            module FuzzyWhere
         | 
| 6 | 
            +
              # Class to build and {ActiveRecord_Relation} based on fuzzy conditions
         | 
| 7 | 
            +
              class FuzzyRelationBuilder
         | 
| 8 | 
            +
                class << self
         | 
| 9 | 
            +
                  # Is sqlite3 validation
         | 
| 10 | 
            +
                  def sqlite3?
         | 
| 11 | 
            +
                    active_record_adapter == 'sqlite3'.freeze
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                  private
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                  # ActiveRecord adapter
         | 
| 17 | 
            +
                  def active_record_adapter
         | 
| 18 | 
            +
                    ActiveRecord::Base.connection.instance_values['config'][:adapter]
         | 
| 19 | 
            +
                  end
         | 
| 20 | 
            +
                end
         | 
| 21 | 
            +
                # @!attribute [r] relation
         | 
| 22 | 
            +
                #   @return [ActiveRecord_Relation] the current standard query
         | 
| 23 | 
            +
                attr_reader :relation
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                # New FuzzyRelationBuilder intance
         | 
| 26 | 
            +
                # @param table [String] table name
         | 
| 27 | 
            +
                # @param relation [ActiveRecord_Relation] query tu append
         | 
| 28 | 
            +
                # @param conditions [Hash] fuzzy conditions
         | 
| 29 | 
            +
                def initialize(table, relation, conditions)
         | 
| 30 | 
            +
                  @table = table
         | 
| 31 | 
            +
                  @conditions = conditions
         | 
| 32 | 
            +
                  @relation = relation
         | 
| 33 | 
            +
                  @membership_degrees = []
         | 
| 34 | 
            +
                end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                # Build an ActiveRecord relation based on fuzzy conditions
         | 
| 37 | 
            +
                #
         | 
| 38 | 
            +
                # @return [ActiveRecord_Relation] the final standard query
         | 
| 39 | 
            +
                def build
         | 
| 40 | 
            +
                  process_conditions
         | 
| 41 | 
            +
                  add_membership_column
         | 
| 42 | 
            +
                  order_by_membership_degree
         | 
| 43 | 
            +
                end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                private
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                def process_conditions
         | 
| 48 | 
            +
                  @conditions.each do |column, predicate|
         | 
| 49 | 
            +
                    pred_def = load_fuzzy_predicate_definition(predicate)
         | 
| 50 | 
            +
                    @relation = derivate_condition(column, pred_def)
         | 
| 51 | 
            +
                    membership_degree_function(column, pred_def)
         | 
| 52 | 
            +
                  end
         | 
| 53 | 
            +
                  @relation
         | 
| 54 | 
            +
                end
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                def load_fuzzy_predicate_definition(predicate)
         | 
| 57 | 
            +
                  pred_def = FuzzyWhere.config.fuzzy_predicate(predicate)
         | 
| 58 | 
            +
                  fail FuzzyError, "couldn't find fuzzy definition" unless pred_def
         | 
| 59 | 
            +
                  pred_def
         | 
| 60 | 
            +
                end
         | 
| 61 | 
            +
             | 
| 62 | 
            +
                def derivate_condition(column, pred_def)
         | 
| 63 | 
            +
                  FuzzyDerivation.new(@relation, @table, column, pred_def)
         | 
| 64 | 
            +
                    .derivative_condition
         | 
| 65 | 
            +
                end
         | 
| 66 | 
            +
             | 
| 67 | 
            +
                def membership_degree_function(column, pred_def)
         | 
| 68 | 
            +
                  membership_degree = PredicateMembershipDegree.new(@table,
         | 
| 69 | 
            +
                                                                    column,
         | 
| 70 | 
            +
                                                                    pred_def)
         | 
| 71 | 
            +
                  @membership_degrees << membership_degree.membership_function
         | 
| 72 | 
            +
                end
         | 
| 73 | 
            +
             | 
| 74 | 
            +
                def add_membership_column
         | 
| 75 | 
            +
                  name = FuzzyWhere.config.membership_degree_column_name
         | 
| 76 | 
            +
                  @relation = @relation
         | 
| 77 | 
            +
                              .select("#{@table}.*, (#{membership_degree}) AS #{name}")
         | 
| 78 | 
            +
                end
         | 
| 79 | 
            +
             | 
| 80 | 
            +
                def membership_degree
         | 
| 81 | 
            +
                  if @membership_degrees.size > 1
         | 
| 82 | 
            +
                    min_membership_degree
         | 
| 83 | 
            +
                  else
         | 
| 84 | 
            +
                    @membership_degrees.first
         | 
| 85 | 
            +
                  end
         | 
| 86 | 
            +
                end
         | 
| 87 | 
            +
             | 
| 88 | 
            +
                # Use apropiate SQL method for minimun value
         | 
| 89 | 
            +
                def min_membership_degree
         | 
| 90 | 
            +
                  if FuzzyRelationBuilder.sqlite3?
         | 
| 91 | 
            +
                    "MIN(#{@membership_degrees.join(',')})"
         | 
| 92 | 
            +
                  else
         | 
| 93 | 
            +
                    "LEAST(#{@membership_degrees.join(',')})"
         | 
| 94 | 
            +
                  end
         | 
| 95 | 
            +
                end
         | 
| 96 | 
            +
             | 
| 97 | 
            +
                def order_by_membership_degree
         | 
| 98 | 
            +
                  name = FuzzyWhere.config.membership_degree_column_name
         | 
| 99 | 
            +
                  @relation.order("#{name} DESC")
         | 
| 100 | 
            +
                end
         | 
| 101 | 
            +
              end
         | 
| 102 | 
            +
            end
         | 
| @@ -0,0 +1,92 @@ | |
| 1 | 
            +
            # SQLf implementation for ActiveRecord
         | 
| 2 | 
            +
            module FuzzyWhere
         | 
| 3 | 
            +
              # Class to determine the membership degree calculation
         | 
| 4 | 
            +
              # for a given column and add the select conditions
         | 
| 5 | 
            +
              class PredicateMembershipDegree
         | 
| 6 | 
            +
                # @!attribute [r] calculation
         | 
| 7 | 
            +
                #   @return [String] calculation query to be used for the given column
         | 
| 8 | 
            +
                attr_reader :calculation
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                # New MembershipDegree intance
         | 
| 11 | 
            +
                # @param table [String] table name
         | 
| 12 | 
            +
                # @param column [String] column name
         | 
| 13 | 
            +
                # @param fuzzy_predicate [Hash] fuzzy predicate
         | 
| 14 | 
            +
                def initialize(table, column, fuzzy_predicate)
         | 
| 15 | 
            +
                  @table = table
         | 
| 16 | 
            +
                  @column = column
         | 
| 17 | 
            +
                  @fuzzy_predicate = fuzzy_predicate
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                # Take instance attributtes and return a calculations for them
         | 
| 21 | 
            +
                # Based on fuzzzy set trapezium function
         | 
| 22 | 
            +
                # @return [String] the calculation query to be used for the column
         | 
| 23 | 
            +
                def membership_function
         | 
| 24 | 
            +
                  min = @fuzzy_predicate[:min]
         | 
| 25 | 
            +
                  max = @fuzzy_predicate[:max]
         | 
| 26 | 
            +
                  @calculation = if !min || min == 'infinite'.freeze
         | 
| 27 | 
            +
                                   decreasing
         | 
| 28 | 
            +
                                 elsif !max || max == 'infinite'.freeze
         | 
| 29 | 
            +
                                   increasing
         | 
| 30 | 
            +
                                 else
         | 
| 31 | 
            +
                                   unimodal
         | 
| 32 | 
            +
                                 end
         | 
| 33 | 
            +
                  @calculation
         | 
| 34 | 
            +
                end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                private
         | 
| 37 | 
            +
             | 
| 38 | 
            +
                # Decreasing function calculation
         | 
| 39 | 
            +
                # @return [String] condition representation for membership calculation
         | 
| 40 | 
            +
                def decreasing
         | 
| 41 | 
            +
                  "CASE WHEN #{less_than(:core2, true)} THEN 1.0 "\
         | 
| 42 | 
            +
                  "WHEN #{greater_than(:core2)} AND #{less_than(:max)} THEN "\
         | 
| 43 | 
            +
                  "(#{right_border_formula}) "\
         | 
| 44 | 
            +
                  'ELSE 0 END'
         | 
| 45 | 
            +
                end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                # Incresing function calculation
         | 
| 48 | 
            +
                # @return [String] condition representation for membership calculation
         | 
| 49 | 
            +
                def increasing
         | 
| 50 | 
            +
                  "CASE WHEN #{greater_than(:core1, true)} THEN 1.0 "\
         | 
| 51 | 
            +
                  "WHEN #{greater_than(:min)} AND #{less_than(:core1)} THEN "\
         | 
| 52 | 
            +
                  "(#{left_border_formula}) "\
         | 
| 53 | 
            +
                  'ELSE 0 END'
         | 
| 54 | 
            +
                end
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                # Unimodal function calculation
         | 
| 57 | 
            +
                # @return [String] condition representation for membership calculation
         | 
| 58 | 
            +
                def unimodal
         | 
| 59 | 
            +
                  'CASE WHEN '\
         | 
| 60 | 
            +
                  "#{greater_than(:core1, true)} AND #{less_than(:core2, true)} THEN 1.0 "\
         | 
| 61 | 
            +
                  "WHEN #{greater_than(:min)} AND #{less_than(:core1)} THEN "\
         | 
| 62 | 
            +
                  "(#{left_border_formula})"\
         | 
| 63 | 
            +
                  "WHEN #{greater_than(:core2)} AND #{less_than(:max)} THEN "\
         | 
| 64 | 
            +
                  "(#{right_border_formula}) "\
         | 
| 65 | 
            +
                  'ELSE 0 END'
         | 
| 66 | 
            +
                end
         | 
| 67 | 
            +
             | 
| 68 | 
            +
                def greater_than(x, equal = false)
         | 
| 69 | 
            +
                  comparator = equal ? '>='.freeze : '>'.freeze
         | 
| 70 | 
            +
                  comparator_condition(x, comparator)
         | 
| 71 | 
            +
                end
         | 
| 72 | 
            +
             | 
| 73 | 
            +
                def less_than(x, equal = false)
         | 
| 74 | 
            +
                  comparator = equal ? '<='.freeze : '<'.freeze
         | 
| 75 | 
            +
                  comparator_condition(x, comparator)
         | 
| 76 | 
            +
                end
         | 
| 77 | 
            +
             | 
| 78 | 
            +
                def comparator_condition(x, comparator)
         | 
| 79 | 
            +
                  "#{@table}.#{@column} #{comparator} #{@fuzzy_predicate[x].to_f}"
         | 
| 80 | 
            +
                end
         | 
| 81 | 
            +
             | 
| 82 | 
            +
                def right_border_formula
         | 
| 83 | 
            +
                  "#{@fuzzy_predicate[:max].to_f} - #{@table}.#{@column})/"\
         | 
| 84 | 
            +
                  "(#{@fuzzy_predicate[:max].to_f} - #{@fuzzy_predicate[:core2].to_f}"
         | 
| 85 | 
            +
                end
         | 
| 86 | 
            +
             | 
| 87 | 
            +
                def left_border_formula
         | 
| 88 | 
            +
                  "#{@table}.#{@column} - #{@fuzzy_predicate[:min].to_f})/"\
         | 
| 89 | 
            +
                  "(#{@fuzzy_predicate[:core1].to_f} - #{@fuzzy_predicate[:min].to_f}"
         | 
| 90 | 
            +
                end
         | 
| 91 | 
            +
              end
         | 
| 92 | 
            +
            end
         | 
| @@ -0,0 +1,9 @@ | |
| 1 | 
            +
            # SQLf implementation for ActiveRecord
         | 
| 2 | 
            +
            module FuzzyWhere
         | 
| 3 | 
            +
              class Railtie < ::Rails::Railtie #:nodoc:
         | 
| 4 | 
            +
                initializer 'fuzzy_where' do |_app|
         | 
| 5 | 
            +
                  # Include module on rails load
         | 
| 6 | 
            +
                  ::ActiveRecord::Base.send :include, FuzzyWhere::ActiveRecordModelExtension
         | 
| 7 | 
            +
                end
         | 
| 8 | 
            +
              end
         | 
| 9 | 
            +
            end
         | 
    
        data/lib/fuzzy_where.rb
    ADDED
    
    | @@ -0,0 +1,27 @@ | |
| 1 | 
            +
            require 'fuzzy_where/version'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            # SQLf implementation for ActiveRecord
         | 
| 4 | 
            +
            module FuzzyWhere
         | 
| 5 | 
            +
            end
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            # load Rails/Railtie
         | 
| 8 | 
            +
            begin
         | 
| 9 | 
            +
              require 'rails'
         | 
| 10 | 
            +
            rescue LoadError
         | 
| 11 | 
            +
              # do nothing
         | 
| 12 | 
            +
            end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            $stderr.puts <<-EOC unless defined?(Rails)
         | 
| 15 | 
            +
            warning: no framework detected.
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            Your Gemfile might not be configured properly.
         | 
| 18 | 
            +
            ---- e.g. ----
         | 
| 19 | 
            +
            Rails:
         | 
| 20 | 
            +
              gem 'fuzzy_where'
         | 
| 21 | 
            +
            EOC
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            # load FuzzyWhere components
         | 
| 24 | 
            +
            require 'fuzzy_where/config'
         | 
| 25 | 
            +
            require 'fuzzy_where/exceptions'
         | 
| 26 | 
            +
            require 'fuzzy_where/active_record_model_extension'
         | 
| 27 | 
            +
            require 'fuzzy_where/railtie' if defined?(::Rails)
         | 
| @@ -0,0 +1,23 @@ | |
| 1 | 
            +
            # SQLf implementation for ActiveRecord
         | 
| 2 | 
            +
            module FuzzyWhere
         | 
| 3 | 
            +
              module Generators #:nodoc
         | 
| 4 | 
            +
                # Generate gem configuration files
         | 
| 5 | 
            +
                class ConfigGenerator < Rails::Generators::Base
         | 
| 6 | 
            +
                  source_root File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                  desc <<DESC
         | 
| 9 | 
            +
            Description:
         | 
| 10 | 
            +
                Copies FuzzyWhere configuration file to your application's initializer directory.
         | 
| 11 | 
            +
            DESC
         | 
| 12 | 
            +
                  # Create FuzzyWhere config file
         | 
| 13 | 
            +
                  def copy_config_file
         | 
| 14 | 
            +
                    template 'fuzzy_where_config.rb', 'config/initializers/fuzzy_where_config.rb'
         | 
| 15 | 
            +
                  end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                  # Create fuzzy predicates definitions file
         | 
| 18 | 
            +
                  def copy_predicates_file
         | 
| 19 | 
            +
                    template 'fuzzy_predicates.yml', 'config/fuzzy_predicates.yml'
         | 
| 20 | 
            +
                  end
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
            end
         | 
| @@ -0,0 +1,33 @@ | |
| 1 | 
            +
            # SQLf implementation for ActiveRecord
         | 
| 2 | 
            +
            module FuzzyWhere
         | 
| 3 | 
            +
              module Generators #:nodoc
         | 
| 4 | 
            +
                # Generate a new fuzzy predicate
         | 
| 5 | 
            +
                class PredicateGenerator < Rails::Generators::NamedBase
         | 
| 6 | 
            +
                  argument :attributes, type: :array, default: [], banner: '1 4 infinite infinite'
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                  desc <<DESC
         | 
| 9 | 
            +
            Description:
         | 
| 10 | 
            +
                Create a new fuzzy predicate.
         | 
| 11 | 
            +
            DESC
         | 
| 12 | 
            +
                  # Add Fuzzy predicate
         | 
| 13 | 
            +
                  def add_fuzzy_predicate
         | 
| 14 | 
            +
                    return if attributes.empty?
         | 
| 15 | 
            +
                    append_to_file 'config/fuzzy_predicates.yml', predicate_content(name, attributes)
         | 
| 16 | 
            +
                  end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                  private
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                  # Content for fuzzy predicate definition
         | 
| 21 | 
            +
                  def predicate_content(name, attributes)
         | 
| 22 | 
            +
                    buffer = <<-CONTENT
         | 
| 23 | 
            +
            #{name}:
         | 
| 24 | 
            +
              min:   #{attributes[0].name}
         | 
| 25 | 
            +
              core1: #{attributes[1].name}
         | 
| 26 | 
            +
              core2: #{attributes[2].name}
         | 
| 27 | 
            +
              max:   #{attributes[3].name}
         | 
| 28 | 
            +
            CONTENT
         | 
| 29 | 
            +
                    buffer
         | 
| 30 | 
            +
                  end
         | 
| 31 | 
            +
                end
         | 
| 32 | 
            +
              end
         | 
| 33 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,219 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: fuzzy_where
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.5.0
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Gustavo Bazan
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: exe
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2015-07-05 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              name: activesupport
         | 
| 15 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 | 
            +
                requirements:
         | 
| 17 | 
            +
                - - "~>"
         | 
| 18 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                    version: '4.0'
         | 
| 20 | 
            +
                - - ">="
         | 
| 21 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 22 | 
            +
                    version: 4.0.0
         | 
| 23 | 
            +
              type: :runtime
         | 
| 24 | 
            +
              prerelease: false
         | 
| 25 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 26 | 
            +
                requirements:
         | 
| 27 | 
            +
                - - "~>"
         | 
| 28 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 29 | 
            +
                    version: '4.0'
         | 
| 30 | 
            +
                - - ">="
         | 
| 31 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 32 | 
            +
                    version: 4.0.0
         | 
| 33 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 34 | 
            +
              name: actionpack
         | 
| 35 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 36 | 
            +
                requirements:
         | 
| 37 | 
            +
                - - "~>"
         | 
| 38 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 39 | 
            +
                    version: '4.0'
         | 
| 40 | 
            +
                - - ">="
         | 
| 41 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 42 | 
            +
                    version: 4.0.0
         | 
| 43 | 
            +
              type: :runtime
         | 
| 44 | 
            +
              prerelease: false
         | 
| 45 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 46 | 
            +
                requirements:
         | 
| 47 | 
            +
                - - "~>"
         | 
| 48 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 49 | 
            +
                    version: '4.0'
         | 
| 50 | 
            +
                - - ">="
         | 
| 51 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 52 | 
            +
                    version: 4.0.0
         | 
| 53 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 54 | 
            +
              name: activerecord
         | 
| 55 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 56 | 
            +
                requirements:
         | 
| 57 | 
            +
                - - "~>"
         | 
| 58 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 59 | 
            +
                    version: '4.0'
         | 
| 60 | 
            +
                - - ">="
         | 
| 61 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 62 | 
            +
                    version: 4.0.0
         | 
| 63 | 
            +
              type: :runtime
         | 
| 64 | 
            +
              prerelease: false
         | 
| 65 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 66 | 
            +
                requirements:
         | 
| 67 | 
            +
                - - "~>"
         | 
| 68 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 69 | 
            +
                    version: '4.0'
         | 
| 70 | 
            +
                - - ">="
         | 
| 71 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 72 | 
            +
                    version: 4.0.0
         | 
| 73 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 74 | 
            +
              name: bundler
         | 
| 75 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 76 | 
            +
                requirements:
         | 
| 77 | 
            +
                - - "~>"
         | 
| 78 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 79 | 
            +
                    version: '1.8'
         | 
| 80 | 
            +
              type: :development
         | 
| 81 | 
            +
              prerelease: false
         | 
| 82 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 83 | 
            +
                requirements:
         | 
| 84 | 
            +
                - - "~>"
         | 
| 85 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 86 | 
            +
                    version: '1.8'
         | 
| 87 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 88 | 
            +
              name: rake
         | 
| 89 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 90 | 
            +
                requirements:
         | 
| 91 | 
            +
                - - "~>"
         | 
| 92 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 93 | 
            +
                    version: '10.0'
         | 
| 94 | 
            +
              type: :development
         | 
| 95 | 
            +
              prerelease: false
         | 
| 96 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 97 | 
            +
                requirements:
         | 
| 98 | 
            +
                - - "~>"
         | 
| 99 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 100 | 
            +
                    version: '10.0'
         | 
| 101 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 102 | 
            +
              name: rspec
         | 
| 103 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 104 | 
            +
                requirements:
         | 
| 105 | 
            +
                - - "~>"
         | 
| 106 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 107 | 
            +
                    version: '3.2'
         | 
| 108 | 
            +
                - - ">="
         | 
| 109 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 110 | 
            +
                    version: 3.2.0
         | 
| 111 | 
            +
              type: :development
         | 
| 112 | 
            +
              prerelease: false
         | 
| 113 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 114 | 
            +
                requirements:
         | 
| 115 | 
            +
                - - "~>"
         | 
| 116 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 117 | 
            +
                    version: '3.2'
         | 
| 118 | 
            +
                - - ">="
         | 
| 119 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 120 | 
            +
                    version: 3.2.0
         | 
| 121 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 122 | 
            +
              name: database_cleaner
         | 
| 123 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 124 | 
            +
                requirements:
         | 
| 125 | 
            +
                - - "~>"
         | 
| 126 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 127 | 
            +
                    version: 1.4.1
         | 
| 128 | 
            +
              type: :development
         | 
| 129 | 
            +
              prerelease: false
         | 
| 130 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 131 | 
            +
                requirements:
         | 
| 132 | 
            +
                - - "~>"
         | 
| 133 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 134 | 
            +
                    version: 1.4.1
         | 
| 135 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 136 | 
            +
              name: yard
         | 
| 137 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 138 | 
            +
                requirements:
         | 
| 139 | 
            +
                - - "~>"
         | 
| 140 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 141 | 
            +
                    version: 0.8.7
         | 
| 142 | 
            +
                - - ">="
         | 
| 143 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 144 | 
            +
                    version: 0.8.0
         | 
| 145 | 
            +
              type: :development
         | 
| 146 | 
            +
              prerelease: false
         | 
| 147 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 148 | 
            +
                requirements:
         | 
| 149 | 
            +
                - - "~>"
         | 
| 150 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 151 | 
            +
                    version: 0.8.7
         | 
| 152 | 
            +
                - - ">="
         | 
| 153 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 154 | 
            +
                    version: 0.8.0
         | 
| 155 | 
            +
            description: SQLf
         | 
| 156 | 
            +
            email:
         | 
| 157 | 
            +
            - gustavo.bazan@koombea.com
         | 
| 158 | 
            +
            executables: []
         | 
| 159 | 
            +
            extensions: []
         | 
| 160 | 
            +
            extra_rdoc_files: []
         | 
| 161 | 
            +
            files:
         | 
| 162 | 
            +
            - ".gitignore"
         | 
| 163 | 
            +
            - ".rspec"
         | 
| 164 | 
            +
            - ".travis.yml"
         | 
| 165 | 
            +
            - ".yardopts"
         | 
| 166 | 
            +
            - CHANGELOG.md
         | 
| 167 | 
            +
            - CODE_OF_CONDUCT.md
         | 
| 168 | 
            +
            - Gemfile
         | 
| 169 | 
            +
            - MIT-LICENSE
         | 
| 170 | 
            +
            - README.md
         | 
| 171 | 
            +
            - Rakefile
         | 
| 172 | 
            +
            - config/fuzzy_predicates.yml
         | 
| 173 | 
            +
            - config/initializers/fuzzy_where_config.rb
         | 
| 174 | 
            +
            - fuzzy_where.gemspec
         | 
| 175 | 
            +
            - gemfiles/active_record_40.gemfile
         | 
| 176 | 
            +
            - gemfiles/active_record_40.gemfile.lock
         | 
| 177 | 
            +
            - gemfiles/active_record_41.gemfile
         | 
| 178 | 
            +
            - gemfiles/active_record_41.gemfile.lock
         | 
| 179 | 
            +
            - gemfiles/active_record_42.gemfile
         | 
| 180 | 
            +
            - gemfiles/active_record_42.gemfile.lock
         | 
| 181 | 
            +
            - lib/fuzzy_where.rb
         | 
| 182 | 
            +
            - lib/fuzzy_where/active_record_model_extension.rb
         | 
| 183 | 
            +
            - lib/fuzzy_where/config.rb
         | 
| 184 | 
            +
            - lib/fuzzy_where/exceptions.rb
         | 
| 185 | 
            +
            - lib/fuzzy_where/fuzzy_derivation.rb
         | 
| 186 | 
            +
            - lib/fuzzy_where/fuzzy_relation_builder.rb
         | 
| 187 | 
            +
            - lib/fuzzy_where/predicate_membership_degree.rb
         | 
| 188 | 
            +
            - lib/fuzzy_where/railtie.rb
         | 
| 189 | 
            +
            - lib/fuzzy_where/version.rb
         | 
| 190 | 
            +
            - lib/generators/fuzzy_where/config_generator.rb
         | 
| 191 | 
            +
            - lib/generators/fuzzy_where/predicate_generator.rb
         | 
| 192 | 
            +
            - lib/generators/fuzzy_where/templates/fuzzy_predicates.yml
         | 
| 193 | 
            +
            - lib/generators/fuzzy_where/templates/fuzzy_where_config.rb
         | 
| 194 | 
            +
            homepage: https://github.com/koombea/fuzzy_where
         | 
| 195 | 
            +
            licenses:
         | 
| 196 | 
            +
            - MIT
         | 
| 197 | 
            +
            metadata: {}
         | 
| 198 | 
            +
            post_install_message: 
         | 
| 199 | 
            +
            rdoc_options: []
         | 
| 200 | 
            +
            require_paths:
         | 
| 201 | 
            +
            - lib
         | 
| 202 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 203 | 
            +
              requirements:
         | 
| 204 | 
            +
              - - ">="
         | 
| 205 | 
            +
                - !ruby/object:Gem::Version
         | 
| 206 | 
            +
                  version: '0'
         | 
| 207 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 208 | 
            +
              requirements:
         | 
| 209 | 
            +
              - - ">="
         | 
| 210 | 
            +
                - !ruby/object:Gem::Version
         | 
| 211 | 
            +
                  version: '0'
         | 
| 212 | 
            +
            requirements: []
         | 
| 213 | 
            +
            rubyforge_project: 
         | 
| 214 | 
            +
            rubygems_version: 2.4.6
         | 
| 215 | 
            +
            signing_key: 
         | 
| 216 | 
            +
            specification_version: 4
         | 
| 217 | 
            +
            summary: SQLf
         | 
| 218 | 
            +
            test_files: []
         | 
| 219 | 
            +
            has_rdoc: 
         |