alchemy-pg_search 4.2.0 → 5.0.0

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
  SHA256:
3
- metadata.gz: b24390ba290061c913ce244c49cf38352d303bbd50e0855d2144517105ce6b53
4
- data.tar.gz: 963ed8b25276155ce526186eb07b12b8d616b60df0d0d98100c713ed12eddc1c
3
+ metadata.gz: 1896b14c7a0f65b1b14ca0f2de751ee14c68219bbd24893f6561725ab69fd622
4
+ data.tar.gz: 8e5759cd3d6f12f57c544ba5a2290d98f5600808f61b9e03e9ae3530a9e6aaaf
5
5
  SHA512:
6
- metadata.gz: 3acc723b3ae261ae52de6c1d59a6e2f727d870bb6849aa8ec461dd2eceaa8578cbc45df4562b5820316ff948210395921287b8391dc675ddaef8448012c980a9
7
- data.tar.gz: b203d53773796999d6f04fd27c8834121e872f359342eeec9cf97737cd487ddae1505f3df8c5f3c83793d9b406ad13f7f88ca1d184d8b1bf72f0d5600c6eb4ea
6
+ metadata.gz: 6fb5a90e1e4a562dd4c71cabbb91dc173be473e2eb2100fe83b0d317f6c6120bf2af66589a369fd0a39355f3996811e80e2399320c7e19c44eb6f1ac8e5c0830
7
+ data.tar.gz: cc3d81d2e4e798b57e47109890b8e97f40a12c16e33446887789ee3f5aa377d68ab4c58430834adfc2e75f2b12f4a57afa6348d2372af9464a91658dc5d84570
@@ -21,7 +21,7 @@ jobs:
21
21
  - name: Set up Ruby
22
22
  uses: ruby/setup-ruby@v1
23
23
  with:
24
- ruby-version: 2.7
24
+ ruby-version: 3.2
25
25
  bundler-cache: true
26
26
  - name: Prepare database
27
27
  run: bundle exec rake alchemy:spec:prepare
