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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3c1f0be1e0222fd105f14a6021e65e0b92ecf154
4
- data.tar.gz: a96c50991cf0d5f180960b2f81086dd22038bec7
3
+ metadata.gz: d04543358e6ec800df190db5551d6c0b1d54c724
4
+ data.tar.gz: 444c4b642b6adbb9e7cae708e8499d3e4649583a
5
5
  SHA512:
6
- metadata.gz: 95b1281eba8a4898f740d2b5a2038ba05f8a83ada3766a136c9d468ab8d3091970d9ad26103f7fdb186001d0dbf67f6556d1c99bc53603d6389f901d1bc9a732
7
- data.tar.gz: 0dedbefc9d1f58f78ee76e7b9777056d83b82f53396b5f4dd3edd647ccd6cf33d998959e10e5f5192b800a51bead6ba06516d0193f1e1254d3d3fe56f83ad08f
6
+ metadata.gz: 49349a79e620091a9284072812e6b4f335eceece513751146af68f004a1fabe4b901afd7811a5de2adc4c494adb5b1339529fa641daca382011a111c8382f3de
7
+ data.tar.gz: e975d27be885f3d98c64c11c6e7e2eaf036402b5a2301c2cd6ff2dffda9ae9bf8d7d14dd2c3b52ae78e1dc747b69fb5385198bc7aad33e0687953aa8981aeb7b
data/.gitignore CHANGED
@@ -1,6 +1,5 @@
1
1
  *.gem
2
2
  *.rbc
3
- .bundle
4
3
  .config
5
4
  .yardoc
6
5
  InstalledFiles
@@ -21,3 +20,7 @@ tmp
21
20
  # Data
22
21
  *.gz
23
22
  *.bz2
23
+
24
+ # Bundler
25
+ .bundle
26
+ vendor/bundle
@@ -0,0 +1,3 @@
1
+ [submodule "rebund"]
2
+ path = rebund
3
+ url = https://github.com/mezis/rebund.git
@@ -1 +1 @@
1
- 2.0.0-p247
1
+ 2.0.0-p353
@@ -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: bundle install
15
- bundler_args:
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=
@@ -1,11 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fuzzily (0.3.1)
4
+ fuzzily (0.3.2)
5
5
  activerecord (>= 2.3.17)
6
6
 
7
7
  GEM
8
- remote: https://rubygems.org/
8
+ remote: http://yarp.dev/
9
9
  specs:
10
10
  activemodel (3.2.14)
11
11
  activesupport (= 3.2.14)
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 magniture) when turning
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/mezis/Dropbox/Development/fuzzily
3
3
  specs:
4
- fuzzily (0.3.1)
4
+ fuzzily (0.3.2)
5
5
  activerecord (>= 2.3.17)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/mezis/Dropbox/Development/fuzzily
3
3
  specs:
4
- fuzzily (0.3.1)
4
+ fuzzily (0.3.2)
5
5
  activerecord (>= 2.3.17)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/mezis/Dropbox/Development/fuzzily
3
3
  specs:
4
- fuzzily (0.3.1)
4
+ fuzzily (0.3.2)
5
5
  activerecord (>= 2.3.17)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/mezis/Dropbox/Development/fuzzily
3
3
  specs:
4
- fuzzily (0.3.1)
4
+ fuzzily (0.3.2)
5
5
  activerecord (>= 2.3.17)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/mezis/Dropbox/Development/fuzzily
3
3
  specs:
4
- fuzzily (0.3.1)
4
+ fuzzily (0.3.2)
5
5
  activerecord (>= 2.3.17)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/mezis/Dropbox/Development/fuzzily
3
3
  specs:
4
- fuzzily (0.3.1)
4
+ fuzzily (0.3.2)
5
5
  activerecord (>= 2.3.17)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/mezis/Dropbox/Development/fuzzily
3
3
  specs:
4
- fuzzily (0.3.1)
4
+ fuzzily (0.3.2)
5
5
  activerecord (>= 2.3.17)
6
6
 
7
7
  GEM
@@ -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).create!(:score => score, :trigram => trigram, :owner_type => self.class.name)
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
 
@@ -1,3 +1,3 @@
1
1
  module Fuzzily
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
@@ -2,8 +2,11 @@ require 'spec_helper'
2
2
 
3
3
  describe Fuzzily::Searchable do
4
4
  # Prepare ourselves a Trigram repository
5
- class Trigram < ActiveRecord::Base
6
- include Fuzzily::Model
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.1
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: 2013-12-09 00:00:00.000000000 Z
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.3
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