Skip to content
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
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins:
- rubocop-rspec

AllCops:
TargetRubyVersion: 3.0
TargetRubyVersion: 3.2
Copy link
Member Author

@san983 san983 Dec 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exclude:
- '*.gemspec'
- 'Rakefile'
Expand Down
10 changes: 5 additions & 5 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2023-01-26 12:48:02 UTC using RuboCop version 1.44.1.
# on 2025-12-27 17:14:14 UTC using RuboCop version 1.82.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 74
# Offense count: 90
# Configuration parameters: CountAsOne.
RSpec/ExampleLength:
Max: 17
Expand All @@ -22,11 +22,11 @@ RSpec/LeakyConstantDeclaration:
RSpec/MessageSpies:
EnforcedStyle: receive

# Offense count: 115
# Offense count: 134
RSpec/MultipleExpectations:
Max: 15

# Offense count: 372
# Offense count: 422
# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
# SupportedStyles: always, named_only
RSpec/NamedSubject:
Expand All @@ -48,7 +48,7 @@ RSpec/SubjectStub:
- 'spec/dnsimple/client/zones_spec.rb'
- 'spec/dnsimple/client_spec.rb'

# Offense count: 69
# Offense count: 83
# Configuration parameters: AllowedConstants.
Style/Documentation:
Enabled: false
2 changes: 1 addition & 1 deletion dnsimple.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Gem::Specification.new do |s|
s.summary = 'The DNSimple API client for Ruby'
s.description = 'The DNSimple API client for Ruby.'

s.required_ruby_version = ">= 2.7"
s.required_ruby_version = ['>= 3.2', '< 4']
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd rather create a new PR for supporting Ruby 4 => https://www.ruby-lang.org/en/news/2025/12/25/ruby-4-0-0-released/


s.require_paths = ['lib']
s.files = `git ls-files`.split("\n")
Expand Down
2 changes: 1 addition & 1 deletion lib/dnsimple/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def add_proxy_options!(options)

def add_auth_options!(options)
if password
options[:basic_auth] = { username: username, password: password }
options[:basic_auth] = { username:, password: }
elsif access_token
options[:headers][HEADER_AUTHORIZATION] = "Bearer #{access_token}"
end
Expand Down
4 changes: 2 additions & 2 deletions lib/dnsimple/client/identity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ module StaticHelpers
# @param [Array] args the args for the {Identity#whoami} call
# @return [Hash]
# @raise [Dnsimple::RequestError]
def whoami(client, *args)
client.identity.whoami(*args).data
def whoami(client, *)
client.identity.whoami(*).data
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/dnsimple/client/oauth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module Oauth
# @option options [String] :redirect_uri The redirect URL sent for the authorization, used to validate the request.
# @return [String] The url to redirect the user to authorize.
def exchange_authorization_for_token(code, client_id, client_secret, options = {})
attributes = { code: code, client_id: client_id, client_secret: client_secret, grant_type: "authorization_code" }
attributes = { code:, client_id:, client_secret:, grant_type: "authorization_code" }
attributes[:state] = options.delete(:state) if options.key?(:state)
attributes[:redirect_uri] = options.delete(:redirect_uri) if options.key?(:redirect_uri)
response = client.post(Client.versioned("/oauth/access_token"), attributes, options)
Expand Down
2 changes: 1 addition & 1 deletion lib/dnsimple/client/zones_records.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def batch_change_zone_records(account_id, zone_id, attributes, options = {})
deletes_data = response["data"]["deletes"] || []
deletes = deletes_data.map { |r| Struct::ZoneRecordId.new(r) }
end
Dnsimple::Response.new(response, Struct::ZoneRecordsBatchChange.new({ creates: creates, updates: updates, deletes: deletes }))
Dnsimple::Response.new(response, Struct::ZoneRecordsBatchChange.new({ creates:, updates:, deletes: }))
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/dnsimple/extra.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def self.join_uri(*parts)
# h2 = { b: 250, c: { c1: 200 } }
# Extra.deep_merge(h1, h2) { |key, this_val, other_val| this_val + other_val }
# # => { a: 100, b: 450, c: { c1: 300 } }
def self.deep_merge(this, other, &block)
deep_merge!(this.dup, other, &block)
def self.deep_merge(this, other, &)
deep_merge!(this.dup, other, &)
end

# Same as +deep_merge+, but modifies +this+ instead of returning a new hash.
Expand Down
2 changes: 1 addition & 1 deletion lib/dnsimple/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def _prepare_filter

def _prepare_groupings
groupings = @options.delete(:groupings)
_merge({ groupings: groupings }) unless groupings.nil?
_merge({ groupings: }) unless groupings.nil?
end

def _merge(hash)
Expand Down
12 changes: 6 additions & 6 deletions spec/dnsimple/client/oauth_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
end

it "builds the correct request" do
subject.exchange_authorization_for_token(code, client_id, client_secret, state: state)
subject.exchange_authorization_for_token(code, client_id, client_secret, state:)

expect(WebMock).to have_requested(:post, "https://api.dnsimple.test/v2/oauth/access_token")
.with(body: { client_id: client_id, client_secret: client_secret, code: code, state: state, grant_type: "authorization_code" })
.with(body: { client_id:, client_secret:, code:, state:, grant_type: "authorization_code" })
.with(headers: { "Accept" => "application/json" })
end

it "returns oauth token" do
result = subject.exchange_authorization_for_token(code, client_id, client_secret, state: state)
result = subject.exchange_authorization_for_token(code, client_id, client_secret, state:)

expect(result).to be_a(Dnsimple::Struct::OauthToken)
expect(result.access_token).to eq("zKQ7OLqF5N1gylcJweA9WodA000BUNJD")
Expand All @@ -39,10 +39,10 @@
let(:redirect_uri) { "super-redirect-uri" }

it "builds the correct request" do
subject.exchange_authorization_for_token(code, client_id, client_secret, state: state, redirect_uri: redirect_uri)
subject.exchange_authorization_for_token(code, client_id, client_secret, state:, redirect_uri:)

expect(WebMock).to have_requested(:post, "https://api.dnsimple.test/v2/oauth/access_token")
.with(body: { client_id: client_id, client_secret: client_secret, code: code, state: state, redirect_uri: redirect_uri, grant_type: "authorization_code" })
.with(body: { client_id:, client_secret:, code:, state:, redirect_uri:, grant_type: "authorization_code" })
.with(headers: { "Accept" => "application/json" })
end
end
Expand All @@ -55,7 +55,7 @@

it "raises OAuthInvalidRequestError" do
expect {
subject.exchange_authorization_for_token(code, client_id, client_secret, state: state)
subject.exchange_authorization_for_token(code, client_id, client_secret, state:)
}.to raise_error(Dnsimple::OAuthInvalidRequestError) do |e|
error = "invalid_request"
error_description = "Invalid \"state\": value doesn't match the \"state\" in the authorization request"
Expand Down