pg_search 2.3.0 → 2.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +1 -0
  3. data/.github/dependabot.yml +11 -0
  4. data/.github/workflows/ci.yml +75 -0
  5. data/.jrubyrc +1 -0
  6. data/.rubocop.yml +88 -7
  7. data/.travis.yml +20 -33
  8. data/CHANGELOG.md +50 -16
  9. data/CODE_OF_CONDUCT.md +76 -0
  10. data/Gemfile +1 -1
  11. data/LICENSE +1 -1
  12. data/README.md +73 -26
  13. data/Rakefile +7 -1
  14. data/lib/pg_search/configuration.rb +12 -2
  15. data/lib/pg_search/document.rb +1 -1
  16. data/lib/pg_search/features/dmetaphone.rb +4 -6
  17. data/lib/pg_search/features/feature.rb +1 -1
  18. data/lib/pg_search/features/tsearch.rb +14 -13
  19. data/lib/pg_search/migration/templates/add_pg_search_dmetaphone_support_functions.rb.erb +6 -6
  20. data/lib/pg_search/migration/templates/create_pg_search_documents.rb.erb +2 -2
  21. data/lib/pg_search/multisearch/rebuilder.rb +7 -3
  22. data/lib/pg_search/multisearch.rb +21 -4
  23. data/lib/pg_search/scope_options.rb +5 -8
  24. data/lib/pg_search/tasks.rb +2 -1
  25. data/lib/pg_search/version.rb +1 -1
  26. data/lib/pg_search.rb +6 -8
  27. data/pg_search.gemspec +14 -7
  28. data/spec/.rubocop.yml +2 -2
  29. data/spec/integration/.rubocop.yml +11 -0
  30. data/spec/integration/associations_spec.rb +17 -56
  31. data/spec/integration/deprecation_spec.rb +1 -1
  32. data/spec/integration/pg_search_spec.rb +94 -52
  33. data/spec/lib/pg_search/configuration/association_spec.rb +8 -6
  34. data/spec/lib/pg_search/features/dmetaphone_spec.rb +2 -2
  35. data/spec/lib/pg_search/features/trigram_spec.rb +16 -12
  36. data/spec/lib/pg_search/features/tsearch_spec.rb +16 -10
  37. data/spec/lib/pg_search/multisearch/rebuilder_spec.rb +116 -71
  38. data/spec/lib/pg_search/multisearch_spec.rb +57 -29
  39. data/spec/lib/pg_search/multisearchable_spec.rb +150 -97
  40. data/spec/lib/pg_search/normalizer_spec.rb +12 -10
  41. data/spec/lib/pg_search_spec.rb +66 -55
  42. data/spec/spec_helper.rb +22 -5
  43. data/spec/support/database.rb +7 -5
  44. metadata +109 -19
  45. data/.autotest +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c8e6c02c032d2a7a39ebe47e50584410cebe923e868dc6be720af23cd3748e55
4
- data.tar.gz: 24d70a673be8c9993c007b812af1d9af89cc565dfbbae9ed37c205d90ca893da
3
+ metadata.gz: 43a62057153fd9e33ed21bc6ce1a420b5fbeaad46e9b047bd1e039c9c7ab6ad2
4
+ data.tar.gz: 15759abc9542c0b7ddc6060e156e7eff74d78cceef5bb06c4bdfa562e029722b
5
5
  SHA512:
6
- metadata.gz: 06e43bdc63bd98ea57943068cde6723780000ca3765a016d9baecdac3eea7006a1deae35885654b88b4752e3ad6f136190ac8602ffad62b3aac356425fad66d0
7
- data.tar.gz: 500d85f688710b48bf235eb1765c66e569dd7db98d95f03eaa81242f12c746d2ce8a57176185700c8d1b6ca903039d2c9b42fd5b71c84a8e4f8c46d7ef3464f7
6
+ metadata.gz: 6c1fc5c20a82e45a4fd6381fc56fd940dcd85cce2039e2e7f5159e0c939146d0176f1970481c29205bd7d7737022007d3d78cddc3fa93603a67221fa272d1a4e
7
+ data.tar.gz: 06a4f487a2cef2fd7b55bf5f650f6e13cec3528b6514f72e6dce69943c67d879f42c795d46c7aa442b2abfe789e4459f10437df94e955f9bfbe54968e9297e39
data/.codeclimate.yml CHANGED
@@ -9,6 +9,7 @@ engines:
9
9
  enabled: true
