textacular 3.2.1 → 3.2.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: 4265ce68e4f181daae87f7bd5ddeafd3b6319b74
4
- data.tar.gz: 01747846949f1a3ceef279a62f1e4587cea23a7a
3
+ metadata.gz: 0c424e3436f89ec19e61d9f932a17fb2b4eaafae
4
+ data.tar.gz: 7d53e4d8a74f6948943a7db4c6e5dd4fce49ba30
5
5
  SHA512:
6
- metadata.gz: 9cd720c7b946da4ec997dff477eae5ccc4133a086784bdd1a9521ba53c5b0683698c5daa6d445acf48b9eb600bfe2d805a60a5410ddcdaac7fd22259ad0040d2
7
- data.tar.gz: 5978ac5a4a59eeaf656b09dcadb36f0034e8e9190d5d8c800e5525471b738c9fde8187676a130d0c2e9ebd160cbe9b448b808b16e3a1a3b5d10201df54ea0164
6
+ metadata.gz: b931560f6e448f9bd3c391641780816e130b3e48a9f5255bf6fdf19e1f4ba0e9994291d826908b5d5f910c543130613d48cb8120bdc7db7e932442c3bcb45821
7
+ data.tar.gz: 03b42bb0a6ee835d797596bb770de66881b759c43aa1c477b77080cb8d0c733bedd1185c2a3a0f8ab9d3a7d27aef769c9809d6ead794a9e18f89bca281a4d77b
@@ -2,8 +2,18 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 3.2.2
6
+
7
+ * Fallback to zero similarity when trying to match null values
8
+ * Fix search term escaping
9
+ * Trigram installation migration only install extension if not installed yet.
10
+ * Update the README to illustrate how to change the similarity threshold.
11
+
12
+ ## 3.2.1
13
+
5
14
  * Fix trigram installation migration reversed filename and content.
6
15
  * Rewrite all tests using RSpec.
16
+ * We're ActiveRecord 4.2+ compatible until tests prove otherwise.
7
17
 
8
18
  ## 3.2.0
9
19
 
data/README.md CHANGED
@@ -91,6 +91,12 @@ Comic.fuzzy_search(title: 'Pearls') # matches Pearls Before Swine
91
91
  Comic.fuzzy_search(title: 'Pear') # does not match Pearls Before Swine
92
92
  ```
93
93
 
94
+ The similarity threshold is hardcoded in PostgreSQL and can be modified on a per-connection basis, for example:
95
+
96
+ ```ruby
97
+ ActiveRecord::Base.connection.execute("SELECT set_limit(0.9);")
98
+ ```
99
+
94
100
  For more info, view the `pg_trgm` documentation, specifically [F.35.2. Functions and Operators](http://www.postgresql.org/docs/9.1/static/pgtrgm.html).
95
101
 
96
102
  Searches are also chainable:
@@ -155,23 +161,14 @@ $ gem install textacular
155
161
 
156
162
  ## Contributing
157
163
 
158
- Help is gladly welcomed. If you have a feature you'd like to add, it's much more
159
- likely to get in (or get in faster) the closer you stick to these steps:
160
-
161
- 1. Open an Issue to talk about it. We can discuss whether it's the right
162
- direction or maybe help track down a bug, etc.
163
- 1. Fork the project, and make a branch to work on your feature/fix. Master is
164
- where you'll want to start from.
165
- 1. Write a test for the feature you are about to add
166
- 1. Run the tests
167
- 1. Turn the Issue into a Pull Request. There are several ways to do this, but
168
- [hub](https://github.com/defunkt/hub) is probably the easiest.
169
- 1. Bonus points if your Pull Request updates `CHANGES.md` to include a summary
170
- of your changes and your name like the other entries. If the last entry is
171
- the last release, add a new `## Unreleased` heading.
172
-
173
- If you don't know how to fix something, even just a Pull Request that includes a
174
- failing test can be helpful. If in doubt, make an Issue to discuss.
164
+ If you'd like to contribute, please see the [contribution guidelines](CONTRIBUTING.md).
165
+
166
+
167
+ ## Releasing
168
+
169
+ Maintainers: Please make sure to follow the [release steps](RELEASING.md) when
170
+ it's time to cut a new release.
171
+
175
172
 
176
173
  ## LICENSE:
177
174
 
@@ -141,7 +141,7 @@ module Textacular
141
141
  end
