Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix kwargs usage for Ruby 3 compatibility #24

Merged
merged 3 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
ruby: ['2.7', '3.2']

steps:
- uses: actions/checkout@v2
- uses: ruby/[email protected]
- name: Set up Ruby ${{ matrix.ruby }}
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.4
ruby-version: ${{ matrix.ruby }}
bundler: 1
bundler-cache: true
env:
Expand Down
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
FROM ruby:2.3-alpine
FROM ruby:3.2-alpine

RUN apk add --no-cache --update bash

COPY Gemfile elastic_search_framework.gemspec .
COPY lib/elastic_search_framework/version.rb ./lib/elastic_search_framework/

RUN apk add --no-cache --update --virtual .gem-builddeps make gcc libc-dev ruby-json \
&& gem install -N oj -v 2.15.0 \
&& gem install -N json -v 2.1.0 \
&& bundle \
&& apk del .gem-builddeps

# Create application directory and set it as the WORKDIR.
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source 'https://rubygems.org'

gem 'json', '2.1.0'
gem 'json'

# Specify your gem's dependencies in elastic_search_framework.gemspec
gemspec
Expand Down
11 changes: 4 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Or install it yourself as:
## Usage


##Global Config
## Global Config

### #namespace
The namespace is used to set the prefix applied to all table and index names.
Expand Down Expand Up @@ -241,26 +241,23 @@ To run the tests locally, we use Docker to provide both a Ruby and JRuby environ
> This builds the Ruby docker image.

```bash
cd script
./setup.sh
./script/setup.sh
```

### Run Tests:

> This executes the test suite.

```bash
cd script
./test.sh
./script/test.sh
```

### Cleanup

> This is used to clean down docker image created in the setup script.

```bash
cd script
./cleanup.sh
./script/cleanup.sh
```

## Development
Expand Down
2 changes: 1 addition & 1 deletion script/docker-compose.yml → docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ services:
depends_on:
- elasticsearch
volumes:
- ../:/elastic_search_framework
- ./:/elastic_search_framework
3 changes: 2 additions & 1 deletion elastic_search_framework.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]

spec.add_development_dependency 'bundler', '~> 1.11'
spec.add_development_dependency 'bundler'
spec.add_development_dependency 'rake', '~> 10.0'
spec.add_development_dependency 'rspec'
spec.add_development_dependency 'pry'
spec.add_development_dependency 'pry-byebug'
spec.add_dependency 'hash_kit', '~> 0.5'
spec.add_dependency 'json'
spec.add_dependency 'connection_pool'
Expand Down
6 changes: 3 additions & 3 deletions lib/elastic_search_framework/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,21 +176,21 @@ def get_item(id:, type: 'default', routing_key: nil)
options = { index: self, id: id, type: type }
options[:routing_key] = routing_key if routing_enabled? && routing_key

repository.get(options)
repository.get(**options)
end

def put_item(type: 'default', item:, op_type: 'index', routing_key: nil)
options = { entity: item, index: self, type: type, op_type: op_type }
options[:routing_key] = routing_key if routing_enabled? && routing_key

repository.set(options)
repository.set(**options)
end

def delete_item(id:, type: 'default', routing_key: nil)
options = { index: self, id: id, type: type }
options[:routing_key] = routing_key if routing_enabled? && routing_key

repository.drop(options)
repository.drop(**options)
end

def query
Expand Down
6 changes: 3 additions & 3 deletions lib/elastic_search_framework/index_alias.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,15 @@ def get_item(id:, type: "default", routing_key: nil)
options = { index: self, id: id, type: type }
options[:routing_key] = routing_key if active_index.routing_enabled? && routing_key

repository.get(options)
repository.get(**options)
end

def put_item(type: "default", item:, op_type: 'index', routing_key: nil)
indexes.each do |index|
options = { entity: item, index: index[:klass], type: type, op_type: op_type }
options[:routing_key] = routing_key if index[:klass].routing_enabled? && routing_key

repository.set(options)
repository.set(**options)
end
end

Expand All @@ -146,7 +146,7 @@ def delete_item(id:, type: "default", routing_key: nil)
options = { index: index[:klass], id: id, type: type }
options[:routing_key] = routing_key if index[:klass].routing_enabled? && routing_key

repository.drop(options)
repository.drop(**options)
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/elastic_search_framework/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def drop(index:, id:, type: 'default', routing_key: nil)
end

def query(index:, expression:, type: 'default', limit: 10, count: false, routing_key: nil)
uri_string = "#{host}/#{index.full_name}/#{type}/_search?q=#{URI.encode(expression)}&size=#{limit}"
uri_string = "#{host}/#{index.full_name}/#{type}/_search?q=#{CGI::escape(expression)}&size=#{limit}"
uri_string += "&routing=#{routing_key}" if routing_key

uri = URI(uri_string)
Expand Down
2 changes: 1 addition & 1 deletion lib/elastic_search_framework/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module ElasticSearchFramework
VERSION = '2.4.0'
VERSION = '2.4.1'
end
2 changes: 1 addition & 1 deletion script/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ echo setup starting.....
docker-compose rm

echo build docker image
cd ../ && docker build --rm -t sage/elasticsearch_test_runner .
docker build --rm -t sage/elasticsearch_test_runner .

echo setup complete
Loading