fuzzily 0.2.1 → 0.2.2

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.
data/.travis.yml CHANGED
@@ -7,3 +7,6 @@ gemfile:
7
7
  - gemfiles/rails30.gemfile
8
8
  - gemfiles/rails31.gemfile
9
9
  - gemfiles/rails32.gemfile
10
+ - gemfiles/rails32_pg.gemfile
11
+ before_script:
12
+ - psql -c 'create database fuzzily_test;' -U postgres
data/Appraisals CHANGED
@@ -13,3 +13,7 @@ end
13
13
  appraise "rails32" do
14
14
  gem "activerecord", "~> 3.2.0"
15
15
  end
16
+
17
+ appraise "rails32-pg" do
18
+ gem "activerecord", "~> 3.2.0"
19
+ end
data/Gemfile.lock CHANGED
@@ -1,41 +1,42 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fuzzily (0.2.1)
4
+ fuzzily (0.2.2)
5
5
  activerecord (>= 2.3.17)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activemodel (3.2.12)
11
- activesupport (= 3.2.12)
10
+ activemodel (3.2.13)
11
+ activesupport (= 3.2.13)
12
12
  builder (~> 3.0.0)
13
- activerecord (3.2.12)
14
- activemodel (= 3.2.12)
15
- activesupport (= 3.2.12)
13
+ activerecord (3.2.13)
14
+ activemodel (= 3.2.13)
15
+ activesupport (= 3.2.13)
16
16
  arel (~> 3.0.2)
17
17
  tzinfo (~> 0.3.29)
18
- activesupport (3.2.12)
19
- i18n (~> 0.6)
18
+ activesupport (3.2.13)
19
+ i18n (= 0.6.1)
20
20
  multi_json (~> 1.0)
21
- appraisal (0.5.1)
21
+ appraisal (0.5.2)
22
22
  bundler
23
23
  rake
24
24
  arel (3.0.2)
25
25
  builder (3.0.4)
26
26
  coderay (1.0.9)
27
- diff-lcs (1.2.1)
28
- i18n (0.6.4)
27
+ diff-lcs (1.2.4)
28
+ i18n (0.6.1)
29
29
  method_source (0.8.1)
30
- multi_json (1.6.1)
30
+ multi_json (1.7.2)
31
31
  mysql2 (0.3.11)
32
- pry (0.9.12)
32
+ pg (0.15.1)
33
+ pry (0.9.12.1)
33
34
  coderay (~> 1.0.5)
34
35
  method_source (~> 0.8)
35
36
  slop (~> 3.4)
36
37
  pry-nav (0.2.3)
37
38
  pry (~> 0.9.10)
38
- rake (10.0.3)
39
+ rake (10.0.4)
39
40
  rspec (2.13.0)
40
41
  rspec-core (~> 2.13.0)
41
42
  rspec-expectations (~> 2.13.0)
@@ -43,7 +44,7 @@ GEM
43
44
  rspec-core (2.13.1)
44
45
  rspec-expectations (2.13.0)
45
46
  diff-lcs (>= 1.1.3, < 2.0)
46
- rspec-mocks (2.13.0)
47
+ rspec-mocks (2.13.1)
47
48
  slop (3.4.4)
48
49
  sqlite3 (1.3.7)
49
50
  tzinfo (0.3.37)
@@ -55,6 +56,7 @@ DEPENDENCIES
55
56
  appraisal
56
57
  fuzzily!
57
58
  mysql2
59
+ pg
58
60
  pry
59
61
  pry-nav
60
62
  rake
