Skip to content

Commit

Permalink
Set minimal ruby to 3.0, add 3.2 to the test matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
zhulik committed Aug 15, 2023
1 parent 96d4f40 commit 6c284bc
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ruby: ["2.7", "3.0", "3.1"]
ruby: ["3.0", "3.1", "3.2"]
steps:
- uses: actions/checkout@v2

Expand Down
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AllCops:
TargetRubyVersion: 2.7
TargetRubyVersion: 3.0
NewCops: enable
SuggestExtensions: false

Expand Down
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruby 2.7.5
ruby 3.0.6
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ event loop.

## Dependencies

Grumlin works with ruby >= 2.7, but it's recommended to use 3.1 due to [zlib warnings](https://github.com/socketry/async-websocket/issues/42).
Grumlin works with ruby >= 3.0, but it's recommended to use 3.1 due to [zlib warnings](https://github.com/socketry/async-websocket/issues/42).

## Install

Expand Down
2 changes: 1 addition & 1 deletion grumlin.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Gem::Specification.new do |spec|

spec.homepage = "https://github.com/babbel/grumlin"
spec.license = "MIT"
spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
spec.required_ruby_version = Gem::Requirement.new(">= 3.0")

spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["source_code_uri"] = "https://github.com/babbel/grumlin"
Expand Down
16 changes: 3 additions & 13 deletions lib/grumlin/repository/instance_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def drop_edge(id = nil, from: nil, to: nil, label: nil, start: g) # rubocop:disa

def add_vertex(label, id = nil, start: g, **properties)
id ||= properties[T.id]
properties = except(properties, T.id)
properties = properties.except(T.id)

t = start.addV(label)
t = t.props(T.id => id) unless id.nil?
Expand All @@ -67,7 +67,7 @@ def add_vertex(label, id = nil, start: g, **properties)

def add_edge(label, id = nil, from:, to:, start: g, **properties)
id ||= properties[T.id]
properties = except(properties, T.label)
properties = properties.except(T.label)
properties[T.id] = id

start.addE(label).from(__.V(from)).to(__.V(to)).props(**properties).next
Expand Down Expand Up @@ -136,20 +136,10 @@ def with_upsert_retry(retry_params, &block)
Retryable.retryable(**retry_params, &block)
end

# A polyfill for Hash#except for ruby 2.x environments without ActiveSupport
# TODO: delete and use native Hash#except after ruby 2.7 is deprecated.
def except(hash, *keys)
return hash.except(*keys) if hash.respond_to?(:except)

hash.each_with_object({}) do |(k, v), res|
res[k] = v unless keys.include?(k)
end
end

def cleanup_properties(create_properties, update_properties, *props_to_cleanup)
props_to_cleanup = [T.id, T.label] if props_to_cleanup.empty?
[create_properties, update_properties].map do |props|
except(props, props_to_cleanup)
props.except(props_to_cleanup)
end
end
end

0 comments on commit 6c284bc

Please sign in to comment.