diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index f91a129..943a8d4 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- ruby-version: [ '2.7', '3.0', '3.1', '3.2', head ]
+ ruby-version: [ '3.0', '3.1', '3.2', '3.3', 'head' ]
steps:
- uses: actions/checkout@v3
diff --git a/.rubocop.yml b/.rubocop.yml
index b5a5de3..9f8c0a8 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -15,7 +15,9 @@ inherit_gem:
- config/ruby-3.0.yml
AllCops:
- TargetRubyVersion: 3.2
+ # Last supported version before EOL
+ # See: https://endoflife.date/ruby
+ TargetRubyVersion: 3.0
NewCops: enable
Exclude:
- '**/vendor/**/*'
diff --git a/.standard.yml b/.standard.yml
new file mode 100644
index 0000000..f184549
--- /dev/null
+++ b/.standard.yml
@@ -0,0 +1,4 @@
+# Last supported version before EOL
+# See: https://endoflife.date/ruby
+ruby_version: 3.0
+format: progress
\ No newline at end of file
diff --git a/README.yml b/README.yml
deleted file mode 100644
index 1f82b6f..0000000
--- a/README.yml
+++ /dev/null
@@ -1,2 +0,0 @@
-title: Home
-icon: home
\ No newline at end of file
diff --git a/Rakefile b/Rakefile
index bd8a454..a3a4d56 100644
--- a/Rakefile
+++ b/Rakefile
@@ -3,15 +3,11 @@
require "bundler/gem_tasks"
require "appraisal"
require "rspec/core/rake_task"
-require "rubocop/rake_task"
-require "standard/rake"
-
-RSpec::Core::RakeTask.new(:spec)
-RuboCop::RakeTask.new
desc "Run the full CI"
task :default do
if ENV["APPRAISAL_INITIALIZED"]
+ RSpec::Core::RakeTask.new(:spec)
Rake::Task["spec"].invoke
else
# FYI: Standard & appraisal requires each a spawn process.
@@ -26,6 +22,6 @@ task :default do
fail unless system "bundle exec appraisal rspec"
fail unless system "bundle exec rubocop"
- fail unless system "bundle exec rake standard"
+ fail unless system "bundle exec standardrb"
end
end
diff --git a/index.md b/index.md
new file mode 100644
index 0000000..e8e8675
--- /dev/null
+++ b/index.md
@@ -0,0 +1,66 @@
+# Caoutsearch [\ˈkawt͡ˈsɝtʃ\\](http://ipa-reader.xyz/?text=ˈkawt͡ˈsɝtʃ)
+
+[](https://rubygems.org/gems/caoutsearch)
+[](https://github.com/solutions-territoire/caoutsearch/actions/workflows/ci.yml)
+[](https://github.com/testdouble/standard)
+[](https://codeclimate.com/github/solutions-territoire/caoutsearch/maintainability)
+[](https://codeclimate.com/github/solutions-territoire/caoutsearch/test_coverage)
+
+[](https://github.com/solutions-territoire/caoutsearch/actions/workflows/jruby.yml)
+[](https://github.com/solutions-territoire/caoutsearch/actions/workflows/truffle_ruby.yml)
+
+**!! Gem under development before public release !!**
+
+Caoutsearch is a new Elasticsearch integration for Ruby and/or Rails.
+It provides a simple but powerful DSL to perform complex indexing and searching, while securely exposing search criteria to a public and chainable API, without overwhelming your models.
+
+Caoutsearch only supports Elasticsearch 8.x right now.
+It is used in production in a robust application, updated and maintained for several years at [Solutions & Territoire](https://solutions-territoire.fr).
+
+Caoutsearch was inspired by awesome gems such as [elasticsearch-rails](https://github.com/elastic/elasticsearch-rails) or [search_flip](https://github.com/mrkamel/search_flip).
+Depending on your search scenarios, they may better suite your needs.
+
+## Overview
+
+Caoutsearch let you create `Index` and `Search` classes to manipulate your data :
+
+```ruby
+class ArticleIndex < Caoutsearch::Index::Base
+ property :title
+ property :published_on
+ property :tags
+
+ def tags
+ records.tags.public.map(&:to_s)
+ end
+end
+```
+
+```ruby
+class ArticleSearch < Caoutsearch::Search::Base
+ filter :title, as: :match
+ filter :published_on, as: :date
+ filter :tags
+
+ has_aggregation :popular_tags, {
+ filter: { term: { published: true } },
+ aggs: {
+ published: {
+ terms: { field: :tags, size: 10 }
+ }
+ }
+ }
+end
+```
+
+You can then index your records
+
+```ruby
+ArticleIndex.reindex
+```
+
+Or search through them:
+
+```ruby
+ArticleSearch.search(published_on: [["now-1y", nil]]).aggregate(:popular_tags)
+```
diff --git a/index.yml b/index.yml
new file mode 100644
index 0000000..46b4056
--- /dev/null
+++ b/index.yml
@@ -0,0 +1,2 @@
+title: Overview
+icon: home
\ No newline at end of file
diff --git a/lib/caoutsearch/model/indexable.rb b/lib/caoutsearch/model/indexable.rb
index 524dec3..5d844f6 100644
--- a/lib/caoutsearch/model/indexable.rb
+++ b/lib/caoutsearch/model/indexable.rb
@@ -19,8 +19,8 @@ def index_with(index_class)
end
module ClassMethods
- def reindex(*properties, **options, &block)
- index_engine_class.reindex(all, *properties, **options, &block)
+ def reindex(...)
+ index_engine_class.reindex(all, ...)
end
def delete_indexes
diff --git a/lib/caoutsearch/search/callbacks.rb b/lib/caoutsearch/search/callbacks.rb
index 3425a7c..b606a93 100644
--- a/lib/caoutsearch/search/callbacks.rb
+++ b/lib/caoutsearch/search/callbacks.rb
@@ -11,16 +11,16 @@ module Callbacks
end
class_methods do
- def before_build(*filters, &blk)
- set_callback(:build, :before, *filters, &blk)
+ def before_build(...)
+ set_callback(:build, :before, ...)
end
- def after_build(*filters, &blk)
- set_callback(:build, :after, *filters, &blk)
+ def after_build(...)
+ set_callback(:build, :after, ...)
end
- def around_build(*filters, &blk)
- set_callback(:build, :around, *filters, &blk)
+ def around_build(...)
+ set_callback(:build, :around, ...)
end
end
end
diff --git a/lib/caoutsearch/search/dsl/item.rb b/lib/caoutsearch/search/dsl/item.rb
index ac13a5c..a10ce9f 100644
--- a/lib/caoutsearch/search/dsl/item.rb
+++ b/lib/caoutsearch/search/dsl/item.rb
@@ -32,7 +32,7 @@ def inspect
def properties_to_inspect
PROPERTIES_TO_INSPECT.each_with_object({}) do |name, properties|
- value = instance_variable_get("@#{name}")
+ value = instance_variable_get(:"@#{name}")
properties[name] = value.inspect if value.present?
end
end
diff --git a/lib/caoutsearch/search/inspect.rb b/lib/caoutsearch/search/inspect.rb
index 263c9fc..6e4e243 100644
--- a/lib/caoutsearch/search/inspect.rb
+++ b/lib/caoutsearch/search/inspect.rb
@@ -25,7 +25,7 @@ def inspect
def properties_to_inspect
PROPERTIES_TO_INSPECT.each_with_object({}) do |name, properties|
- value = instance_variable_get("@#{name}")
+ value = instance_variable_get(:"@#{name}")
properties[name] = value.inspect if value
end
end
diff --git a/retype.yml b/retype.yml
index 68e0106..5918880 100644
--- a/retype.yml
+++ b/retype.yml
@@ -28,4 +28,12 @@ links:
# target: blank
footer:
- copyright: "© 2023 [Solutions & Territoire](https://solutions-territoire.fr) - [MIT License](https://github.com/solutions-territoire/caoutsearch/blob/main/LICENSE)"
\ No newline at end of file
+ copyright: "© 2023 [Solutions & Territoire](https://solutions-territoire.fr) - [MIT License](https://github.com/solutions-territoire/caoutsearch/blob/main/LICENSE)"
+
+edit:
+ base: docs
+
+exclude:
+ - "README.md"
+ - "release_instruction.md"
+ - "retype_instruction.md"
\ No newline at end of file
diff --git a/spec/caoutsearch/search/batch_methods_spec.rb b/spec/caoutsearch/search/batch_methods_spec.rb
index 47d024f..915ff26 100644
--- a/spec/caoutsearch/search/batch_methods_spec.rb
+++ b/spec/caoutsearch/search/batch_methods_spec.rb
@@ -2,7 +2,7 @@
require "spec_helper"
-RSpec.describe Caoutsearch::Search::BatchMethods, active_record: true do
+RSpec.describe Caoutsearch::Search::BatchMethods, :active_record do
let(:search_class) { stub_search_class("SampleSearch") }
let(:search) { search_class.new }
let(:records) { Array.new(12) { Sample.create } }
diff --git a/spec/caoutsearch/search/records_spec.rb b/spec/caoutsearch/search/records_spec.rb
index f25daea..c8921ce 100644
--- a/spec/caoutsearch/search/records_spec.rb
+++ b/spec/caoutsearch/search/records_spec.rb
@@ -2,7 +2,7 @@
require "spec_helper"
-RSpec.describe Caoutsearch::Search::Records, active_record: true do
+RSpec.describe Caoutsearch::Search::Records, :active_record do
let!(:search) { search_class.new }
let!(:search_class) { stub_search_class("SampleSearch") }
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 312ac0b..f32c828 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -26,7 +26,7 @@
expect.syntax = :expect
end
- config.before :context, active_record: true do
+ config.before :context, :active_record do
require "database_cleaner/active_record"
require "active_record"
@@ -47,7 +47,7 @@
DatabaseCleaner.cleaning { example.run }
end
- config.after :context, active_record: true do
+ config.after :context, :active_record do
ActiveRecord::Schema.define do
suppress_messages do
drop_table :samples