data/README.md CHANGED
@@ -1,13 +1,25 @@
1
- # Fuzzily
1
+ # Fuzzily - fuzzy string matching for ActiveRecord
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/fuzzily.png)](http://badge.fury.io/rb/fuzzily)
3
4
  [![Build Status](https://travis-ci.org/mezis/fuzzily.png?branch=master)](https://travis-ci.org/mezis/fuzzily)
4
5
  [![Dependency Status](https://gemnasium.com/mezis/fuzzily.png)](https://gemnasium.com/mezis/fuzzily)
6
+ [![Code Climate](https://codeclimate.com/github/mezis/fuzzily.png)](https://codeclimate.com/github/mezis/fuzzily)
5
7
 
6
- A fast, [trigram](http://en.wikipedia.org/wiki/N-gram)-based, database-backed [fuzzy](http://en.wikipedia.org/wiki/Approximate_string_matching) string search/match engine for Rails.
8
+ > Show me photos of **Marakech** !
9
+ >
10
+ > Here aresome photos of **Marrakesh**, Morroco.
11
+ > Did you mean **Martanesh**, Albania, **Marakkanam**, India, or **Marasheshty**, Romania?
7
12
 
13
+ Blurrily finds misspelled, prefix, or partial needles in a haystack of
14
+ strings. It's a fast, [trigram](http://en.wikipedia.org/wiki/N-gram)-based, database-backed [fuzzy](http://en.wikipedia.org/wiki/Approximate_string_matching) string search/match engine for Rails.
8
15
  Loosely inspired from an [old blog post](http://unirec.blogspot.co.uk/2007/12/live-fuzzy-search-using-n-grams-in.html).
9
16
 
10
- Compatible with ActiveRecord 2.3, 3.0, 3.1, 3.2.
17
+ Works with ActiveRecord 2.3, 3.0, 3.1, 3.2 on various Rubies.
18
+
19
+ If your dateset is big, if you need yet more speed, or do not use ActiveRecord,
20
+ check out [blurrily](http://github.com/mezis/blurrily), another gem (backed with a C extension)
21
+ with the same intent.
22
+
11
23
 
12
24
  ## Installation
13
25
 
@@ -100,7 +112,7 @@ the `owner_type` and `fuzzy_field` columns of the `trigrams` table from
100
112
  MySQL and pgSQL.
101
113
 
102
114
  This is not the default in the gem as ActiveRecord does not suport `ENUM`
103
- columns in any version
115
+ columns in any version.
104
116
 
105
117
 
106
118
  ## License
data/fuzzily.gemspec CHANGED
@@ -20,6 +20,7 @@ Gem::Specification.new do |gem|
20
20
  gem.add_development_dependency 'pry'
21
21
  gem.add_development_dependency 'pry-nav'
22
22
  gem.add_development_dependency 'sqlite3'
23
+ gem.add_development_dependency 'pg'
23
24
  gem.add_development_dependency 'mysql2'
24
25
 
25
26
  gem.files = `git ls-files`.split($/)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/mezis/Dropbox/Development/fuzzily
3
3
  specs:
4
- fuzzily (0.1.0)
4
+ fuzzily (0.2.2)
5
5
  activerecord (>= 2.3.17)
6
6
 
7
7
  GEM
@@ -16,6 +16,8 @@ GEM
16
16
  coderay (1.0.9)
17
17
  diff-lcs (1.1.3)
18
18
  method_source (0.8.1)
19
+ mysql2 (0.3.11)
20
+ pg (0.14.1)
19
21
  pry (0.9.12)
20
22
  coderay (~> 1.0.5)
21
23
  method_source (~> 0.8)
@@ -41,6 +43,8 @@ DEPENDENCIES
41
43
  activerecord (~> 2.3.0)
42
44
  appraisal
43
45
  fuzzily!
46
+ mysql2
47
+ pg
44
48
  pry
45
49
  pry-nav
46
50
  rake
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/mezis/Dropbox/Development/fuzzily
3
3
  specs:
4
- fuzzily (0.1.0)
4
+ fuzzily (0.2.2)
5
5
  activerecord (>= 2.3.17)
6
6
 
7
7
  GEM
@@ -26,6 +26,8 @@ GEM
26
26
  diff-lcs (1.1.3)
27
27
  i18n (0.5.0)
28
28
  method_source (0.8.1)
29
+ mysql2 (0.3.11)
30
+ pg (0.15.1)
29
31
  pry (0.9.12)
30
32
  coderay (~> 1.0.5)
31
33
  method_source (~> 0.8)
@@ -52,6 +54,8 @@ DEPENDENCIES
52
54
  activerecord (~> 3.0.0)
53
55
  appraisal
54
56
  fuzzily!
57
+ mysql2
58
+ pg
55
59
  pry
56
60
  pry-nav
57
61
  rake
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/mezis/Dropbox/Development/fuzzily
3
3
  specs:
4
- fuzzily (0.1.0)
4
+ fuzzily (0.2.2)
5
5
  activerecord (>= 2.3.17)
6
6
 
7
7
  GEM
@@ -28,6 +28,8 @@ GEM
28
28
  i18n (0.6.1)
29
29
  method_source (0.8.1)
30
30
  multi_json (1.6.1)
31
+ mysql2 (0.3.11)
32
+ pg (0.15.1)
31
33
  pry (0.9.12)
32
34
  coderay (~> 1.0.5)
33
35
  method_source (~> 0.8)
@@ -54,6 +56,8 @@ DEPENDENCIES
54
56
  activerecord (~> 3.1.0)
55
57
  appraisal
56
58
  fuzzily!
59
+ mysql2
60
+ pg
57
61
  pry
58
62
  pry-nav
59
63
  rake
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/mezis/Dropbox/Development/fuzzily
3
3
  specs:
4
- fuzzily (0.1.0)
4
+ fuzzily (0.2.2)
5
5
  activerecord (>= 2.3.17)
6
6
 
7
7
  GEM
@@ -28,6 +28,8 @@ GEM
28
28
  i18n (0.6.1)
29
29
  method_source (0.8.1)
30
30
  multi_json (1.6.1)
31
+ mysql2 (0.3.11)
32
+ pg (0.15.1)
31
33
  pry (0.9.12)
32
34
  coderay (~> 1.0.5)
33
35
  method_source (~> 0.8)
@@ -54,6 +56,8 @@ DEPENDENCIES
54
56
  activerecord (~> 3.2.0)
55
57
  appraisal
56
58
  fuzzily!
59
+ mysql2
60
+ pg
57
61
  pry
58
62
  pry-nav
59
63
  rake
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 3.2.0"
6
+
7
+ gemspec :path=>"../"
8
+
9
+ ENV['FUZZILY_USE_PG'] = 'YES'
@@ -0,0 +1,65 @@
1
+ PATH
2
+ remote: /Users/mezis/Dropbox/Development/fuzzily
3
+ specs:
4
+ fuzzily (0.2.2)
5
+ activerecord (>= 2.3.17)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ activemodel (3.2.12)
11
+ activesupport (= 3.2.12)
12
+ builder (~> 3.0.0)
13
+ activerecord (3.2.12)
14
+ activemodel (= 3.2.12)
15
+ activesupport (= 3.2.12)
16
+ arel (~> 3.0.2)
17
+ tzinfo (~> 0.3.29)
18
+ activesupport (3.2.12)
19
+ i18n (~> 0.6)
20
+ multi_json (~> 1.0)
21
+ appraisal (0.5.1)
22
+ bundler
23
+ rake
24
+ arel (3.0.2)
25
+ builder (3.0.4)
26
+ coderay (1.0.9)
27
+ diff-lcs (1.2.2)
28
+ i18n (0.6.4)
29
+ method_source (0.8.1)
30
+ multi_json (1.7.2)
31
+ mysql2 (0.3.11)
32
+ pg (0.15.1)
33
+ pry (0.9.12)
34
+ coderay (~> 1.0.5)
35
+ method_source (~> 0.8)
36
+ slop (~> 3.4)
37
+ pry-nav (0.2.3)
38
+ pry (~> 0.9.10)
39
+ rake (10.0.4)
40
+ rspec (2.13.0)
41
+ rspec-core (~> 2.13.0)
42
+ rspec-expectations (~> 2.13.0)
43
+ rspec-mocks (~> 2.13.0)
44
+ rspec-core (2.13.1)
45
+ rspec-expectations (2.13.0)
46
+ diff-lcs (>= 1.1.3, < 2.0)
47
+ rspec-mocks (2.13.0)
48
+ slop (3.4.4)
49
+ sqlite3 (1.3.7)
50
+ tzinfo (0.3.37)
51
+
52
+ PLATFORMS
53
+ ruby
54
+
55
+ DEPENDENCIES
56
+ activerecord (~> 3.2.0)
57
+ appraisal
58
+ fuzzily!
59
+ mysql2
60
+ pg
61
+ pry
62
+ pry-nav
63
+ rake
64
+ rspec
65
+ sqlite3
data/lib/fuzzily/model.rb CHANGED
@@ -38,8 +38,8 @@ module Fuzzily
38
38
  def matches_for(text)
39
39
  trigrams = Fuzzily::String.new(text).trigrams
40
40
  self.
41
- scoped(:select => 'owner_id, owner_type, count(*) AS matches, score').
42
- scoped(:group => :owner_id).
41
+ scoped(:select => 'owner_id, owner_type, count(*) AS matches, MAX(score) AS score').
42
+ scoped(:group => 'owner_id, owner_type').
43
43
  scoped(:order => 'matches DESC, score ASC').
44
44
  with_trigram(trigrams).
45
45
  map(&:owner)
@@ -1,3 +1,3 @@
1
1
  module Fuzzily
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -19,7 +19,7 @@ describe Fuzzily::Migration do
19
19
  subject.trigrams_table_name = :foobars
20
20
  silence_stream(STDOUT) { subject.up }
21
21
  expect {
22
- ActiveRecord::Base.connection.execute('INSERT INTO `foobars` (score) VALUES (1)')
22
+ ActiveRecord::Base.connection.execute('INSERT INTO foobars (score) VALUES (1)')
23
23
  }.to_not raise_error
24
24
  end
25
25
 
data/spec/meta_spec.rb CHANGED
@@ -3,6 +3,6 @@ require 'spec_helper'
3
3
 
4
4
  describe 'Test suite' do
5
5
  it 'has a working ActiveRecord connection' do
6
- ActiveRecord::Base.connection.execute('SELECT * FROM `sqlite_master`')
6
+ ActiveRecord::Base.connection.execute('SELECT(1)')
7
7
  end
8
8
  end
data/spec/spec_helper.rb CHANGED
@@ -23,10 +23,24 @@ end
23
23
  RSpec.configure do |config|
24
24
  config.before(:each) do
25
25
  # Setup test database
26
- ActiveRecord::Base.establish_connection(
27
- :adapter => 'sqlite3',
28
- :database => Database.to_s
29
- )
26
+
27
+ if ENV['FUZZILY_USE_PG']
28
+ ActiveRecord::Base.establish_connection(
29
+ :adapter => 'postgresql',
30
+ :database => 'fuzzily_test',
31
+ :host => 'localhost',
32
+ :username => 'postgres'
33
+ )
34
+
35
+ ActiveRecord::Base.connection.execute 'DROP TABLE IF EXISTS trigrams;'
36
+ ActiveRecord::Base.connection.execute 'DROP TABLE IF EXISTS stuffs;'
37
+ ActiveRecord::Base.connection.execute 'DROP TABLE IF EXISTS foobars;'
38
+ else
39
+ ActiveRecord::Base.establish_connection(
40
+ :adapter => 'sqlite3',
41
+ :database => Database.to_s
42
+ )
43
+ end
30
44
 
31
45
  def prepare_trigrams_table
32
46
  silence_stream(STDOUT) do
@@ -43,6 +57,8 @@ RSpec.configure do |config|
43
57
  end
44
58
 
45
59
  config.after(:each) do
46
- Database.delete if Database.exist?
60
+ unless ENV['FUZZILY_USE_PG']
61
+ Database.delete if Database.exist?
62
+ end
47
63
  end
48
64
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fuzzily
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-13 00:00:00.000000000 Z
12
+ date: 2013-05-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -123,6 +123,22 @@ dependencies:
123
123
  - - ! '>='
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: pg
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
126
142
  - !ruby/object:Gem::Dependency
127
143
  name: mysql2
128
144
  requirement: !ruby/object:Gem::Requirement
@@ -165,6 +181,8 @@ files:
165
181
  - gemfiles/rails31.gemfile.lock
166
182
  - gemfiles/rails32.gemfile
167
183
  - gemfiles/rails32.gemfile.lock
184
+ - gemfiles/rails32_pg.gemfile
185
+ - gemfiles/rails32_pg.gemfile.lock
168
186
  - lib/fuzzily.rb
169
187
  - lib/fuzzily/migration.rb
170
188
  - lib/fuzzily/model.rb
@@ -191,7 +209,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
191
209
  version: '0'
192
210
  segments:
193
211
  - 0
194
- hash: 2813832546497713737
212
+ hash: 2078821306338560416
195
213
  required_rubygems_version: !ruby/object:Gem::Requirement
196
214
  none: false
197
215
  requirements:
@@ -200,7 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
200
218
  version: '0'
201
219
  segments:
202
220
  - 0
203
- hash: 2813832546497713737
221
+ hash: 2078821306338560416
204
222
  requirements: []
205
223
  rubyforge_project:
206
224
  rubygems_version: 1.8.23