alchemy-pg_search 2.1.0 → 2.4.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: a799a278783ba0529bff4fe80e0b2125de5b126dcd5b64791adfc0b54c6e157e
4
- data.tar.gz: 8aefcd02fb869d1d1eea9e16b0777f204a74e0c18331501374b3004edc993054
3
+ metadata.gz: 9549e748d89548023d9df7829e219fa3b6a407d3b5ad002029b4ec36b26301a1
4
+ data.tar.gz: 615172e174163bd0edc420040750e849d9b8655277c9b7d6418187e5442fde22
5
5
  SHA512:
6
- metadata.gz: 10d52b3ad7a394f7d1835087d15552cf0f280b85ef5521dc6066fce35685a2bf5cbd25b0850135852a5d2de0333a4c6ec6d63c3b46e5b0b8e97eab3a46f97cc9
7
- data.tar.gz: 6ecc6d9b7827167b43a110c39261a568002b57eaf87b1618aabb8d5272e803ed1e97a9cf2591cd71dac9a09970bbfe2b0946c9018cc2739f1cdd766f730a8cd3
6
+ metadata.gz: dbbb491dc844fedaf74efbebfa67f4ae03d6288e18b70dae0d6cdac0e2a5664bc756fcd1f47ed236c3abc959703ee183f8b643f0d4698f7c1a3e1430cd216628
7
+ data.tar.gz: c3870c31a905d108a9f4faf39335ab9ad59bd5246962671c570c93ab8d4d1ea50da35c6bc12491db76b021cc403e5ec11938716c41d61b9de26647850a36f665
@@ -0,0 +1,29 @@
1
+ name: CI
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ RSpec:
7
+ runs-on: ubuntu-latest
8
+ env:
9
+ RAILS_ENV: test
10
+ services:
11
+ postgres:
12
+ image: postgres:11
13
+ env:
14
+ POSTGRES_USER: postgres
15
+ POSTGRES_PASSWORD: password
16
+ POSTGRES_DB: alchemy_pg_search_test
17
+ ports: ["5432:5432"]
18
+ options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
19
+ steps:
20
+ - uses: actions/checkout@v2.3.4
21
+ - name: Set up Ruby
22
+ uses: ruby/setup-ruby@v1
23
+ with:
24
+ ruby-version: 2.7
25
+ bundler-cache: true
26
+ - name: Prepare database
27
+ run: bundle exec rake alchemy:spec:prepare
28
+ - name: Run tests
29
+ run: bundle exec rspec
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## 2.4.0 (2022-06-06)
2
+
3
+ - Add support for Alchemy 5.2 [#25](https://github.com/AlchemyCMS/alchemy-pg_search/pull/25) by [kulturbande](https://github.com/kulturbande)
4
+
5
+ ## 2.3.0 (2022-03-04)
6
+
7
+ - Add support for Alchemy 5.1 [#24](https://github.com/AlchemyCMS/alchemy-pg_search/pull/24) by [kulturbande](https://github.com/kulturbande)
8
+
9
+ ## 2.2.0 (2021-09-25)
10
+
11
+ - Alchemy 4.3 [#21](https://github.com/AlchemyCMS/alchemy-pg_search/pull/21) by [tvdeyen](https://github.com/tvdeyen)
12
+
1
13
  ## 2.1.0 (2021-09-25)
2
14
 
3
15
  - Do not allow Alchemy 4.3 and above [#22](https://github.com/AlchemyCMS/alchemy-pg_search/pull/22) by [tvdeyen](https://github.com/tvdeyen)
data/Gemfile CHANGED
@@ -2,11 +2,14 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem "rails", "~> 5.1.0"
6
- gem "alchemy_cms", github: "AlchemyCMS/alchemy_cms", branch: "4.0-stable"
5
+ gem "rails", "~> 6.0.0"
6
+ ENV.fetch("ALCHEMY_BRANCH", "5.3-stable").tap do |branch|
7
+ gem "alchemy_cms", github: "AlchemyCMS/alchemy_cms", branch: branch
8
+ end
7
9
  gem "sassc-rails"
8
- gem "sassc", "< 2.2.0"
9
- gem "pg", "< 1.0"
10
+ gem "sassc", "~> 2.4.0"
11
+ gem "webpacker"
12
+ gem "pg", "~> 1.0"
10
13
  gem "puma"
11
14
 
12
15
  group :test do
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Build Status](https://travis-ci.org/AlchemyCMS/alchemy-pg_search.svg?branch=main)](https://travis-ci.org/AlchemyCMS/alchemy-pg_search)
1
+ [![CI](https://github.com/AlchemyCMS/alchemy-pg_search/actions/workflows/ci.yml/badge.svg)](https://github.com/AlchemyCMS/alchemy-pg_search/actions/workflows/ci.yml)
2
2
 
3
3
  # Alchemy CMS Postgresql Fulltext Search
4
4
 
@@ -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", [">= 4.0", "< 4.3"]
19
+ spec.add_runtime_dependency "alchemy_cms", [">= 4.3", "< 6"]
20
20
  spec.add_runtime_dependency "pg_search", ["~> 2.1"]
21
21
  spec.add_runtime_dependency "pg"
22
22
 
@@ -1,7 +1,8 @@
1
1
  module Alchemy::PgSearch::ContentExtension
2
2
  module ClassMethods
3
- def build(element, essence_hash)
4
- definition = content_definition(element, essence_hash)
3
+ def new(attributes)
4
+ element = attributes[:element]
5
+ definition = element.content_definition_for(attributes[:name])
5
6
  super.tap do |content|
6
7
  content.searchable = definition.key?(:searchable) ? definition[:searchable] : true
7
8
  end
@@ -1,58 +1,54 @@
1
- Alchemy::Page.class_eval do
2
- include PgSearch::Model
1
+ # Enable Postgresql full text indexing.
2
+ #
3
+ module Alchemy::PgSearch::PageExtension
4
+ def self.extended(base)
5
+ base.include InstanceMethods
6
+ base.include PgSearch::Model
3
7
 
4
- # Enable Postgresql full text indexing.
5
- #
6
- pg_search_scope :full_text_search,
7
- against: {
8
- meta_description: "B",
9
- meta_keywords: "B",
10
- title: "B",
11
- name: "A",
12
- },
13
- associated_against: {
14
- searchable_essence_texts: :body,
15
- searchable_essence_richtexts: :stripped_body,
16
- searchable_essence_pictures: :caption,
17
- },
18
- using: {
19
- tsearch: { prefix: true },
20
- }
8
+ base.pg_search_scope(
9
+ :full_text_search,
10
+ against: {
11
+ meta_description: "B",
12
+ meta_keywords: "B",
13
+ title: "B",
14
+ name: "A",
15
+ },
16
+ associated_against: {
17
+ searchable_essence_texts: :body,
18
+ searchable_essence_richtexts: :stripped_body,
19
+ searchable_essence_pictures: :caption,
20
+ },
21
+ using: {
22
+ tsearch: { prefix: true },
23
+ },
24
+ )
21
25
 
22
- has_many :searchable_essence_texts,
23
- -> {
24
- includes(:element)
25
- .where(alchemy_contents: { searchable: true })
26
- .where(alchemy_elements: { public: true })
27
- },
28
- class_name: "Alchemy::EssenceText",
29
- source_type: "Alchemy::EssenceText",
30
- through: :descendent_contents,
31
- source: :essence
26
+ base.has_many(
27
+ :searchable_contents,
28
+ -> {
29
+ where(alchemy_elements: { public: true })
30
+ .where(searchable: true)
31
+ },
32
+ class_name: "Alchemy::Content",
33
+ through: :all_elements,
34
+ )
32
35
 
33
- has_many :searchable_essence_richtexts,
34
- -> {
35
- includes(:element)
36
- .where(alchemy_contents: { searchable: true })
37
- .where(alchemy_elements: { public: true })
38
- },
39
- class_name: "Alchemy::EssenceRichtext",
40
- source_type: "Alchemy::EssenceRichtext",
41
- through: :descendent_contents,
42
- source: :essence
43
-
44
- has_many :searchable_essence_pictures,
45
- -> {
46
- includes(:element)
47
- .where(alchemy_contents: { searchable: true })
48
- .where(alchemy_elements: { public: true })
49
- },
50
- class_name: "Alchemy::EssencePicture",
51
- source_type: "Alchemy::EssencePicture",
52
- through: :descendent_contents,
53
- source: :essence
36
+ Alchemy::PgSearch::SEARCHABLE_ESSENCES.each do |klass|
37
+ base.has_many(
38
+ :"searchable_#{klass.underscore.pluralize}",
39
+ class_name: "Alchemy::#{klass}",
40
+ source_type: "Alchemy::#{klass}",
41
+ through: :searchable_contents,
42
+ source: :essence,
43
+ )
44
+ end
45
+ end
54
46
 
55
- def element_search_results(query)
56
- descendent_elements.full_text_search(query)
47
+ module InstanceMethods
48
+ def element_search_results(query)
49
+ all_elements.full_text_search(query)
50
+ end
57
51
  end
52
+
53
+ Alchemy::Page.extend self
58
54
  end
@@ -1,5 +1,5 @@
1
1
  module Alchemy
2
2
  module PgSearch
3
- VERSION = "2.1.0"
3
+ VERSION = "2.4.0"
4
4
  end
5
5
  end
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: 2.1.0
4
+ version: 2.4.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: 2021-09-25 00:00:00.000000000 Z
11
+ date: 2022-06-06 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: '4.0'
19
+ version: '4.3'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '4.3'
22
+ version: '6'
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: '4.0'
29
+ version: '4.3'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '4.3'
32
+ version: '6'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: pg_search
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -107,8 +107,8 @@ executables: []
107
107
  extensions: []
108
108
  extra_rdoc_files: []
109
109
  files:
110
+ - ".github/workflows/ci.yml"
110
111
  - ".gitignore"
111
- - ".travis.yml"
112
112
  - CHANGELOG.md
113
113
  - Gemfile
114
114
  - LICENSE
@@ -159,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
159
  - !ruby/object:Gem::Version
160
160
  version: '0'
161
161
  requirements: []
162
- rubygems_version: 3.2.28
162
+ rubygems_version: 3.1.6
163
163
  signing_key:
164
164
  specification_version: 4
165
165
  summary: This gem provides PostgreSQL full text search to Alchemy 4.0
data/.travis.yml DELETED
@@ -1,13 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.5
5
- services:
6
- - postgresql
7
- cache:
8
- - bundler
9
- branches:
10
- only:
11
- - main
12
- before_script: bundle exec rake alchemy:spec:prepare
13
- script: bundle exec rspec