fuzzily 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -1
- data/.gitmodules +3 -0
- data/.ruby-version +1 -1
- data/.travis.yml +8 -2
- data/Gemfile.lock +2 -2
- data/README.md +6 -2
- data/gemfiles/rails23.gemfile.lock +1 -1
- data/gemfiles/rails30.gemfile.lock +1 -1
- data/gemfiles/rails31.gemfile.lock +1 -1
- data/gemfiles/rails32.gemfile.lock +1 -1
- data/gemfiles/rails32_mysql.gemfile.lock +1 -1
- data/gemfiles/rails32_pg.gemfile.lock +1 -1
- data/gemfiles/rails40.gemfile.lock +1 -1
- data/lib/fuzzily/searchable.rb +6 -1
- data/lib/fuzzily/version.rb +1 -1
- data/spec/fuzzily/searchable_spec.rb +15 -2
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d04543358e6ec800df190db5551d6c0b1d54c724
|
4
|
+
data.tar.gz: 444c4b642b6adbb9e7cae708e8499d3e4649583a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49349a79e620091a9284072812e6b4f335eceece513751146af68f004a1fabe4b901afd7811a5de2adc4c494adb5b1339529fa641daca382011a111c8382f3de
|
7
|
+
data.tar.gz: e975d27be885f3d98c64c11c6e7e2eaf036402b5a2301c2cd6ff2dffda9ae9bf8d7d14dd2c3b52ae78e1dc747b69fb5385198bc7aad33e0687953aa8981aeb7b
|
data/.gitignore
CHANGED
data/.gitmodules
ADDED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.0-
|
1
|
+
2.0.0-p353
|
data/.travis.yml
CHANGED
@@ -11,8 +11,13 @@ gemfile:
|
|
11
11
|
- gemfiles/rails32_pg.gemfile
|
12
12
|
- gemfiles/rails32_mysql.gemfile
|
13
13
|
- gemfiles/rails40.gemfile
|
14
|
-
before_install:
|
15
|
-
|
14
|
+
before_install:
|
15
|
+
- if ruby --version | fgrep -q 'ruby 1.8.7' ; then gem update --system 1.8.25 ; fi
|
16
|
+
install:
|
17
|
+
- ./rebund/run download
|
18
|
+
- bundle install --path ../vendor/bundle
|
19
|
+
after_script:
|
20
|
+
- ./rebund/run upload
|
16
21
|
matrix:
|
17
22
|
exclude:
|
18
23
|
- rvm: 2.0.0
|
@@ -27,3 +32,4 @@ before_script:
|
|
27
32
|
env:
|
28
33
|
global:
|
29
34
|
- TRAVIS=TRUE
|
35
|
+
- secure: bXHSygHAYQtuVj+rZSaXOQJFWVQEwnOm3HOivKfh+0CADtHJ3TxWSPHpwWPDx/+GDqad4eU/9qfhb5GBr1lJMRJmSi5iJ53KOZxilHqL0fo070mSsLEvOSnT6fKwIe30+3LTYVR6oKEwdyt9EI/yP5aGO4klncZkvI2zqAoy6YI=
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -109,7 +109,7 @@ end
|
|
109
109
|
|
110
110
|
class AddTrigramsModel < ActiveRecord::Migration
|
111
111
|
extend Fuzzily::Migration
|
112
|
-
trigrams_table_name = :custom_trigrams
|
112
|
+
self.trigrams_table_name = :custom_trigrams
|
113
113
|
end
|
114
114
|
|
115
115
|
class MyStuff < ActiveRecord::Base
|
@@ -123,7 +123,7 @@ For large data sets (millions of rows to index), the "compatible" storage
|
|
123
123
|
used by default will typically no longer be enough to keep the index small
|
124
124
|
enough.
|
125
125
|
|
126
|
-
Users have reported **major improvements** (2 order of
|
126
|
+
Users have reported **major improvements** (2 order of magnitude) when turning
|
127
127
|
the `owner_type` and `fuzzy_field` columns of the `trigrams` table from
|
128
128
|
`VARCHAR` (the default) into `ENUM`. This is particularly efficient with
|
129
129
|
MySQL and pgSQL.
|
@@ -142,6 +142,10 @@ class AddTrigramsModel < ActiveRecord::Migration
|
|
142
142
|
end
|
143
143
|
```
|
144
144
|
|
145
|
+
## Model primary key (id) is VARCHAR
|
146
|
+
|
147
|
+
If you set your Model primary key (id) AS `VARCHAR` instead of `INT`, you will need to change the `owner_id` column type from `INT` to `VARCHAR` in the trigrams table.
|
148
|
+
|
145
149
|
## Searching virtual attributes
|
146
150
|
|
147
151
|
Your searchable fields do not have to be stored, they can be dynamic methods
|
data/lib/fuzzily/searchable.rb
CHANGED
@@ -17,7 +17,12 @@ module Fuzzily
|
|
17
17
|
def _update_fuzzy!(_o)
|
18
18
|
self.send(_o.trigram_association).delete_all
|
19
19
|
String.new(self.send(_o.field)).scored_trigrams.each do |trigram, score|
|
20
|
-
self.send(_o.trigram_association).
|
20
|
+
self.send(_o.trigram_association).build.tap do |record|
|
21
|
+
record.score = score
|
22
|
+
record.trigram = trigram
|
23
|
+
record.fuzzy_field = _o.field.to_s
|
24
|
+
record.save!
|
25
|
+
end
|
21
26
|
end
|
22
27
|
end
|
23
28
|
|
data/lib/fuzzily/version.rb
CHANGED
@@ -2,8 +2,11 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Fuzzily::Searchable do
|
4
4
|
# Prepare ourselves a Trigram repository
|
5
|
-
|
6
|
-
|
5
|
+
before do
|
6
|
+
silence_warnings do
|
7
|
+
Trigram = Class.new(ActiveRecord::Base)
|
8
|
+
end
|
9
|
+
Trigram.class_eval { include Fuzzily::Model }
|
7
10
|
end
|
8
11
|
|
9
12
|
before(:each) { prepare_trigrams_table }
|
@@ -83,6 +86,16 @@ describe Fuzzily::Searchable do
|
|
83
86
|
subject.last.update_fuzzy_name!
|
84
87
|
Trigram.all.should be_empty
|
85
88
|
end
|
89
|
+
|
90
|
+
if ActiveRecord::VERSION::MAJOR <= 3
|
91
|
+
let(:fields) {[ :score, :fuzzy_field, :trigram ]}
|
92
|
+
before { Trigram.attr_protected fields }
|
93
|
+
|
94
|
+
it 'tolerates mass assignment security' do
|
95
|
+
subject.create!(:name => 'Paris')
|
96
|
+
subject.last.update_fuzzy_name!
|
97
|
+
end
|
98
|
+
end
|
86
99
|
end
|
87
100
|
|
88
101
|
describe '.bulk_update_fuzzy_<field>' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fuzzily
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julien Letessier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -158,6 +158,7 @@ extensions: []
|
|
158
158
|
extra_rdoc_files: []
|
159
159
|
files:
|
160
160
|
- .gitignore
|
161
|
+
- .gitmodules
|
161
162
|
- .rspec
|
162
163
|
- .ruby-version
|
163
164
|
- .travis.yml
|
@@ -214,7 +215,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
214
215
|
version: '0'
|
215
216
|
requirements: []
|
216
217
|
rubyforge_project:
|
217
|
-
rubygems_version: 2.0.
|
218
|
+
rubygems_version: 2.0.14
|
218
219
|
signing_key:
|
219
220
|
specification_version: 4
|
220
221
|
summary: A fast, trigram-based, database-backed fuzzy string search/match engine for
|