Skip to content

Provides convenient scopes for finding duplicate records in ActiveRecord.

License

Notifications You must be signed in to change notification settings

TwilightCoders/doppel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Version      Build Status Code Climate Test Coverage Dependencies

Doppel

Doppel provides convenience scopes on your ActiveRecord Models for finding similar or exact records.

Compatible with ActiveRecord 4.0, 4.1, 4.2, 5.0, 5.1

Currently supports PostgreSQL and it's levenshtein function via the fuzzystrmatch extension.

Usage

Add this line to your application's Gemfile:

gem 'doppel'

And then execute:

$ bundle

Or install it yourself as:

$ gem install doppel

Application Code

Doppel is automatically available to your ActiveRecord Models

class User < Account
  # ...
end

User.create(name: "John Doe", email: '[email protected]')
User.create(name: "John Deer", email: '[email protected]')
User.create(name: "John Dear", email: '[email protected]')

users_with_similar_names = User.find_similar(:name, sensitivity: 1).to_a
=> [#<User:0x007fb42b093ad0
  id: 14,
  name: "John Deer",
  email: "[email protected]",
  created_at: Fri, 22 Dec 2017 23:04:41 UTC +00:00,
  updated_at: Fri, 22 Dec 2017 23:04:41 UTC +00:00>,
 #<User:0x007fb42b093940
  id: 15,
  name: "John Dear",
  email: "[email protected]",
  created_at: Fri, 22 Dec 2017 23:04:41 UTC +00:00,
  updated_at: Fri, 22 Dec 2017 23:04:41 UTC +00:00>]

users_with_similar_emails = User.find_similar(:email, sensitivity: 1).to_a
=> [#<User:0x007fb426786e00
  id: 13,
  name: "John Doe",
  email: "[email protected]",
  created_at: Fri, 22 Dec 2017 23:04:41 UTC +00:00,
  updated_at: Fri, 22 Dec 2017 23:04:41 UTC +00:00>,
 #<User:0x007fb426786bd0
  id: 14,
  name: "John Deer",
  email: "[email protected]",
  created_at: Fri, 22 Dec 2017 23:04:41 UTC +00:00,
  updated_at: Fri, 22 Dec 2017 23:04:41 UTC +00:00>]

Contributing

  1. Fork it ( https://github.com/TwilightCoders/active_record-mti/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

About

Provides convenient scopes for finding duplicate records in ActiveRecord.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages