Skip to content

Commit

Permalink
Drop support for Ruby 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
hasghari committed Apr 29, 2024
1 parent 73bcce6 commit b5318b5
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 15 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ jobs:
strategy:
matrix:
ruby:
- '3.0'
- '3.1'
- '3.2'
- '3.3'
Expand Down
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ inherit_mode:

AllCops:
NewCops: enable
TargetRubyVersion: 3.0
TargetRubyVersion: 3.1
Exclude:
- gemfiles/**

Expand Down
2 changes: 1 addition & 1 deletion gemfiles/activerecord_6.1.0.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PATH
remote: ..
specs:
parentry (1.6.0)
activerecord (>= 5.1, < 7.2)
activerecord (>= 6.1, < 7.2)

GEM
remote: https://rubygems.org/
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/activerecord_7.0.0.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PATH
remote: ..
specs:
parentry (1.6.0)
activerecord (>= 5.1, < 7.2)
activerecord (>= 6.1, < 7.2)

GEM
remote: https://rubygems.org/
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/activerecord_7.1.0.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PATH
remote: ..
specs:
parentry (1.6.0)
activerecord (>= 5.1, < 7.2)
activerecord (>= 6.1, < 7.2)

GEM
remote: https://rubygems.org/
Expand Down
4 changes: 2 additions & 2 deletions lib/parentry/navigation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def sibling_ids
end

def siblings
parentry_scope.where.not(id: id).where.not(parent_id: nil).where(parent_id: parent_id)
parentry_scope.where.not(id:).where.not(parent_id: nil).where(parent_id:)
end

def siblings?
Expand All @@ -73,7 +73,7 @@ def descendant_ids(scopes = {})

def descendants(scopes = {})
with_depth_scopes(scopes) do
subtree.where.not(id: id)
subtree.where.not(id:)
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/parentry/strategy/array/instance_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def compute_parentry
def cascade_parentry
old_path, new_path = saved_changes[parentry_column]
parentry_scope.where(
["#{parentry_column} @> ARRAY[:tree] AND id != :id", { tree: old_path, id: id }]
["#{parentry_column} @> ARRAY[:tree] AND id != :id", { tree: old_path, id: }]
).update_all(
[
"#{parentry_column} = array_cat(ARRAY[?], #{parentry_column}[?:array_length(#{parentry_column}, 1)])",
Expand Down
4 changes: 2 additions & 2 deletions lib/parentry/strategy/ltree/instance_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ def compute_parentry
def cascade_parentry
old_path, new_path = saved_changes[parentry_column]
parentry_scope.where(
["#{parentry_column} <@ :tree AND id != :id", { tree: old_path, id: id }]
["#{parentry_column} <@ :tree AND id != :id", { tree: old_path, id: }]
).update_all(
[
"#{parentry_column} = :new_path || subpath(#{parentry_column}, nlevel(:old_path))",
{ new_path: new_path, old_path: old_path }
{ new_path:, old_path: }
]
)
end
Expand Down
4 changes: 2 additions & 2 deletions parentry.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ Gem::Specification.new do |spec|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
spec.require_paths = ['lib']

spec.required_ruby_version = '>= 3.0'
spec.required_ruby_version = '>= 3.1'
spec.metadata['rubygems_mfa_required'] = 'true'

spec.add_dependency 'activerecord', '>= 5.1', '< 7.2'
spec.add_dependency 'activerecord', '>= 6.1', '< 7.2'
end
6 changes: 3 additions & 3 deletions spec/parentry/instance_methods_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ def parse(parentry)

it 'persists parentry path after create' do
parent = TreeNode.create
node = TreeNode.create parent: parent
node = TreeNode.create(parent:)
expect(parse(node.parentry)).to eq [parent.id, node.id]
end

it 'is not valid when parent not persisted' do
parent = TreeNode.new
expect(TreeNode.new(parent: parent)).not_to be_valid
expect(TreeNode.new(parent:)).not_to be_valid
end

it 'cannot create circular path' do
Expand All @@ -28,7 +28,7 @@ def parse(parentry)

it 'assigns parent when persisted' do
parent = TreeNode.create
node = TreeNode.new parent: parent
node = TreeNode.new(parent:)
expect(node.parent).to eq parent
end

Expand Down

0 comments on commit b5318b5

Please sign in to comment.