Skip to content

Commit

Permalink
Merge branch 'master' into feature/json-support
Browse files Browse the repository at this point in the history
  • Loading branch information
nertzy authored May 8, 2023
2 parents 6710bed + 17c0b34 commit 0a4f9f1
Show file tree
Hide file tree
Showing 36 changed files with 622 additions and 708 deletions.
18 changes: 5 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,33 +36,25 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby-version: ['2.7', '3.0', '3.1']
ruby-version: ['2.7', '3.0', '3.1', '3.2']
active-record-version-env:
- ACTIVE_RECORD_VERSION="~> 5.2.0"
- ACTIVE_RECORD_VERSION="~> 6.0.0"
- ACTIVE_RECORD_VERSION="~> 6.1.0"
- ACTIVE_RECORD_VERSION="~> 7.0.0"
allow-failure: [false]
include:
- ruby-version: '3.1'
- ruby-version: '3.2'
active-record-version-env: ACTIVE_RECORD_BRANCH="main"
allow-failure: true
- ruby-version: '3.1'
- ruby-version: '3.2'
active-record-version-env: ACTIVE_RECORD_BRANCH="7-0-stable"
allow-failure: true
- ruby-version: '3.1'
- ruby-version: '3.2'
active-record-version-env: ACTIVE_RECORD_BRANCH="6-1-stable"
allow-failure: true
exclude:
- ruby-version: '3.0'
active-record-version-env: ACTIVE_RECORD_VERSION="~> 5.2.0"
allow-failure: false
- ruby-version: '3.1'
active-record-version-env: ACTIVE_RECORD_VERSION="~> 5.2.0"
allow-failure: false
continue-on-error: ${{ matrix.allow-failure }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
Expand Down
125 changes: 11 additions & 114 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,137 +1,34 @@
require:
- standard
- rubocop-performance
- rubocop-rails
- rubocop-rake
- rubocop-rspec

inherit_gem:
standard: config/base.yml

AllCops:
TargetRubyVersion: 2.7
NewCops: enable
NewCops: disable
Exclude:
- bin/**/*
- vendor/**/*

Style/StringLiterals:
Enabled: false

Layout/LineLength:
Max: 120

Metrics/MethodLength:
Max: 15

Metrics/BlockLength:
Exclude:
- spec/**/*

Layout/ParameterAlignment:
EnforcedStyle: with_fixed_indentation

Style/NumericPredicate:
Enabled: false

Style/PercentLiteralDelimiters:
PreferredDelimiters:
'%w': '[]'
'%W': '[]'

Style/GuardClause:
Enabled: false

Naming/VariableNumber:
EnforcedStyle: snake_case

Bundler/OrderedGems:
Enabled: false

Bundler/DuplicatedGem:
Enabled: false

Style/EmptyMethod:
EnforcedStyle: expanded

Layout/FirstArrayElementIndentation:
EnforcedStyle: consistent

Style/Documentation:
Enabled: false

Style/WordArray:
EnforcedStyle: percent
MinSize: 3

Style/HashEachMethods:
Lint/RedundantCopDisableDirective:
Enabled: true

Style/HashTransformKeys:
Lint/RedundantCopEnableDirective:
Enabled: true

Style/HashTransformValues:
Enabled: true

Rails/ApplicationRecord:
Bundler/DuplicatedGem:
Enabled: false

Rails/TimeZone:
Rails/ApplicationRecord:
Enabled: false

RSpec/ContextWording:
Prefixes:
- using
- via
- when
- with
- without

Lint/RaiseException:
Enabled: true

Lint/StructNewOverride:
Enabled: true

Layout/SpaceAroundMethodCallOperator:
Enabled: true

Style/ExponentialNotation:
Enabled: true

RSpec/DescribedClass:
Enabled: true

RSpec/ExpectInHook:
Rails/RakeEnvironment:
Enabled: false

RSpec/FilePath:
CustomTransform:
TSearch: "tsearch"
DMetaphone: "dmetaphone"

Layout/EmptyLinesAroundAttributeAccessor:
Enabled: true

Lint/DeprecatedOpenSSLConstant:
Enabled: true

Style/SlicingWithRange:
Enabled: true

Lint/MixedRegexpCaptureTypes:
Enabled: true

Style/RedundantFetchBlock:
Enabled: true

Style/RedundantRegexpCharacterClass:
Enabled: true

Style/RedundantRegexpEscape:
Enabled: true

RSpec/MultipleExpectations:
Max: 5

RSpec/ExampleLength:
Max: 15

Rails/RakeEnvironment:
Rails/TimeZone:
Enabled: false
27 changes: 21 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
# frozen_string_literal: true

source 'https://rubygems.org'
source "https://rubygems.org"

gemspec

gem 'pg', '>= 0.21.0', platform: :ruby
gem "pg", ">= 0.21.0", platform: :ruby
gem "activerecord-jdbcpostgresql-adapter", ">= 1.3.1", platform: :jruby

if ENV['ACTIVE_RECORD_BRANCH']
gem 'activerecord', git: 'https://github.com/rails/rails.git', branch: ENV.fetch('ACTIVE_RECORD_BRANCH', nil)
gem 'arel', git: 'https://github.com/rails/arel.git' if ENV.fetch('ACTIVE_RECORD_BRANCH', nil) == 'master'
if ENV["ACTIVE_RECORD_BRANCH"]
gem "activerecord", git: "https://github.com/rails/rails.git", branch: ENV.fetch("ACTIVE_RECORD_BRANCH", nil)
gem "arel", git: "https://github.com/rails/arel.git" if ENV.fetch("ACTIVE_RECORD_BRANCH", nil) == "master"
end

gem 'activerecord', ENV.fetch('ACTIVE_RECORD_VERSION', nil) if ENV['ACTIVE_RECORD_VERSION']
gem "activerecord", ENV.fetch("ACTIVE_RECORD_VERSION", nil) if ENV["ACTIVE_RECORD_VERSION"]

gem "pry"
gem "rake"
gem "rspec"
gem "rubocop"
gem "rubocop-performance"
gem "rubocop-rails"
gem "rubocop-rake"
gem "rubocop-rspec"
gem "simplecov"
gem "simplecov-lcov"
gem "standard", ">= 1.23.0"
gem "undercover"
gem "warning"
gem "with_model"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Read the blog post introducing PgSearch at https://tanzu.vmware.com/content/blog
## REQUIREMENTS

* Ruby 2.7+
* ActiveRecord 5.2+
* Active Record 6.0+
* PostgreSQL 9.2+
* [PostgreSQL extensions](https://github.com/Casecommons/pg_search/wiki/Installing-PostgreSQL-Extensions) for certain features

Expand Down
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# frozen_string_literal: true

require 'bundler'
require "bundler"
Bundler::GemHelper.install_tasks

require 'rspec/core/rake_task'
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec)

require "rubocop/rake_task"
Expand Down
2 changes: 1 addition & 1 deletion lib/pg_search/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def order_within_rank
attr_reader :options

def default_options
{ using: :tsearch }
{using: :tsearch}
end

VALID_KEYS = %w[
Expand Down
2 changes: 1 addition & 1 deletion lib/pg_search/configuration/column.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require 'digest'
require "digest"

module PgSearch
class Configuration
Expand Down
2 changes: 1 addition & 1 deletion lib/pg_search/configuration/foreign_column.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require 'digest'
require "digest"

module PgSearch
class Configuration
Expand Down
14 changes: 7 additions & 7 deletions lib/pg_search/document.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# frozen_string_literal: true

require 'logger'
require "logger"

module PgSearch
class Document < ActiveRecord::Base
include PgSearch::Model

self.table_name = 'pg_search_documents'
self.table_name = "pg_search_documents"
belongs_to :searchable, polymorphic: true

# The logger might not have loaded yet.
Expand All @@ -17,12 +17,12 @@ def self.logger

pg_search_scope :search, lambda { |*args|
options = if PgSearch.multisearch_options.respond_to?(:call)
PgSearch.multisearch_options.call(*args)
else
{ query: args.first }.merge(PgSearch.multisearch_options)
end
PgSearch.multisearch_options.call(*args)
else
{query: args.first}.merge(PgSearch.multisearch_options)
end

{ against: :content }.merge(options)
{against: :content}.merge(options)
}
end
end
2 changes: 1 addition & 1 deletion lib/pg_search/features/dmetaphone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Features
class DMetaphone
def initialize(query, options, columns, model, normalizer)
dmetaphone_normalizer = Normalizer.new(normalizer)
options = (options || {}).merge(dictionary: 'simple')
options = (options || {}).merge(dictionary: "simple")
@tsearch = TSearch.new(query, options, columns, model, dmetaphone_normalizer)
end

Expand Down
8 changes: 4 additions & 4 deletions lib/pg_search/features/trigram.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ def word_similarity?

def similarity_function
if word_similarity?
'word_similarity'
"word_similarity"
else
'similarity'
"similarity"
end
end

def infix_operator
if word_similarity?
'<%'
"<%"
else
'%'
"%"
end
end

Expand Down
Loading

0 comments on commit 0a4f9f1

Please sign in to comment.