10
10
  rubocop:
11
11
  enabled: true
12
+ channel: rubocop-0-78
12
13
  ratings:
13
14
  paths:
14
15
  - "**.rb"
@@ -0,0 +1,11 @@
1
+ # To get started with Dependabot version updates, you'll need to specify which
2
+ # package ecosystems to update and where the package manifests are located.
3
+ # Please see the documentation for all configuration options:
4
+ # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5
+
6
+ version: 2
7
+ updates:
8
+ - package-ecosystem: "bundler" # See documentation for possible values
9
+ directory: "/" # Location of package manifests
10
+ schedule:
11
+ interval: "daily"
@@ -0,0 +1,75 @@
1
+ name: build
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ - github-actions
8
+ pull_request:
9
+ branches:
10
+ - master
11
+
12
+ jobs:
13
+ test:
14
+ runs-on: ubuntu-latest
15
+ services:
16
+ postgres:
17
+ image: postgres:latest
18
+ env:
19
+ POSTGRES_USER: postgres
20
+ POSTGRES_PASSWORD: postgres
21
+ options: >-
22
+ --health-cmd pg_isready
23
+ --health-interval 10s
24
+ --health-timeout 5s
25
+ --health-retries 5
26
+ ports:
27
+ - 5432:5432
28
+ env:
29
+ CI: true
30
+ PGHOST: 127.0.0.1
31
+ PGUSER: postgres
32
+ PGPASS: postgres
33
+ strategy:
34
+ fail-fast: false
35
+ matrix:
36
+ ruby-version: ['2.6', '2.7', '3.0', '3.1']
37
+ active-record-version-env:
38
+ - ACTIVE_RECORD_VERSION="~> 5.2.0"
39
+ - ACTIVE_RECORD_VERSION="~> 6.0.0"
40
+ - ACTIVE_RECORD_VERSION="~> 6.1.0"
41
+ - ACTIVE_RECORD_VERSION="~> 7.0.0"
42
+ allow-failure: [false]
43
+ include:
44
+ - ruby-version: '3.1'
45
+ active-record-version-env: ACTIVE_RECORD_BRANCH="7-0-stable"
46
+ allow-failure: true
47
+ - ruby-version: '3.1'
48
+ active-record-version-env: ACTIVE_RECORD_BRANCH="6-1-stable"
49
+ allow-failure: true
50
+ exclude:
51
+ - ruby-version: '3.0'
52
+ active-record-version-env: ACTIVE_RECORD_VERSION="~> 5.2.0"
53
+ allow-failure: false
54
+ - ruby-version: '3.1'
55
+ active-record-version-env: ACTIVE_RECORD_VERSION="~> 5.2.0"
56
+ allow-failure: false
57
+ - ruby-version: '2.6'
58
+ active-record-version-env: ACTIVE_RECORD_VERSION="~> 7.0.0"
59
+ allow-failure: false
60
+ continue-on-error: ${{ matrix.allow-failure }}
61
+ steps:
62
+ - uses: actions/checkout@v2
63
+ - name: Set up Ruby
64
+ uses: ruby/setup-ruby@v1
65
+ with:
66
+ ruby-version: ${{ matrix.ruby-version }}
67
+ bundler-cache: true
68
+ - name: Set up test database
69
+ env:
70
+ PGPASSWORD: postgres
71
+ run: createdb pg_search_test
72
+ - name: Update bundle
73
+ run: ${{ matrix.active-record-version-env }} bundle update
74
+ - name: Run tests
75
+ run: ${{ matrix.active-record-version-env }} bundle exec rake
data/.jrubyrc ADDED
@@ -0,0 +1 @@
1
+ debug.fullTrace=true
data/.rubocop.yml CHANGED
@@ -1,7 +1,12 @@
1
- require: rubocop-performance
1
+ require:
2
+ - rubocop-performance
3
+ - rubocop-rails
4
+ - rubocop-rake
5
+ - rubocop-rspec
2
6
 
3
7
  AllCops:
4
- TargetRubyVersion: 2.4
8
+ TargetRubyVersion: 2.6
9
+ NewCops: enable
5
10
  Exclude:
