Skip to content

Commit

Permalink
fix: Ruby 3.3.0 compat
Browse files Browse the repository at this point in the history
  • Loading branch information
palkan committed Jan 9, 2024
1 parent 2c603f1 commit b661b5f
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 12 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/rspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ jobs:
]
rbs: ['false']
include:
- ruby: "3.2"
- ruby: "3.3"
gemfile: "Gemfile"
rbs: 'true'
- ruby: "3.2"
gemfile: "Gemfile"
rbs: 'false'
- ruby: "3.2"
gemfile: "gemfiles/rails7.gemfile"
rbs: 'false'
Expand Down
7 changes: 7 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,10 @@ Style/FrozenStringLiteralComment:

Lint/RedundantRequireStatement:
Enabled: false

Lint/ItWithoutArgumentsInBlock:
Enabled: false

# Doesn't work in Ruby 3.3.0 https://bugs.ruby-lang.org/issues/20090
Style/ArgumentsForwarding:
Enabled: false
4 changes: 2 additions & 2 deletions lib/anyway/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,9 @@ def load(overrides = nil)
self
end

def load_from_sources(base_config, **)
def load_from_sources(base_config, **opts)
Anyway.loaders.each do |(_id, loader)|
Utils.deep_merge!(base_config, loader.call(**))
Utils.deep_merge!(base_config, loader.call(**opts))
end
base_config
end
Expand Down
12 changes: 6 additions & 6 deletions lib/anyway/tracing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ def dig(...)
value.dig(...)
end

def record_value(val, *path, **)
def record_value(val, *path, **opts)
key = path.pop
trace = if val.is_a?(Hash)
Trace.new.tap { it.merge_values(val, **) }
Trace.new.tap { it.merge_values(val, **opts) }
else
Trace.new(:value, val, **)
Trace.new(:value, val, **opts)
end

target_trace = path.empty? ? self : value.dig(*path)
Expand All @@ -40,14 +40,14 @@ def record_value(val, *path, **)
val
end

def merge_values(hash, **)
def merge_values(hash, **opts)
return hash unless hash

hash.each do |key, val|
if val.is_a?(Hash)
value[key.to_s].merge_values(val, **)
value[key.to_s].merge_values(val, **opts)
else
value[key.to_s] = Trace.new(:value, val, **)
value[key.to_s] = Trace.new(:value, val, **opts)
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
port: 3000

def submeta=(val)
super JSON.parse(val)
super(JSON.parse(val))
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/rails/loaders/credentials_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "spec_helper"

describe "Anyway::Rails::Loaders::Credentials", :rails, skip: (NORAILS || !Rails.application.respond_to?(:credentials)) do
describe "Anyway::Rails::Loaders::Credentials", :rails, skip: NORAILS || !Rails.application.respond_to?(:credentials) do
subject { Anyway::Rails::Loaders::Credentials.call(**options) }

let(:options) { {name: "cool", some_other: "value"} }
Expand Down
2 changes: 1 addition & 1 deletion spec/rails/loaders/secrets_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "spec_helper"

describe "Anyway::Rails::Loaders::Secrets", :rails, :secrets, skip: (NORAILS || !Rails.application.respond_to?(:secrets)) do
describe "Anyway::Rails::Loaders::Secrets", :rails, :secrets, skip: NORAILS || !Rails.application.respond_to?(:secrets) do
subject { Anyway::Rails::Loaders::Secrets.call(**options) }

let(:options) { {name: "cool", some_other: "value"} }
Expand Down

0 comments on commit b661b5f

Please sign in to comment.