142
142
 
143
143
  def fuzzy_similarity_string(table_name, column, search_term)
144
- "similarity(#{table_name}.#{column}, #{search_term})"
144
+ "COALESCE(similarity(#{table_name}.#{column}, #{search_term}), 0)"
145
145
  end
146
146
 
147
147
  def fuzzy_condition_string(table_name, column, search_term)
@@ -179,7 +179,7 @@ module Textacular
179
179
  module Helper
180
180
  class << self
181
181
  def normalize(query)
182
- query.to_s.gsub(' ', '\\\\ ')
182
+ query.to_s.gsub(/\s(?![\&|\!|\|])/, '\\\\ ')
183
183
  end
184
184
 
185
185
  def method_name_regex
@@ -3,7 +3,7 @@ class Textacular::TrigramInstaller
3
3
  content = <<-MIGRATION
4
4
  class InstallTrigram < ActiveRecord::Migration
5
5
  def self.up
6
- ActiveRecord::Base.connection.execute("CREATE EXTENSION pg_trgm;")
6
+ ActiveRecord::Base.connection.execute("CREATE EXTENSION IF NOT EXISTS pg_trgm;")
7
7
  end
8
8
 
9
9
  def self.down
@@ -1,5 +1,5 @@
1
1
  module Textacular
2
- VERSION = '3.2.1'
2
+ VERSION = '3.2.2'
3
3
 
4
4
  def self.version
5
5
  VERSION
@@ -61,7 +61,7 @@ RSpec.describe "Searchable" do
61
61
  let!(:questionable_content) do
62
62
  WebComicWithSearchableName.create(
63
63
  name: 'Questionable Content',
64
- author: 'Jeph Jaques',
64
+ author: nil,
65
65
  )
66
66
  end
67
67
 
@@ -108,6 +108,9 @@ RSpec.describe "Searchable" do
108
108
  }.to raise_error(ActiveRecord::StatementInvalid)
109
109
  end
110
110
  end
111
+ it "searches with negation" do
112
+ expect(WebComicWithSearchableName.advanced_search('foo & ! bar')).to be_empty
113
+ end
111
114
  end
112
115
 
113
116
  it "does fuzzy searching" do
@@ -116,6 +119,13 @@ RSpec.describe "Searchable" do
116
119
  ).to eq([questionable_content])
117
120
  end
118
121
 
122
+ it "return a valid rank when fuzzy searching on NULL columns" do
123
+ qcont_with_author = questionable_content.becomes(WebComicWithSearchableNameAndAuthor)
124
+ search_result = WebComicWithSearchableNameAndAuthor.fuzzy_search('Questio')
125
+ expect([qcont_with_author]).to eq(search_result)
126
+ expect(search_result.first.attributes.find { |k, _| k[0..3] == 'rank' }.last).to be_truthy
127
+ end
128
+
119
129
  it "defines :searchable_columns as private" do
120
130
  expect { WebComicWithSearchableName.searchable_columns }.to raise_error(NoMethodError)
121
131
 
@@ -3,7 +3,7 @@ RSpec.describe "Textacular::TrigramInstaller" do
3
3
  <<-MIGRATION
4
4
  class InstallTrigram < ActiveRecord::Migration
5
5
  def self.up
6
- ActiveRecord::Base.connection.execute("CREATE EXTENSION pg_trgm;")
6
+ ActiveRecord::Base.connection.execute("CREATE EXTENSION IF NOT EXISTS pg_trgm;")
7
7
  end
8
8
 
9
9
  def self.down
metadata CHANGED
@@ -1,16 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: textacular
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.1
4
+ version: 3.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Hamill
8
8
  - ecin
9
9
  - Aaron Patterson
10
+ - Greg Molnar
10
11
  autorequire:
11
12
  bindir: bin
12
13
  cert_chain: []
13
- date: 2014-12-22 00:00:00.000000000 Z
14
+ date: 2015-03-28 00:00:00.000000000 Z
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
17
  name: pg
@@ -180,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
180
181
  version: '0'
181
182
  requirements: []
182
183
  rubyforge_project:
183
- rubygems_version: 2.4.3
184
+ rubygems_version: 2.2.2
184
185
  signing_key:
185
186
  specification_version: 4
186
187
  summary: Textacular exposes full text search capabilities from PostgreSQL