6
11
  - bin/**/*
7
12
  - vendor/**/*
@@ -9,17 +14,17 @@ AllCops:
9
14
  Style/StringLiterals:
10
15
  Enabled: false
11
16
 
12
- Metrics/LineLength:
17
+ Layout/LineLength:
13
18
  Max: 120
14
19
 
15
20
  Metrics/MethodLength:
16
- Max: 21
21
+ Max: 15
17
22
 
18
23
  Metrics/BlockLength:
19
24
  Exclude:
20
25
  - spec/**/*
21
26
 
22
- Layout/AlignParameters:
27
+ Layout/ParameterAlignment:
23
28
  EnforcedStyle: with_fixed_indentation
24
29
 
25
30
  Style/NumericPredicate:
@@ -44,8 +49,8 @@ Bundler/DuplicatedGem:
44
49
 
45
50
  Style/EmptyMethod:
46
51
  EnforcedStyle: expanded
47
-
48
- Layout/IndentFirstArrayElement:
52
+
53
+ Layout/FirstArrayElementIndentation:
49
54
  EnforcedStyle: consistent
50
55
 
51
56
  Style/Documentation:
@@ -54,3 +59,79 @@ Style/Documentation:
54
59
  Style/WordArray:
55
60
  EnforcedStyle: percent
56
61
  MinSize: 3
62
+
63
+ Style/HashEachMethods:
64
+ Enabled: true
65
+
66
+ Style/HashTransformKeys:
67
+ Enabled: true
68
+
69
+ Style/HashTransformValues:
70
+ Enabled: true
71
+
72
+ Rails/ApplicationRecord:
73
+ Enabled: false
74
+
75
+ Rails/TimeZone:
76
+ Enabled: false
77
+
78
+ RSpec/ContextWording:
79
+ Prefixes:
80
+ - using
81
+ - via
82
+ - when
83
+ - with
84
+ - without
85
+
86
+ Lint/RaiseException:
87
+ Enabled: true
88
+
89
+ Lint/StructNewOverride:
90
+ Enabled: true
91
+
92
+ Layout/SpaceAroundMethodCallOperator:
93
+ Enabled: true
94
+
95
+ Style/ExponentialNotation:
96
+ Enabled: true
97
+
98
+ RSpec/DescribedClass:
99
+ Enabled: true
100
+
101
+ RSpec/ExpectInHook:
102
+ Enabled: false
103
+
104
+ RSpec/FilePath:
105
+ CustomTransform:
106
+ TSearch: "tsearch"
107
+ DMetaphone: "dmetaphone"
108
+
109
+ Layout/EmptyLinesAroundAttributeAccessor:
110
+ Enabled: true
111
+
112
+ Lint/DeprecatedOpenSSLConstant:
113
+ Enabled: true
114
+
115
+ Style/SlicingWithRange:
116
+ Enabled: true
117
+
118
+ Lint/MixedRegexpCaptureTypes:
119
+ Enabled: true
120
+
121
+ Style/RedundantFetchBlock:
122
+ Enabled: true
123
+
124
+ Style/RedundantRegexpCharacterClass:
125
+ Enabled: true
126
+
127
+ Style/RedundantRegexpEscape:
128
+ Enabled: true
129
+
130
+ RSpec/MultipleExpectations:
131
+ Max: 5
132
+
133
+ RSpec/ExampleLength:
134
+ Max: 15
135
+
136
+ Rails/RakeEnvironment:
137
+ Enabled: false
data/.travis.yml CHANGED
@@ -1,50 +1,37 @@
1
1
  language: ruby
2
- sudo: false
3
2
  bundler_args: --binstubs
4
3
  cache: bundler
5
4
 
6
5
  rvm:
7
- - 2.6.3
8
- - 2.5.5
9
- - 2.4.6
10
- - jruby-9.2.6.0
6
+ - 3.0.1
7
+ - 2.7.3
8
+ - 2.6.7
9
+
10
+ services:
11
+ - postgresql
11
12
 
12
13
  env:
