Skip to content

Commit 5640b53

Browse files
committed
update to newer version of ruby and fix cops
1 parent c8a2b20 commit 5640b53

File tree

9 files changed

+24
-24
lines changed

9 files changed

+24
-24
lines changed

.github/workflows/rubocop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ jobs:
88
- name: Set up Ruby
99
uses: ruby/setup-ruby@v1
1010
with:
11-
ruby-version: 2.7
11+
ruby-version: '3.0'
1212
bundler-cache: true
1313
- run: bundle exec rubocop

.github/workflows/test.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ jobs:
99
fail-fast: false
1010
matrix:
1111
entry:
12-
- { ruby: '2.7.1', mongo: 'mongo:4.4', mongoid: '6' }
13-
- { ruby: '3.0.5', mongo: 'mongo:4.4', mongoid: '6' }
14-
- { ruby: '3.1.3', mongo: 'mongo:4.4', mongoid: '6' }
15-
- { ruby: '2.7.1', mongo: 'mongo:4.4', mongoid: '7' }
16-
- { ruby: '3.0.5', mongo: 'mongo:4.4', mongoid: '7' }
17-
- { ruby: '3.1.3', mongo: 'mongo:4.4', mongoid: '7' }
18-
- { ruby: '2.7.1', mongo: 'mongo:4.4', mongoid: '8' }
19-
- { ruby: '3.0.5', mongo: 'mongo:4.4', mongoid: '8' }
20-
- { ruby: '3.1.3', mongo: 'mongo:4.4', mongoid: '8' }
12+
- { ruby: '3.0.7', mongo: 'mongo:4.4', mongoid: '6' }
13+
- { ruby: '3.1.7', mongo: 'mongo:4.4', mongoid: '6' }
14+
- { ruby: '3.2.10', mongo: 'mongo:4.4', mongoid: '6' }
15+
- { ruby: '3.0.7', mongo: 'mongo:4.4', mongoid: '7' }
16+
- { ruby: '3.1.7', mongo: 'mongo:4.4', mongoid: '7' }
17+
- { ruby: '3.2.10', mongo: 'mongo:4.4', mongoid: '7' }
18+
- { ruby: '3.0.7', mongo: 'mongo:4.4', mongoid: '8' }
19+
- { ruby: '3.1.7', mongo: 'mongo:4.4', mongoid: '8' }
20+
- { ruby: '3.2.10', mongo: 'mongo:4.4', mongoid: '8' }
2121
experimental: [false]
2222

2323
name: test (ruby=${{ matrix.entry.ruby }}, mongo=${{ matrix.entry.mongo }}, mongoid=${{ matrix.entry.mongoid }})

.rubocop.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
AllCops:
2-
TargetRubyVersion: 2.7
2+
TargetRubyVersion: 3.0
3+
NewCops: enable
34
Exclude:
45
- vendor/**/*
56
-Metrics/BlockLength:

Gemfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ else
1818
end
1919

2020
group :development do
21+
gem 'database_cleaner-mongoid', '>= 2.0.0'
22+
gem 'mongoid-compatibility'
2123
gem 'rake', '>= 12.3.3'
24+
gem 'rspec', '~> 3.1'
2225
gem 'rubocop', '1.56.0'
2326
gem 'simplecov'
2427
end

lib/mongoid_search/mongoid_search.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def search_without_relevance(query, options)
9494
end
9595

9696
def search_relevant(query, options)
97-
results_with_relevance(query, options).sort { |o| o['value'] }.map do |r|
97+
results_with_relevance(query, options).sort_by { |o| o['value'] }.map do |r|
9898
new(r['_id'].merge(relevance: r['value'])) do |o|
9999
# Need to match the actual object
100100
o.instance_variable_set('@new_record', false)

lib/mongoid_search/tasks/mongoid_search.rake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
namespace :mongoid_search do
44
desc 'Goes through all documents with search enabled and indexes the keywords.'
55
task index: :environment do
6-
::Rails.application.eager_load!
6+
Rails.application.eager_load!
77
if Mongoid::Search.classes.blank?
88
Mongoid::Search::Log.log "No model to index keywords.\n"
99
else
1010
Mongoid::Search.classes.each do |klass|
11-
Mongoid::Search::Log.silent = ENV['SILENT']
11+
Mongoid::Search::Log.silent = ENV.fetch('SILENT', nil)
1212
Mongoid::Search::Log.log "\nIndexing documents for #{klass.name}:\n"
1313
klass.index_keywords!
1414
end

lib/mongoid_search/util.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ def self.normalize_keywords(text)
4646
.to_s
4747
.gsub(strip_symbols, ' ') # strip symbols
4848
.gsub(strip_accents, '') # strip accents
49-
.gsub(/[#{ligatures.keys.join('')}]/) { |c| ligatures[c] }
50-
.split(' ')
49+
.gsub(/[#{ligatures.keys.join}]/) { |c| ligatures[c] }
50+
.split
5151
.reject { |word| word.size < Mongoid::Search.minimum_word_size }
5252
text = text.reject { |word| ignore_list.include?(word) } unless ignore_list.blank?
5353
text = text.map(&stem_proc) if stem_keywords

mongoid_search.gemspec

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,14 @@ Gem::Specification.new do |s|
1414
s.license = 'MIT'
1515

1616
s.required_rubygems_version = '>= 1.3.6'
17-
s.required_ruby_version = '>= 2.7'
17+
s.required_ruby_version = '>= 3.0'
1818

1919
s.platform = 'ruby'
2020

2121
s.add_dependency('fast-stemmer', ['~> 1.0.0'])
22-
s.add_dependency('mongoid', ['>= 5.0.0'])
23-
s.add_development_dependency('database_cleaner-mongoid', ['>= 2.0.0'])
24-
s.add_development_dependency('mongoid-compatibility')
25-
s.add_development_dependency('rake', ['>= 12.3.3'])
26-
s.add_development_dependency('rspec', ['~> 3.1'])
22+
s.add_dependency('mongoid', ['>= 6.0.0'])
2723

2824
s.require_path = 'lib'
2925
s.files = Dir['lib/**/*', 'tasks/*.rake'] + %w[LICENSE README.md Rakefile]
30-
s.test_files = Dir.glob('spec/**/*')
26+
s.metadata['rubygems_mfa_required'] = 'true'
3127
end

spec/spec_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
config.connect_to 'mongoid_search_test'
1717
end
1818

19-
Dir["#{File.dirname(__FILE__)}/models/*.rb"].sort.each { |file| require file }
19+
Dir["#{File.dirname(__FILE__)}/models/*.rb"].each { |file| require file }
2020

2121
RSpec.configure do |config|
2222
config.before(:all) do

0 commit comments

Comments
 (0)