pg_search_scope 0.1.7 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +4 -4
- data/lib/pg_search_scope/model_helper.rb +7 -4
- data/lib/pg_search_scope/version.rb +1 -1
- metadata +8 -10
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8f2ef54178f521230b95924c5bcfc66d39eec323
|
4
|
+
data.tar.gz: 18762a7573132d83971d7c6976216ed43a456908
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 311674c09aeb714f86c22c42e59606d177ffa860b1a1c0165cf757bc2548b98403612de3cc97a38f7ab0d7dd6e682f3f1b2669b7bca6635a2a75de9409b56678
|
7
|
+
data.tar.gz: fd72df8d924704eff25d06388ac1015a08fee7ced54ddefb9e44e1265568cf86fcf26c71627a72d98c2f52f42c27af8b952d30f26bc451c2e798e3be47a66adb
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
### PG Search Scope
|
1
|
+
### PG Search Scope ;
|
2
2
|
|
3
|
-
PostgreSQL full text search using Rails 3 scopes
|
3
|
+
PostgreSQL full text search using Rails 3 and 4 scopes
|
4
4
|
|
5
5
|
## Basic usage
|
6
6
|
|
@@ -38,7 +38,7 @@ You can set additional search options:
|
|
38
38
|
|
39
39
|
:rank_function - Ranking function. Valid values are 'ts_rank' and 'ts_rank_cd'
|
40
40
|
|
41
|
-
:rank_columns - If you want to sort table by rank only by specific fields - input column names
|
41
|
+
:rank_columns - If you want to sort table by rank only by specific fields - input column names here
|
42
42
|
|
43
43
|
If you use `:language` option, you need to use the same option for `add_fulltext_index`
|
44
44
|
|
@@ -57,4 +57,4 @@ Examples:
|
|
57
57
|
## Copyright
|
58
58
|
|
59
59
|
Copyright (c) 2011 Ivan Efremov, Ilia Ablamonov, Cloud Castle Inc.
|
60
|
-
See LICENSE for details.
|
60
|
+
See LICENSE for details.
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module PgSearchScope
|
2
2
|
module ModelHelper
|
3
|
+
SCOPE_METHOD = defined?(ActiveRecord) && ActiveRecord::VERSION::MAJOR > 3 ? :all : :scoped
|
4
|
+
|
3
5
|
DEFAULT_OPTIONS = {
|
4
6
|
:as => nil,
|
5
7
|
:wildcard => true,
|
@@ -33,7 +35,7 @@ module PgSearchScope
|
|
33
35
|
#
|
34
36
|
# * <tt>:language</tt> - Search language, e.g. 'simple' (without magic), 'english'
|
35
37
|
# * <tt>:rank_function</tt> - Ranking function. Valid values are 'ts_rank' and 'ts_rank_cd'
|
36
|
-
# * <tt>:rank_columns</tt> - If you want to sort table by rank only by specific fields - input column names
|
38
|
+
# * <tt>:rank_columns</tt> - If you want to sort table by rank only by specific fields - input column names here
|
37
39
|
#
|
38
40
|
# == Usage
|
39
41
|
#
|
@@ -56,7 +58,8 @@ module PgSearchScope
|
|
56
58
|
options = scope_options.merge(options || {})
|
57
59
|
search_string ||= ''
|
58
60
|
|
59
|
-
terms = search_string.scan(/
|
61
|
+
terms = search_string.scan(/([\p{Lu}\p{Ll}\d][\p{Lu}\p{Ll}\d\.'@]*)/u).map {|s,_| s.gsub /'/, "''"}
|
62
|
+
|
60
63
|
|
61
64
|
if terms.present?
|
62
65
|
prefix = arel_table.table_alias || arel_table.name
|
@@ -79,7 +82,7 @@ module PgSearchScope
|
|
79
82
|
|
80
83
|
rank = "#{scope_options[:rank_function]}(#{rank_tsvector}, #{tsquery}, #{options[:normalization]})"
|
81
84
|
|
82
|
-
search_scope =
|
85
|
+
search_scope = send(SCOPE_METHOD)
|
83
86
|
|
84
87
|
if options[:select_rank]
|
85
88
|
search_scope = search_scope.select("#{rank} #{scope_name}_rank")
|
@@ -96,4 +99,4 @@ module PgSearchScope
|
|
96
99
|
end
|
97
100
|
end
|
98
101
|
|
99
|
-
ActiveRecord::Base.send :extend, PgSearchScope::ModelHelper
|
102
|
+
ActiveRecord::Base.send :extend, PgSearchScope::ModelHelper
|
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg_search_scope
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.9
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Ivan Efremov, Ilia Ablamonov, Cloud Castle Inc.
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-11-10 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
13
|
description: ''
|
15
14
|
email:
|
@@ -19,7 +18,7 @@ executables: []
|
|
19
18
|
extensions: []
|
20
19
|
extra_rdoc_files: []
|
21
20
|
files:
|
22
|
-
- .gitignore
|
21
|
+
- ".gitignore"
|
23
22
|
- Gemfile
|
24
23
|
- LICENSE
|
25
24
|
- README.md
|
@@ -31,26 +30,25 @@ files:
|
|
31
30
|
- pg_search_scope.gemspec
|
32
31
|
homepage: https://github.com/cloudcastle/pg_search_scope
|
33
32
|
licenses: []
|
33
|
+
metadata: {}
|
34
34
|
post_install_message:
|
35
35
|
rdoc_options: []
|
36
36
|
require_paths:
|
37
37
|
- lib
|
38
38
|
required_ruby_version: !ruby/object:Gem::Requirement
|
39
|
-
none: false
|
40
39
|
requirements:
|
41
|
-
- -
|
40
|
+
- - ">="
|
42
41
|
- !ruby/object:Gem::Version
|
43
42
|
version: '0'
|
44
43
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
|
-
none: false
|
46
44
|
requirements:
|
47
|
-
- -
|
45
|
+
- - ">="
|
48
46
|
- !ruby/object:Gem::Version
|
49
47
|
version: '0'
|
50
48
|
requirements: []
|
51
49
|
rubyforge_project: pg_search_scope
|
52
|
-
rubygems_version:
|
50
|
+
rubygems_version: 2.2.2
|
53
51
|
signing_key:
|
54
|
-
specification_version:
|
52
|
+
specification_version: 4
|
55
53
|
summary: PostgreSQL full text search using Rails 3 scopes
|
56
54
|
test_files: []
|