13
- global:
14
- - CC_TEST_REPORTER_ID=0a0e3e45118bc447e677d52c21d056a5471c4921d54f96ed7b2550d9fc5043ea
15
- matrix:
16
- - ACTIVE_RECORD_BRANCH="master"
17
- - ACTIVE_RECORD_BRANCH="5-2-stable"
18
- - ACTIVE_RECORD_VERSION="~> 6.0.0.beta1"
14
+ jobs:
15
+ - ACTIVE_RECORD_BRANCH="main"
16
+ - ACTIVE_RECORD_BRANCH="6-1-stable"
17
+ - ACTIVE_RECORD_BRANCH="6-0-stable"
18
+ - ACTIVE_RECORD_VERSION="~> 6.1.0"
19
+ - ACTIVE_RECORD_VERSION="~> 6.0.0"
19
20
  - ACTIVE_RECORD_VERSION="~> 5.2.0"
20
- - ACTIVE_RECORD_VERSION="~> 5.1.0"
21
- - ACTIVE_RECORD_VERSION="~> 5.0.0"
22
- - ACTIVE_RECORD_VERSION="~> 4.2.9"
23
21
 
24
- matrix:
22
+ jobs:
25
23
  allow_failures:
26
- - env: ACTIVE_RECORD_BRANCH="master"
27
- - env: ACTIVE_RECORD_BRANCH="5-2-stable"
28
- - env: ACTIVE_RECORD_VERSION="~> 6.0.0.beta1"
24
+ - env: ACTIVE_RECORD_BRANCH="main"
25
+ - env: ACTIVE_RECORD_BRANCH="6-0-stable"
26
+ - env: ACTIVE_RECORD_BRANCH="6-1-stable"
29
27
  exclude:
30
- - rvm: 2.4.6
31
- env: ACTIVE_RECORD_BRANCH="master"
32
- - rvm: jruby-9.2.6.0
33
- env: ACTIVE_RECORD_VERSION="~> 4.2.9"
34
- - rvm: 2.4.5
35
- env: ACTIVE_RECORD_VERSION="~> 6.0.0.beta1"
28
+ - rvm: 3.0.1
29
+ env: ACTIVE_RECORD_VERSION="~> 5.2.0"
30
+ - rvm: 2.6.7
31
+ env: ACTIVE_RECORD_BRANCH="main"
36
32
 
37
33
  before_script:
38
34
  - psql --version
39
35
  - psql -c 'create database pg_search_test;' -U postgres >/dev/null
40
- - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
41
- - chmod +x ./cc-test-reporter
42
- - ./cc-test-reporter before-build
43
36
 
44
37
  script: bin/rake
45
-
46
- after_script:
47
- - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
48
-
49
- addons:
50
- postgresql: "9.6"
data/CHANGELOG.md CHANGED
@@ -1,52 +1,86 @@
1
1
  # pg_search changelog
2
2
 
3
+ ## 2.3.6
4
+
5
+ * Drop support for Ruby 2.5
6
+ * Support Ruby 3.1
7
+ * Support Active Record 7.0
8
+ * Don't require `:against` if `:tsvector_column` is specified (Travis Hunter)
9
+ * Optionally disable transaction when rebuilding documents (Travis Hunter)
10
+ * Preserve columns when chaining ::with_pg_search_highlight (jcsanti)
11
+
12
+ ## 2.3.5
13
+
14
+ * Add table of contents to README (Barry Woolgar)
15
+ * Add support for Active Record 6.1
16
+
17
+ ## 2.3.4
18
+
19
+ * Fix issue when setting various options directly on the `PgSearch` module while
20
+ running with a threaded web server, such as Puma. (Anton Rieder)
21
+
22
+ ## 2.3.3
23
+
24
+ * Drop support for Ruby < 2.5.
25
+ * Use keyword argument for `clean_up` setting in `PgSearch::Multisearch.rebuild`.
26
+
27
+ ## 2.3.2
28
+
29
+ * Autoload `PgSearch::Document` to prevent it from being loaded in projects that are not using multi-search.
30
+ * Rebuilder should use `update_pg_search_document` if `additional_attributes` is set. (David Ramalho)
31
+
32
+ ## 2.3.1
33
+
34
+ * Drop support for Active Record < 5.2.
35
+ * Do not load railtie unless Rails::Railtie is defined, to avoid problem when loading alongside Action Mailer. (Adam Schwartz)
36
+
3
37
  ## 2.3.0
4
38
 
