pg_search_multiple_highlight 0.1.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -2
- data/Gemfile +26 -4
- data/Gemfile.lock +77 -12
- data/lib/pg_search_multiple_highlight/tsearch.rb +4 -17
- data/lib/pg_search_multiple_highlight/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1102e138d69bc59b4fbcb29b470530af8ffb8111e9bc2035cb80bea3c4909333
|
4
|
+
data.tar.gz: d6b092296fc0ecdae01cbb5308dce5a77915643d4d75ca0a385311873564b922
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 936c9289a3ee0752e306a5c63c7ee4bf4e10fe7c9153d6314175a7724f6c17fb56cd14cfe4c22e0d89ab8b84146536b6188bf78ae35aa422d380f8aff8cb832b
|
7
|
+
data.tar.gz: f63fb8d7697b3dc76be7a1db7561681cb2dcf4a7dd7fcbf90acb3478488cf84d8bfdeeca4382c3b18a73e4b62c8fb9e0cb9564d1e4711f0160f8f46181a44797
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
@@ -2,11 +2,33 @@
|
|
2
2
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
|
-
# Specify your gem
|
5
|
+
# Specify your gem"s dependencies in pg_search_multiple_highlight.gemspec
|
6
6
|
gemspec
|
7
7
|
|
8
|
+
if ENV["ACTIVE_RECORD_BRANCH"]
|
9
|
+
gem "activerecord", git: "https://github.com/rails/rails.git", branch: ENV.fetch("ACTIVE_RECORD_BRANCH", nil)
|
10
|
+
gem "arel", git: "https://github.com/rails/arel.git" if ENV.fetch("ACTIVE_RECORD_BRANCH", nil) == "master"
|
11
|
+
end
|
12
|
+
|
13
|
+
gem "activerecord-jdbcpostgresql-adapter", ">= 1.3.1", platform: :jruby
|
14
|
+
gem "bundle-audit", "~> 0.1.0"
|
15
|
+
gem "pg", ">= 0.21.0", platform: :ruby
|
8
16
|
gem "rake", "~> 13.0"
|
9
|
-
gem "minitest", "~> 5.0"
|
10
17
|
gem "rubocop", "~> 1.21"
|
11
|
-
gem "
|
12
|
-
gem "
|
18
|
+
gem "rubocop-minitest"
|
19
|
+
gem "rubocop-performance"
|
20
|
+
gem "rubocop-rails"
|
21
|
+
gem "rubocop-rake"
|
22
|
+
|
23
|
+
group :development, :test do
|
24
|
+
gem "byebug"
|
25
|
+
gem "database_cleaner"
|
26
|
+
gem "minitest", "~> 5.0"
|
27
|
+
gem "simplecov"
|
28
|
+
gem "simplecov-lcov"
|
29
|
+
gem "single_cov", "~> 1.9"
|
30
|
+
gem "standard", ">= 1.23.0"
|
31
|
+
gem "undercover"
|
32
|
+
gem "warning"
|
33
|
+
gem "with_model"
|
34
|
+
end
|
data/Gemfile.lock
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
pg_search_multiple_highlight (0.
|
4
|
+
pg_search_multiple_highlight (0.3.0)
|
5
5
|
pg_search (~> 2.3)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activemodel (7.0.
|
11
|
-
activesupport (= 7.0.
|
12
|
-
activerecord (7.0.
|
13
|
-
activemodel (= 7.0.
|
14
|
-
activesupport (= 7.0.
|
15
|
-
activesupport (7.0.
|
10
|
+
activemodel (7.0.7.1)
|
11
|
+
activesupport (= 7.0.7.1)
|
12
|
+
activerecord (7.0.7.1)
|
13
|
+
activemodel (= 7.0.7.1)
|
14
|
+
activesupport (= 7.0.7.1)
|
15
|
+
activesupport (7.0.7.1)
|
16
16
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
17
|
i18n (>= 1.6, < 2)
|
18
18
|
minitest (>= 5.1)
|
@@ -23,54 +23,119 @@ GEM
|
|
23
23
|
bundler-audit (0.9.1)
|
24
24
|
bundler (>= 1.2.0, < 3)
|
25
25
|
thor (~> 1.0)
|
26
|
-
|
26
|
+
byebug (11.1.3)
|
27
|
+
concurrent-ruby (1.2.3)
|
28
|
+
database_cleaner (2.0.2)
|
29
|
+
database_cleaner-active_record (>= 2, < 3)
|
30
|
+
database_cleaner-active_record (2.1.0)
|
31
|
+
activerecord (>= 5.a)
|
32
|
+
database_cleaner-core (~> 2.0.0)
|
33
|
+
database_cleaner-core (2.0.1)
|
34
|
+
docile (1.4.0)
|
27
35
|
i18n (1.14.1)
|
28
36
|
concurrent-ruby (~> 1.0)
|
37
|
+
imagen (0.1.8)
|
38
|
+
parser (>= 2.5, != 2.5.1.1)
|
29
39
|
json (2.6.3)
|
30
40
|
language_server-protocol (3.17.0.3)
|
31
|
-
|
41
|
+
lint_roller (1.1.0)
|
42
|
+
minitest (5.21.2)
|
32
43
|
parallel (1.23.0)
|
33
44
|
parser (3.2.2.3)
|
34
45
|
ast (~> 2.4.1)
|
35
46
|
racc
|
47
|
+
pg (1.5.3)
|
36
48
|
pg_search (2.3.6)
|
37
49
|
activerecord (>= 5.2)
|
38
50
|
activesupport (>= 5.2)
|
39
51
|
racc (1.7.1)
|
52
|
+
rack (3.0.8)
|
40
53
|
rainbow (3.1.1)
|
41
54
|
rake (13.0.6)
|
42
55
|
regexp_parser (2.8.1)
|
43
56
|
rexml (3.2.6)
|
44
|
-
rubocop (1.
|
57
|
+
rubocop (1.52.1)
|
45
58
|
json (~> 2.3)
|
46
|
-
language_server-protocol (>= 3.17.0)
|
47
59
|
parallel (~> 1.10)
|
48
60
|
parser (>= 3.2.2.3)
|
49
61
|
rainbow (>= 2.2.2, < 4.0)
|
50
62
|
regexp_parser (>= 1.8, < 3.0)
|
51
63
|
rexml (>= 3.2.5, < 4.0)
|
52
|
-
rubocop-ast (>= 1.28.
|
64
|
+
rubocop-ast (>= 1.28.0, < 2.0)
|
53
65
|
ruby-progressbar (~> 1.7)
|
54
66
|
unicode-display_width (>= 2.4.0, < 3.0)
|
55
67
|
rubocop-ast (1.29.0)
|
56
68
|
parser (>= 3.2.1.0)
|
69
|
+
rubocop-minitest (0.31.0)
|
70
|
+
rubocop (>= 1.39, < 2.0)
|
71
|
+
rubocop-performance (1.18.0)
|
72
|
+
rubocop (>= 1.7.0, < 2.0)
|
73
|
+
rubocop-ast (>= 0.4.0)
|
74
|
+
rubocop-rails (2.20.2)
|
75
|
+
activesupport (>= 4.2.0)
|
76
|
+
rack (>= 1.1)
|
77
|
+
rubocop (>= 1.33.0, < 2.0)
|
78
|
+
rubocop-rake (0.6.0)
|
79
|
+
rubocop (~> 1.0)
|
57
80
|
ruby-progressbar (1.13.0)
|
81
|
+
rugged (1.6.3)
|
82
|
+
simplecov (0.22.0)
|
83
|
+
docile (~> 1.1)
|
84
|
+
simplecov-html (~> 0.11)
|
85
|
+
simplecov_json_formatter (~> 0.1)
|
86
|
+
simplecov-html (0.12.3)
|
87
|
+
simplecov-lcov (0.8.0)
|
88
|
+
simplecov_json_formatter (0.1.4)
|
58
89
|
single_cov (1.11.0)
|
90
|
+
standard (1.30.1)
|
91
|
+
language_server-protocol (~> 3.17.0.2)
|
92
|
+
lint_roller (~> 1.0)
|
93
|
+
rubocop (~> 1.52.0)
|
94
|
+
standard-custom (~> 1.0.0)
|
95
|
+
standard-performance (~> 1.1.0)
|
96
|
+
standard-custom (1.0.2)
|
97
|
+
lint_roller (~> 1.0)
|
98
|
+
rubocop (~> 1.50)
|
99
|
+
standard-performance (1.1.2)
|
100
|
+
lint_roller (~> 1.1)
|
101
|
+
rubocop-performance (~> 1.18.0)
|
59
102
|
thor (1.2.2)
|
60
103
|
tzinfo (2.0.6)
|
61
104
|
concurrent-ruby (~> 1.0)
|
105
|
+
undercover (0.4.6)
|
106
|
+
imagen (>= 0.1.8)
|
107
|
+
rainbow (>= 2.1, < 4.0)
|
108
|
+
rugged (>= 0.27, < 1.7)
|
62
109
|
unicode-display_width (2.4.2)
|
110
|
+
warning (1.3.0)
|
111
|
+
with_model (2.1.6)
|
112
|
+
activerecord (>= 5.2)
|
63
113
|
|
64
114
|
PLATFORMS
|
65
115
|
x86_64-darwin-22
|
116
|
+
x86_64-linux
|
66
117
|
|
67
118
|
DEPENDENCIES
|
119
|
+
activerecord-jdbcpostgresql-adapter (>= 1.3.1)
|
68
120
|
bundle-audit (~> 0.1.0)
|
121
|
+
byebug
|
122
|
+
database_cleaner
|
69
123
|
minitest (~> 5.0)
|
124
|
+
pg (>= 0.21.0)
|
70
125
|
pg_search_multiple_highlight!
|
71
126
|
rake (~> 13.0)
|
72
127
|
rubocop (~> 1.21)
|
128
|
+
rubocop-minitest
|
129
|
+
rubocop-performance
|
130
|
+
rubocop-rails
|
131
|
+
rubocop-rake
|
132
|
+
simplecov
|
133
|
+
simplecov-lcov
|
73
134
|
single_cov (~> 1.9)
|
135
|
+
standard (>= 1.23.0)
|
136
|
+
undercover
|
137
|
+
warning
|
138
|
+
with_model
|
74
139
|
|
75
140
|
BUNDLED WITH
|
76
141
|
2.4.6
|
@@ -6,7 +6,7 @@ module PgSearch
|
|
6
6
|
# Extends class to enable multiple_ighlight method for the search results
|
7
7
|
class TSearch < Feature
|
8
8
|
def self.valid_options
|
9
|
-
super + %i[multiple_highlight]
|
9
|
+
super + %i[dictionary prefix negation any_word normalization tsvector_column highlight multiple_highlight]
|
10
10
|
end
|
11
11
|
|
12
12
|
def multiple_highlight
|
@@ -27,24 +27,11 @@ module PgSearch
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def highlight_multiple_fields(text, query)
|
30
|
-
|
30
|
+
split_words = query.split(/\s+/).map { |word| Regexp.escape(word) }
|
31
31
|
|
32
|
-
|
32
|
+
regex = Regexp.new("\\b(#{split_words.join("|")})\\b", Regexp::IGNORECASE)
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
scope_options = raw_options.map { |key, value| "#{key}=#{value}" }.join(", ")
|
37
|
-
|
38
|
-
sanitized_sql = ActiveRecord::Base.send(
|
39
|
-
:sanitize_sql_array, [
|
40
|
-
"SELECT ts_headline(
|
41
|
-
?, to_tsquery('#{dictionary}', ?),
|
42
|
-
'#{scope_options}'
|
43
|
-
) AS highlighted_text",
|
44
|
-
text, tsquery
|
45
|
-
]
|
46
|
-
)
|
47
|
-
ActiveRecord::Base.connection.execute(sanitized_sql).first["highlighted_text"]
|
34
|
+
text.gsub(regex) { |match| "<mark>#{match}</mark>" }
|
48
35
|
end
|
49
36
|
end
|
50
37
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg_search_multiple_highlight
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Suleyman Musayev
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg_search
|
@@ -73,7 +73,7 @@ metadata:
|
|
73
73
|
source_code_uri: https://github.com/msuliq/pg_search_multiple_highlight
|
74
74
|
changelog_uri: https://github.com/msuliq/pg_search_multiple_highlight/blob/main/CHANGELOG.md
|
75
75
|
rubygems_mfa_required: 'true'
|
76
|
-
post_install_message:
|
76
|
+
post_install_message:
|
77
77
|
rdoc_options: []
|
78
78
|
require_paths:
|
79
79
|
- lib
|
@@ -88,8 +88,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
requirements: []
|
91
|
-
rubygems_version: 3.
|
92
|
-
signing_key:
|
91
|
+
rubygems_version: 3.1.6
|
92
|
+
signing_key:
|
93
93
|
specification_version: 4
|
94
94
|
summary: The 'pg_search_multiple_highlight' gem enhances the 'pg_search' gem by introducing
|
95
95
|
a new scope option, ':multiple_highlight', which enables highlighting of search
|