data/.gitignore CHANGED
@@ -6,6 +6,8 @@ Gemfile.lock
6
6
  spec/dummy/log/*.log
7
7
  spec/dummy/db/*.sqlite3*
8
8
  spec/dummy/tmp/*
9
+ spec/dummy/public/*
10
+ spec/dummy/uploads/*
9
11
  .ruby-*
10
12
  node_modules
11
13
  yarn.lock
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## [v5.0.0](https://github.com/AlchemyCMS/alchemy-pg_search/tree/v5.0.0) (2023-09-01)
4
+
5
+ [Full Changelog](https://github.com/AlchemyCMS/alchemy-pg_search/compare/v4.2.0...v5.0.0)
6
+
7
+ **Merged pull requests:**
8
+
9
+ - Update to Alchemy 7.0 [\#39](https://github.com/AlchemyCMS/alchemy-pg_search/pull/39) ([sascha-karnatz](https://github.com/sascha-karnatz))
10
+
3
11
  ## [v4.2.0](https://github.com/AlchemyCMS/alchemy-pg_search/tree/v4.2.0) (2023-01-23)
4
12
 
5
13
  [Full Changelog](https://github.com/AlchemyCMS/alchemy-pg_search/compare/v4.1.1...v4.2.0)
data/Gemfile CHANGED
@@ -2,13 +2,11 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem "rails", "~> 6.0.0"
6
- ENV.fetch("ALCHEMY_BRANCH", "6.1-stable").tap do |branch|
7
- gem "alchemy_cms", github: "AlchemyCMS/alchemy_cms", branch: branch
8
- end
5
+ gem "rails", "~> 7.0.0"
6
+ gem "alchemy_cms", "~> 7.0.0"
7
+
9
8
  gem "sassc-rails"
10
9
  gem "sassc", "~> 2.4.0"
11
- gem "webpacker"
12
10
  gem "pg", "~> 1.0"
13
11
  gem "puma"
14
12
 
data/README.md CHANGED
@@ -26,7 +26,7 @@ $ bin/rails g alchemy:pg_search:install
26
26
 
27
27
  ## Usage
28
28
 
29
- Every `EssenceText`, `EssenceRichtext` and `EssencePicture` will be indexed unless you tell Alchemy to not index a specific content.
29
+ Every `Ingredient` will be indexed unless you tell Alchemy to not index a specific content.
30
30
 
31
31
  ### Disable Indexing
32
32
 
@@ -51,7 +51,7 @@ Pass `searchable: false` to your element definitions and Alchemy will not index
51
51
  - name: secret_sauce
52
52
  searchable: false
53
53
  ingredients:
54
- - name: sauce
54
+ - role: sauce
55
55
  type: Text
56
56
  default: 'This is my secret sauce.'
57
57
  ```
@@ -63,9 +63,9 @@ Pass `searchable: false` to your content definitions and Alchemy will not index
63
63
  ```yaml
64
64
  # elements.yml
65
65
  - name: secrets
66
- contents:
67
- - name: passwords
68
- type: EssenceText
66
+ ingredients:
67
+ - role: passwords
68
+ type: Text
69
69
  searchable: false
70
70
  default: 'This is my secret password.'
71
71
  ```
@@ -76,7 +76,7 @@ The same works for `ingredients` as well
76
76
  # elements.yml
77
77
  - name: secrets
78
78
  ingredients:
79
- - name: passwords
79
+ - role: passwords
80
80
  type: Text
81
81
  searchable: false
82
82
  default: 'This is my secret password.'
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^spec/}) }
17
17
  spec.require_paths = ["lib"]
18
18
 
19
- spec.add_runtime_dependency "alchemy_cms", [">= 6.1", "< 7"]
19
+ spec.add_runtime_dependency "alchemy_cms", [">= 7.0", "< 8"]
20
20
  spec.add_runtime_dependency "pg_search", ["~> 2.1"]
21
21
  spec.add_runtime_dependency "pg"
22
22
 
@@ -1,13 +1,18 @@
1
1
  module Alchemy::PgSearch::IngredientExtension
2
- def self.prepended(base)
3
- base.include PgSearch::Model
4
- base.multisearchable(
2
+
3
+ def self.multisearch_config
4
+ {
5
5
  against: [
6
6
  :value,
7
7
  ],
8
8
  additional_attributes: ->(ingredient) { { page_id: ingredient.element.page.id } },
9
- if: :searchable?,
10
- )
9
+ if: :searchable?
10
+ }
11
+ end
12
+
13
+ def self.prepended(base)
14
+ base.include PgSearch::Model
15
+ base.multisearchable(multisearch_config)
11
16
  end
12
17
 
13
18
  def searchable?
@@ -17,4 +22,8 @@ module Alchemy::PgSearch::IngredientExtension
17
22
  end
18
23
  end
19
24
 
25
+ # add the PgSearch model to all ingredients
20
26
  Alchemy::Ingredient.prepend(Alchemy::PgSearch::IngredientExtension)
27
+
28
+ # only enable the search for Text, Richtext, and Picture
29
+ Alchemy::Ingredients::Picture.multisearchable(Alchemy::PgSearch::IngredientExtension.multisearch_config.merge({against: [:caption]}))
@@ -5,7 +5,7 @@ module Alchemy
5
5
  ##
6
6
  # index all supported Alchemy models
7
7
  def self.rebuild
8
- ([Alchemy::Page, Alchemy::Ingredient] + Alchemy::PgSearch.searchable_essence_classes).each do |model|
8
+ [Alchemy::Page, Alchemy::Ingredient].each do |model|
9
9
  ::PgSearch::Multisearch.rebuild(model)
10
10
  end
11
11
  end
@@ -19,20 +19,16 @@ module Alchemy
19
19
  end
20
20
 
21
21
  ##
22
- # index a single page and indexable essences
22
+ # index a single page and indexable ingredients
23
23
  #
24
24
  # @param page [Alchemy::Page]
25
25
  def self.index_page(page)
26
26
  remove_page page
27
27
 
28
28
  page.update_pg_search_document
29
- page.all_elements.includes(:ingredients, contents: :essence).find_each do |element|
30
- element.contents.each do |content|
31
- content.essence.update_pg_search_document if Alchemy::PgSearch.is_searchable?(content.essence_type)
32
- end
33
-
34
- element.ingredients.each do |ingredient|
35
- ingredient.update_pg_search_document if Alchemy::PgSearch.is_searchable?(ingredient.type)
29
+ page.all_elements.includes(:ingredients).find_each do |element|
30
+ element.ingredients.select { |i| Alchemy::PgSearch.is_searchable?(i.type) }.each do |ingredient|
31
+ ingredient.update_pg_search_document
36
32
  end
37
33
  end
38
34
  end
@@ -1,5 +1,5 @@
1
1
  module Alchemy
2
2
  module PgSearch
3
- VERSION = "4.2.0"
3
+ VERSION = "5.0.0"
4
4
  end
5
5
  end
@@ -9,18 +9,11 @@ module Alchemy
9
9
  extend Config
10
10
 
11
11
  ##
12
- # is essence or ingredient searchable?
13
- # @param essence_type [string]
12
+ # is ingredient searchable?
13
+ # @param ingredient_type [string]
14
14
  # @return [boolean]
15
- def self.is_searchable?(essence_type)
16
- SEARCHABLE_INGREDIENTS.include?(essence_type.gsub(/Alchemy::(Essence|Ingredients::)/, ""))
17
- end
18
-
19
- ##
20
- # generate an array of all supported essences classes
21
- # @return [array]
22
- def self.searchable_essence_classes
23
- SEARCHABLE_INGREDIENTS.map { |k| "Alchemy::Essence#{k.classify}".constantize }
15
+ def self.is_searchable?(ingredient_type)
16
+ SEARCHABLE_INGREDIENTS.include?(ingredient_type.gsub(/Alchemy::Ingredients::/, ""))
24
17
  end
25
18
 
26
19
  ##
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alchemy-pg_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.0
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas von Deyen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-23 00:00:00.000000000 Z
11
+ date: 2023-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: alchemy_cms
@@ -16,20 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '6.1'
19
+ version: '7.0'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '7'
22
+ version: '8'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '6.1'
29
+ version: '7.0'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '7'
32
+ version: '8'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: pg_search
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -116,11 +116,7 @@ files:
116
116
  - Rakefile
117
117
  - alchemy-pg_search.gemspec
118
118
  - app/controller/alchemy/pg_search/controller_methods.rb
119
- - app/extensions/alchemy/pg_search/content_extension.rb
120
119
  - app/extensions/alchemy/pg_search/element_extension.rb
121
- - app/extensions/alchemy/pg_search/essence_picture_extension.rb
122
- - app/extensions/alchemy/pg_search/essence_richtext_extension.rb
123
- - app/extensions/alchemy/pg_search/essence_text_extension.rb
124
120
  - app/extensions/alchemy/pg_search/ingredient_extension.rb
125
121
  - app/extensions/alchemy/pg_search/page_extension.rb
126
122
  - app/extensions/alchemy/pg_search/pg_search_document_extension.rb
@@ -165,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
161
  - !ruby/object:Gem::Version
166
162
  version: '0'
167
163
  requirements: []
168
- rubygems_version: 3.1.6
164
+ rubygems_version: 3.4.17
169
165
  signing_key:
170
166
  specification_version: 4
171
167
  summary: This gem provides PostgreSQL full text search to Alchemy
@@ -1,19 +0,0 @@
1
- module Alchemy::PgSearch::ContentExtension
2
- module ClassMethods
3
- def new(attributes)
4
- super.tap do |content|
5
- content.searchable = content.definition.key?(:searchable) ? content.definition[:searchable] : true
6
- end
7
- end
8
-
9
- Alchemy::Content.singleton_class.prepend self
10
- end
11
-
12
- module InstanceMethods
13
- def searchable?
14
- searchable && element.searchable?
15
- end
16
-
17
- Alchemy::Content.prepend self
18
- end
19
- end
@@ -1,19 +0,0 @@
1
- module Alchemy::PgSearch::EssencePictureExtension
2
-
3
- def self.prepended(base)
4
- base.include PgSearch::Model
5
- base.multisearchable(
6
- against: [
7
- :caption
8
- ],
9
- additional_attributes: -> (essence_picture) { { page_id: essence_picture.page.id } },
10
- if: :searchable?
11
- )
12
- end
13
-
14
- def searchable?
15
- caption.present? && !!content&.searchable?
16
- end
17
- end
18
-
19
- Alchemy::EssencePicture.prepend(Alchemy::PgSearch::EssencePictureExtension)
@@ -1,20 +0,0 @@
1
- module Alchemy::PgSearch::EssenceRichtextExtension
2
-
3
- def self.prepended(base)
4
- base.include PgSearch::Model
5
- base.multisearchable(
6
- against: [
7
- :stripped_body
8
- ],
9
- additional_attributes: -> (essence_richtext) { { page_id: essence_richtext.page.id } },
10
- if: :searchable?
11
- )
12
- end
13
-
14
- def searchable?
15
- stripped_body.present? && !!content&.searchable?
16
- end
17
- end
18
-
19
- Alchemy::EssenceRichtext.prepend(Alchemy::PgSearch::EssenceRichtextExtension)
20
-
@@ -1,19 +0,0 @@
1
- module Alchemy::PgSearch::EssenceTextExtension
2
- def self.prepended(base)
3
- base.include PgSearch::Model
4
- base.multisearchable(
5
- against: [
6
- :body
7
- ],
8
- additional_attributes: -> (essence_text) { { page_id: essence_text.page.id } },
9
- if: :searchable?
10
- )
11
- end
12
-
13
- def searchable?
14
- body.present? && !!content&.searchable?
15
- end
16
- end
17
-
18
- Alchemy::EssenceText.prepend(Alchemy::PgSearch::EssenceTextExtension)
19
-