5
- * Extract `PgSearch::Model` module
39
+ * Extract `PgSearch::Model` module.
6
40
  * Deprecate `include PgSearch`. Use `include PgSearch::Model` instead.
7
41
 
8
42
  ## 2.2.0
9
43
 
10
- * Add word_similarity option to trigram search (Severin Räz)
44
+ * Add `word_similarity` option to trigram search. (Severin Räz)
11
45
 
12
46
  ## 2.1.7
13
47
 
14
- * Restore link to GitHub repository to original location
48
+ * Restore link to GitHub repository to original location.
15
49
 
16
50
  ## 2.1.6
17
51
 
18
- * Update link to GitHub repository to new location
52
+ * Update link to GitHub repository to new location.
19
53
 
20
54
  ## 2.1.5
21
55
 
22
- * Drop support for Ruby < 2.4
56
+ * Drop support for Ruby < 2.4.
23
57
 
24
58
  ## 2.1.4
25
59
 
26
- * Drop support for Ruby < 2.3
27
- * Use update instead of deprecated update_attributes
28
- * Remove explicit arel dependency to better support Active Record 6 beta
60
+ * Drop support for Ruby < 2.3.
61
+ * Use `update` instead of deprecated `update_attributes`.
62
+ * Remove explicit Arel dependency to better support Active Record 6 beta.
29
63
 
30
64
  ## 2.1.3
31
65
 
32
66
  * Drop support for Ruby < 2.2
33
- * Disallow left/right single quotation marks in tsquery (Fabian Schwahn) (#382)
34
- * Do not attempt to save an already-destroy PgSearch::Document (Oleg Dashevskii, Vokhmin Aleksei V) (#353)
35
- * Quote column name when rebuilding (Jed Levin) (#379)
67
+ * Disallow left/right single quotation marks in tsquery. (Fabian Schwahn) (#382)
68
+ * Do not attempt to save an already-destroyed `PgSearch::Document`. (Oleg Dashevskii, Vokhmin Aleksei V) (#353)
69
+ * Quote column name when rebuilding. (Jed Levin) (#379)
36
70
 
37
71
  ## 2.1.2
38
72
 
39
- * Silence warnings in Rails 5.2.0.beta2 (Kevin Deisz)
73
+ * Silence warnings in Rails 5.2.0.beta2. (Kevin Deisz)
40
74
 
41
75
  ## 2.1.1
42
76
 
43
- * Support snake_case ts_headline options again (with deprecation warning)
77
+ * Support snake_case `ts_headline` options again. (with deprecation warning)
44
78
 
45
79
  ## 2.1.0
46
80
 
47
- * Allow ts_headline options to be passed to :highlight (Ian Heisters)
48
- * Wait to load PgSearch::Document until after Active Record has loaded (Logan Leger)
49
- * Add Rails version to generated migrations (Erik Eide)
81
+ * Allow `ts_headline` options to be passed to `:highlight`. (Ian Heisters)
82
+ * Wait to load `PgSearch::Document` until after Active Record has loaded. (Logan Leger)
83
+ * Add Rails version to generated migrations. (Erik Eide)
50
84
 
51
85
  ## 2.0.1
52
86
 
@@ -0,0 +1,76 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, sex characteristics, gender identity and expression,
9
+ level of experience, education, socio-economic status, nationality, personal
10
+ appearance, race, religion, or sexual identity and orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at pg_search@nertzy.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72
+
73
+ [homepage]: https://www.contributor-covenant.org
74
+
75
+ For answers to common questions about this code of conduct, see
76
+ https://www.contributor-covenant.org/faq
data/Gemfile CHANGED
@@ -4,7 +4,7 @@ source 'https://rubygems.org'
4
4
 
5
5
  gemspec
6
6
 
7
- gem 'pg', '>= 0.21.0', '< 1.0.0', platform: :ruby
7
+ gem 'pg', '>= 0.21.0', platform: :ruby
8
8
  gem "activerecord-jdbcpostgresql-adapter", ">= 1.3.1", platform: :jruby
9
9
 
10
10
  if ENV['ACTIVE_RECORD_BRANCH']
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010-2019 Casebook, PBC <http://www.casebook.net>
1
+ Copyright (c) 2010-2021 Casebook, PBC <http://www.casebook.net>
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal