Skip to content

Commit 0ff80cb

Browse files
authored
Merge pull request #24 from Sage/build-ruby3
Fix kwargs usage for Ruby 3 compatibility
2 parents 5e3767e + b69d706 commit 0ff80cb

File tree

11 files changed

+29
-24
lines changed

11 files changed

+29
-24
lines changed

.github/workflows/test.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,16 @@ jobs:
66
test:
77
runs-on: ubuntu-latest
88

9+
strategy:
10+
matrix:
11+
ruby: ['2.7', '3.2']
12+
913
steps:
1014
- uses: actions/checkout@v2
11-
- uses: ruby/[email protected]
15+
- name: Set up Ruby ${{ matrix.ruby }}
16+
uses: ruby/setup-ruby@v1
1217
with:
13-
ruby-version: 2.4
18+
ruby-version: ${{ matrix.ruby }}
1419
bundler: 1
1520
bundler-cache: true
1621
env:

Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
FROM ruby:2.3-alpine
1+
FROM ruby:3.2-alpine
22

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

5+
COPY Gemfile elastic_search_framework.gemspec .
6+
COPY lib/elastic_search_framework/version.rb ./lib/elastic_search_framework/
7+
58
RUN apk add --no-cache --update --virtual .gem-builddeps make gcc libc-dev ruby-json \
6-
&& gem install -N oj -v 2.15.0 \
7-
&& gem install -N json -v 2.1.0 \
9+
&& bundle \
810
&& apk del .gem-builddeps
911

1012
# Create application directory and set it as the WORKDIR.

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
source 'https://rubygems.org'
22

3-
gem 'json', '2.1.0'
3+
gem 'json'
44

55
# Specify your gem's dependencies in elastic_search_framework.gemspec
66
gemspec

README.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Or install it yourself as:
2121
## Usage
2222

2323

24-
##Global Config
24+
## Global Config
2525

2626
### #namespace
2727
The namespace is used to set the prefix applied to all table and index names.
@@ -241,26 +241,23 @@ To run the tests locally, we use Docker to provide both a Ruby and JRuby environ
241241
> This builds the Ruby docker image.
242242
243243
```bash
244-
cd script
245-
./setup.sh
244+
./script/setup.sh
246245
```
247246

248247
### Run Tests:
249248

250249
> This executes the test suite.
251250
252251
```bash
253-
cd script
254-
./test.sh
252+
./script/test.sh
255253
```
256254

257255
### Cleanup
258256

259257
> This is used to clean down docker image created in the setup script.
260258
261259
```bash
262-
cd script
263-
./cleanup.sh
260+
./script/cleanup.sh
264261
```
265262

266263
## Development

script/docker-compose.yml renamed to docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ services:
1818
depends_on:
1919
- elasticsearch
2020
volumes:
21-
- ../:/elastic_search_framework
21+
- ./:/elastic_search_framework

elastic_search_framework.gemspec

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ Gem::Specification.new do |spec|
1919
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
2020
spec.require_paths = ["lib"]
2121

22-
spec.add_development_dependency 'bundler', '~> 1.11'
22+
spec.add_development_dependency 'bundler'
2323
spec.add_development_dependency 'rake', '~> 10.0'
2424
spec.add_development_dependency 'rspec'
2525
spec.add_development_dependency 'pry'
26+
spec.add_development_dependency 'pry-byebug'
2627
spec.add_dependency 'hash_kit', '~> 0.5'
2728
spec.add_dependency 'json'
2829
spec.add_dependency 'connection_pool'

lib/elastic_search_framework/index.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,21 +176,21 @@ def get_item(id:, type: 'default', routing_key: nil)
176176
options = { index: self, id: id, type: type }
177177
options[:routing_key] = routing_key if routing_enabled? && routing_key
178178

179-
repository.get(options)
179+
repository.get(**options)
180180
end
181181

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

186-
repository.set(options)
186+
repository.set(**options)
187187
end
188188

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

193-
repository.drop(options)
193+
repository.drop(**options)
194194
end
195195

196196
def query

lib/elastic_search_framework/index_alias.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,15 @@ def get_item(id:, type: "default", routing_key: nil)
129129
options = { index: self, id: id, type: type }
130130
options[:routing_key] = routing_key if active_index.routing_enabled? && routing_key
131131

132-
repository.get(options)
132+
repository.get(**options)
133133
end
134134

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

140-
repository.set(options)
140+
repository.set(**options)
141141
end
142142
end
143143

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

149-
repository.drop(options)
149+
repository.drop(**options)
150150
end
151151
end
152152

lib/elastic_search_framework/repository.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def drop(index:, id:, type: 'default', routing_key: nil)
7474
end
7575

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

8080
uri = URI(uri_string)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module ElasticSearchFramework
2-
VERSION = '2.4.0'
2+
VERSION = '2.4.1'
33
end

0 commit comments

Comments
 (0)