Skip to content

Commit

Permalink
Raised the minimum Ruby/Rails versions. (#15)
Browse files Browse the repository at this point in the history
Signed-off-by: Hermann Mayer <[email protected]>
  • Loading branch information
Jack12816 authored Jan 3, 2025
1 parent 3c8f565 commit 92face6
Show file tree
Hide file tree
Showing 32 changed files with 147 additions and 160 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: ['2.7']
rails: ['5.2', '6.1', '7.1']
ruby: ['2.7', '3.0']
rails: ['6.1', '7.1']
env:
BUNDLE_GEMFILE: 'gemfiles/rails_${{ matrix.rails }}.gemfile'
steps:
Expand Down
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ AllCops:
SuggestExtensions: false
DisplayCopNames: true
TargetRubyVersion: 2.7
TargetRailsVersion: 5.2
TargetRailsVersion: 6.1
Exclude:
- bin/**/*
- vendor/**/*
Expand Down
4 changes: 0 additions & 4 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# frozen_string_literal: true

appraise 'rails-5.2' do
gem 'activesupport', '~> 5.2.0'
end

appraise 'rails-6.1' do
gem 'activesupport', '~> 6.1.0'
end
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### next

* TODO: Replace this bullet point with an actual description of a change.
* Raised minimum supported Ruby/Rails version to 2.7/6.1 (#15)

### 1.3.4 (15 August 2024)

Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ gem 'bundler', '~> 2.3'
gem 'countless', '~> 1.1'
gem 'guard-rspec', '~> 4.7'
gem 'irb', '~> 1.2'
gem 'railties', '>= 5.2'
gem 'railties', '>= 6.1'
gem 'rake', '~> 13.0'
gem 'rspec', '~> 3.12'
gem 'rubocop', '~> 1.28'
Expand Down
23 changes: 0 additions & 23 deletions gemfiles/rails_5.2.gemfile

This file was deleted.

2 changes: 1 addition & 1 deletion gemfiles/rails_6.1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ gem "bundler", "~> 2.3"
gem "countless", "~> 1.1"
gem "guard-rspec", "~> 4.7"
gem "irb", "~> 1.2"
gem "railties", ">= 5.2"
gem "railties", ">= 6.1"
gem "rake", "~> 13.0"
gem "rspec", "~> 3.12"
gem "rubocop", "~> 1.28"
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails_7.1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ gem "bundler", "~> 2.3"
gem "countless", "~> 1.1"
gem "guard-rspec", "~> 4.7"
gem "irb", "~> 1.2"
gem "railties", ">= 5.2"
gem "railties", ">= 6.1"
gem "rake", "~> 13.0"
gem "rspec", "~> 3.12"
gem "rubocop", "~> 1.28"
Expand Down
4 changes: 2 additions & 2 deletions jabber_admin.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ Gem::Specification.new do |spec|

spec.required_ruby_version = '>= 2.7'

spec.add_runtime_dependency 'activesupport', '>= 5.2'
spec.add_runtime_dependency 'rest-client', '~> 2.1'
spec.add_dependency 'activesupport', '>= 6.1'
spec.add_dependency 'rest-client', '~> 2.1'
end
19 changes: 14 additions & 5 deletions lib/jabber_admin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,15 @@ def self.configure
# it is present)
#
# @param method [Symbol, String, #to_s] the name of the command to run
# @param args all additional payload to pass down to the API call
# @param args [Array<Mixed>] all additional API call payload
# @param kwargs [Hash{Symbol => Mixed}] all additional API call payload
# @return [RestClient::Response] the actual response of the command
def self.method_missing(method, *args)
predefined_command(method).call(predefined_callable(method), *args)
def self.method_missing(method, *args, **kwargs)
predefined_command(method).call(
predefined_callable(method), *args, **kwargs
)
rescue NameError
predefined_callable(method).call(method.to_s.chomp('!'), *args)
predefined_callable(method).call(method.to_s.chomp('!'), *args, **kwargs)
end

# Try to find the given name as a predefined command. When there is no such
Expand All @@ -109,7 +112,13 @@ def self.predefined_command(name)
# @return [Proc] the API call wrapper
def self.predefined_callable(name)
method = name.to_s.end_with?('!') ? 'perform!' : 'perform'
proc { |*args| ApiCall.send(method, *args) }
proc do |*args, **kwargs|
if kwargs.empty?
ApiCall.send(method, *args)
else
ApiCall.send(method, *args, **kwargs)
end
end
end

# Determine if a room exists. This is a convenience method for the
Expand Down
16 changes: 8 additions & 8 deletions lib/jabber_admin/api_call.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,25 +108,25 @@ def perform!
# code which accepts the same arguments as the instance initialize method.
# (+#new+)
#
# @param command [String] the command to execute
# @param payload [Hash] the request payload, empty by default
# @param args [Array<Mixed>] the initializer arguments
# @param kwargs [Hash{Symbol => Mixed}] the initializer arguments
# @return [RestClient::Response] the API call response
def self.perform(*args)
new(*args).perform
def self.perform(*args, **kwargs)
new(*args, **kwargs).perform
end

# A simple class level shortcut of the +perform!+ method. This is just DSL
# code which accepts the same arguments as the instance initialize method.
# (+#new+)
#
# @param command [String] the command to execute
# @param payload [Hash] the request payload, empty by default
# @param args [Array<Mixed>] the initializer arguments
# @param kwargs [Hash{Symbol => Mixed}] the initializer arguments
# @return [RestClient::Response] the API call response
#
# @raise JabberAdmin::ApiError
# @raise JabberAdmin::CommandError
def self.perform!(*args)
new(*args).perform!
def self.perform!(*args, **kwargs)
new(*args, **kwargs).perform!
end
end
end
8 changes: 4 additions & 4 deletions spec/jabber_admin/commands/ban_account_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
RSpec.describe JabberAdmin::Commands::BanAccount do
it_behaves_like 'a command',
with_name: 'ban_account',
with_input_args: [
with_input_kwargs: {
user: '[email protected]',
reason: 'test'
],
with_called_args: [
},
with_called_kwargs: {
user: 'tom',
host: 'ejabberd.local',
reason: 'test'
]
}
end
8 changes: 4 additions & 4 deletions spec/jabber_admin/commands/create_room_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
RSpec.describe JabberAdmin::Commands::CreateRoom do
it_behaves_like 'a command',
with_name: 'create_room',
with_input_args: [
with_input_kwargs: {
room: '[email protected]',
host: 'ejabberd.local'
],
with_called_args: [
},
with_called_kwargs: {
name: 'room1',
service: 'conference.ejabberd.local',
host: 'ejabberd.local'
]
}
end
8 changes: 4 additions & 4 deletions spec/jabber_admin/commands/create_room_with_opts_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
RSpec.describe JabberAdmin::Commands::CreateRoomWithOpts do
it_behaves_like 'a command',
with_name: 'create_room_with_opts',
with_input_args: [
with_input_kwargs: {
room: '[email protected]',
host: 'ejabberd.local',
members_only: true
],
with_called_args: [
},
with_called_kwargs: {
name: 'room2',
service: 'conference.ejabberd.local',
host: 'ejabberd.local',
options: [{ 'name' => 'members_only', 'value' => 'true' }]
]
}
end
8 changes: 4 additions & 4 deletions spec/jabber_admin/commands/destroy_room_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
RSpec.describe JabberAdmin::Commands::DestroyRoom do
it_behaves_like 'a command',
with_name: 'destroy_room',
with_input_args: [
with_input_kwargs: {
room: '[email protected]',
host: 'ejabberd.local'
],
with_called_args: [
},
with_called_kwargs: {
name: 'room1',
service: 'conference.ejabberd.local',
host: 'ejabberd.local'
]
}
end
16 changes: 8 additions & 8 deletions spec/jabber_admin/commands/get_room_affiliations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@

it_behaves_like 'a command',
with_name: 'get_room_affiliations',
with_input_args: [
with_input_kwargs: {
room: '[email protected]'
],
with_called_args: [
},
with_called_kwargs: {
name: 'room1',
service: 'conference.ejabberd.local'
]
}

it 'returns the room affiliations' do
expect(action).to include(a_hash_including({
Expand All @@ -38,13 +38,13 @@

it_behaves_like 'a command',
with_name: 'get_room_affiliations',
with_input_args: [
with_input_kwargs: {
room: '[email protected]'
],
with_called_args: [
},
with_called_kwargs: {
name: 'room2',
service: 'conference.ejabberd.local'
]
}

it 'returns empty room affiliations' do
expect(action).to eql([])
Expand Down
30 changes: 12 additions & 18 deletions spec/jabber_admin/commands/get_vcard_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@
it_behaves_like(
'a command',
with_name: 'get_vcard',
with_input_args: [
:fn,
{ user: '[email protected]' }
],
with_called_args: [
with_input_args: [:fn],
with_input_kwargs: { user: '[email protected]' },
with_called_kwargs: {
user: 'admin',
host: 'jabber.local',
name: 'FN'
],
},
stubbed_response: '{"content":"The Admin"}'
) do
describe 'return value', :vcr do
Expand All @@ -39,16 +37,14 @@
'a command',
with_name: 'get_vcard',
with_called_name: 'get_vcard2',
with_input_args: [
'n.given',
{ user: '[email protected]' }
],
with_called_args: [
with_input_args: ['n.given'],
with_input_kwargs: { user: '[email protected]' },
with_called_kwargs: {
user: 'admin',
host: 'jabber.local',
name: 'N',
subname: 'GIVEN'
],
},
stubbed_response: '{"content":"Aang"}'
) do
describe 'return value', :vcr do
Expand All @@ -64,16 +60,14 @@
'a command',
with_name: 'get_vcard',
with_called_name: 'get_vcard2_multi',
with_input_args: [
'org.orgunit[]',
{ user: '[email protected]' }
],
with_called_args: [
with_input_args: ['org.orgunit[]'],
with_input_kwargs: { user: '[email protected]' },
with_called_kwargs: {
user: 'admin',
host: 'jabber.local',
name: 'ORG',
subname: 'ORGUNIT'
],
},
stubbed_response: '["Marketing","Production"]'
) do
describe 'return value', :vcr do
Expand Down
8 changes: 4 additions & 4 deletions spec/jabber_admin/commands/muc_register_nick_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
RSpec.describe JabberAdmin::Commands::MucRegisterNick do
it_behaves_like 'a command',
with_name: 'muc_register_nick',
with_input_args: [
with_input_kwargs: {
user: '[email protected]',
nick: 'TomTom'
],
with_called_args: [
},
with_called_kwargs: {
jid: '[email protected]',
serverhost: 'ejabberd.local',
nick: 'TomTom'
]
}
end
8 changes: 4 additions & 4 deletions spec/jabber_admin/commands/register_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
RSpec.describe JabberAdmin::Commands::Register do
it_behaves_like 'a command',
with_name: 'register',
with_input_args: [
with_input_kwargs: {
user: '[email protected]',
password: 'password'
],
with_called_args: [
},
with_called_kwargs: {
check_res_body: false,
user: 'tom',
host: 'ejabberd.local',
password: 'password'
]
}
end
8 changes: 4 additions & 4 deletions spec/jabber_admin/commands/registered_users_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
RSpec.describe JabberAdmin::Commands::RegisteredUsers do
it_behaves_like 'a command',
with_name: 'registered_users',
with_input_args: [
with_input_kwargs: {
host: 'ejabberd.local'
],
with_called_args: [
},
with_called_kwargs: {
check_res_body: false,
host: 'ejabberd.local'
]
}
end
Loading

0 comments on commit 92face6

Please sign in to comment.