jabber_admin 1.3.4 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +2 -2
- data/.rubocop.yml +1 -1
- data/.yardopts +1 -0
- data/Appraisals +0 -4
- data/CHANGELOG.md +23 -15
- data/Gemfile +1 -1
- data/gemfiles/rails_6.1.gemfile +1 -1
- data/gemfiles/rails_7.1.gemfile +1 -1
- data/jabber_admin.gemspec +3 -2
- data/lib/jabber_admin/api_call.rb +8 -8
- data/lib/jabber_admin/version.rb +1 -1
- data/lib/jabber_admin.rb +103 -79
- metadata +19 -7
- data/gemfiles/rails_5.2.gemfile +0 -23
- data/lib/jabber_admin/commands.rb +0 -11
- /data/lib/jabber_admin/{exceptions.rb → errors.rb} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c4af608b6ed7038365c714cb8ffea5270ccb1138fb7f739d448f53be85e1c99
|
4
|
+
data.tar.gz: 0f6a0f5d8d0d43781e3dde3451151e44f0e1acbab6419c25963912d8ca884946
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 516a0761b8f1e98e1eb33047826885beb1e75930cee6c555e2cfb76488f77efdff238aca93a96f140af0cc2e5d043fab7c4c4b6d556b02a4e700c052741dcce8
|
7
|
+
data.tar.gz: ef4cc3eaa6d182bf92387f1a995b8ea45c14b77e7a46f1234dc5ae21110cb4f468e2ddec4eb36954075646de929745010fd209b315b8d22aa971b0590c753de5
|
data/.github/workflows/test.yml
CHANGED
data/.rubocop.yml
CHANGED
data/.yardopts
CHANGED
data/Appraisals
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,32 +2,40 @@
|
|
2
2
|
|
3
3
|
* TODO: Replace this bullet point with an actual description of a change.
|
4
4
|
|
5
|
-
### 1.
|
5
|
+
### 1.5.0 (12 January 2025)
|
6
|
+
|
7
|
+
* Switched to Zeitwerk as autoloader (#16)
|
8
|
+
|
9
|
+
### 1.4.0 (3 January 2025)
|
10
|
+
|
11
|
+
* Raised minimum supported Ruby/Rails version to 2.7/6.1 (#15)
|
12
|
+
|
13
|
+
### 1.3.4 (15 August 2024)
|
6
14
|
|
7
15
|
* Just a retag of 1.3.1
|
8
16
|
|
9
|
-
### 1.3.3
|
17
|
+
### 1.3.3 (15 August 2024)
|
10
18
|
|
11
19
|
* Just a retag of 1.3.1
|
12
20
|
|
13
|
-
### 1.3.2
|
21
|
+
### 1.3.2 (9 August 2024)
|
14
22
|
|
15
23
|
* Just a retag of 1.3.1
|
16
24
|
|
17
|
-
### 1.3.1
|
25
|
+
### 1.3.1 (9 August 2024)
|
18
26
|
|
19
27
|
* Added API docs building to continuous integration (#14)
|
20
28
|
|
21
|
-
### 1.3.0
|
29
|
+
### 1.3.0 (8 July 2024)
|
22
30
|
|
23
31
|
* Moved the development dependencies from the gemspec to the Gemfile (#12)
|
24
32
|
* Dropped support for Ruby <2.7 (#13)
|
25
33
|
|
26
|
-
### 1.2.0
|
34
|
+
### 1.2.0 (24 February 2023)
|
27
35
|
|
28
36
|
* Added support for Gem release automation
|
29
37
|
|
30
|
-
### 1.1.0
|
38
|
+
### 1.1.0 (18 January 2023)
|
31
39
|
|
32
40
|
* Bundler >= 2.3 is from now on required as minimal version (#11)
|
33
41
|
* Dropped support for Ruby < 2.5 (#11)
|
@@ -35,32 +43,32 @@
|
|
35
43
|
* Updated all development/runtime gems to their latest
|
36
44
|
Ruby 2.5 compatible version (#11)
|
37
45
|
|
38
|
-
### 1.0.5
|
46
|
+
### 1.0.5 (20 January 2022)
|
39
47
|
|
40
48
|
* Added support for the predefined command `get_room_affiliations` (#10)
|
41
49
|
* Added the top-level helper `JabberAdmin.room_exist?` to determine whether
|
42
50
|
a room exists or not (#10)
|
43
51
|
|
44
|
-
### 1.0.4
|
52
|
+
### 1.0.4 (11 November 2021)
|
45
53
|
|
46
54
|
* Added support for the predefined command `destroy_room`
|
47
55
|
|
48
|
-
### 1.0.3
|
56
|
+
### 1.0.3 (15 October 2021)
|
49
57
|
|
50
58
|
* Migrated to Github Actions
|
51
59
|
* Migrated to our own coverage reporting
|
52
60
|
* Added the code statistics to the test process
|
53
61
|
|
54
|
-
### 1.0.2
|
62
|
+
### 1.0.2 (12 May 2021)
|
55
63
|
|
56
64
|
* Corrected the GNU Make release target
|
57
65
|
* Corrected the empty arguments check
|
58
66
|
|
59
|
-
### 1.0.1
|
67
|
+
### 1.0.1 (13 October 2020)
|
60
68
|
|
61
69
|
* Gracefully handle a missing vCard when a vCard field is queried (#7)
|
62
70
|
|
63
|
-
### 1.0.0
|
71
|
+
### 1.0.0 (13 October 2020)
|
64
72
|
|
65
73
|
* All `JabberAdmin` errors `[UnknownCommandError, CommandError, RequestError]`
|
66
74
|
now ship the response object correctly (was always set to `nil` previously)
|
@@ -71,7 +79,7 @@
|
|
71
79
|
* Dropped support for Ruby <2.5 (#6)
|
72
80
|
* Added some versioning helpers (eg. `JabberAdmin.version`)
|
73
81
|
|
74
|
-
### 0.2.0
|
82
|
+
### 0.2.0 (14 May 2018)
|
75
83
|
|
76
84
|
* [BC] The configuration has changed
|
77
85
|
* `api_host` => `url`, we require now the full base URL of the REST API, this
|
@@ -94,7 +102,7 @@
|
|
94
102
|
* The testcases were rewritten and tested with VCR against a real ejabberd
|
95
103
|
server (18.01)
|
96
104
|
|
97
|
-
### 0.1.4
|
105
|
+
### 0.1.4 (23 January 2018)
|
98
106
|
|
99
107
|
* Added support for predefined commands
|
100
108
|
* ban_account
|
data/Gemfile
CHANGED
data/gemfiles/rails_6.1.gemfile
CHANGED
data/gemfiles/rails_7.1.gemfile
CHANGED
data/jabber_admin.gemspec
CHANGED
@@ -33,6 +33,7 @@ Gem::Specification.new do |spec|
|
|
33
33
|
|
34
34
|
spec.required_ruby_version = '>= 2.7'
|
35
35
|
|
36
|
-
spec.
|
37
|
-
spec.
|
36
|
+
spec.add_dependency 'activesupport', '>= 6.1'
|
37
|
+
spec.add_dependency 'rest-client', '~> 2.1'
|
38
|
+
spec.add_dependency 'zeitwerk', '~> 2.6'
|
38
39
|
end
|
@@ -108,25 +108,25 @@ module JabberAdmin
|
|
108
108
|
# code which accepts the same arguments as the instance initialize method.
|
109
109
|
# (+#new+)
|
110
110
|
#
|
111
|
-
# @param
|
112
|
-
# @param
|
111
|
+
# @param args [Array<Mixed>] the initializer arguments
|
112
|
+
# @param kwargs [Hash{Symbol => Mixed}] the initializer arguments
|
113
113
|
# @return [RestClient::Response] the API call response
|
114
|
-
def self.perform(*args)
|
115
|
-
new(*args).perform
|
114
|
+
def self.perform(*args, **kwargs)
|
115
|
+
new(*args, **kwargs).perform
|
116
116
|
end
|
117
117
|
|
118
118
|
# A simple class level shortcut of the +perform!+ method. This is just DSL
|
119
119
|
# code which accepts the same arguments as the instance initialize method.
|
120
120
|
# (+#new+)
|
121
121
|
#
|
122
|
-
# @param
|
123
|
-
# @param
|
122
|
+
# @param args [Array<Mixed>] the initializer arguments
|
123
|
+
# @param kwargs [Hash{Symbol => Mixed}] the initializer arguments
|
124
124
|
# @return [RestClient::Response] the API call response
|
125
125
|
#
|
126
126
|
# @raise JabberAdmin::ApiError
|
127
127
|
# @raise JabberAdmin::CommandError
|
128
|
-
def self.perform!(*args)
|
129
|
-
new(*args).perform!
|
128
|
+
def self.perform!(*args, **kwargs)
|
129
|
+
new(*args, **kwargs).perform!
|
130
130
|
end
|
131
131
|
end
|
132
132
|
end
|
data/lib/jabber_admin/version.rb
CHANGED
data/lib/jabber_admin.rb
CHANGED
@@ -1,16 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'zeitwerk'
|
3
4
|
require 'active_support/inflector'
|
4
5
|
require 'json'
|
5
6
|
require 'pathname'
|
6
7
|
require 'rest-client'
|
7
8
|
|
8
|
-
require 'jabber_admin/exceptions'
|
9
|
-
require 'jabber_admin/configuration'
|
10
|
-
require 'jabber_admin/commands'
|
11
|
-
require 'jabber_admin/api_call'
|
12
|
-
require 'jabber_admin/version'
|
13
|
-
|
14
9
|
# jabber_admin
|
15
10
|
#
|
16
11
|
# This gem allows making API calls to the ejabberd RESTful admin backend. We
|
@@ -53,87 +48,116 @@ require 'jabber_admin/version'
|
|
53
48
|
# @example Delete a user from the XMPP service, in fire and forget manner
|
54
49
|
# JabberAdmin.unregister user: 'peter@example.com'
|
55
50
|
module JabberAdmin
|
51
|
+
# Configure the relative gem code base location
|
52
|
+
root_path = Pathname.new("#{__dir__}/jabber_admin")
|
53
|
+
|
54
|
+
# Setup a Zeitwerk autoloader instance and configure it
|
55
|
+
loader = Zeitwerk::Loader.for_gem
|
56
|
+
|
57
|
+
# Do not auto load some parts of the gem
|
58
|
+
loader.ignore(root_path.join('errors.rb'))
|
59
|
+
|
60
|
+
# Finish the auto loader configuration
|
61
|
+
loader.setup
|
62
|
+
|
63
|
+
# Load standalone code
|
64
|
+
require 'jabber_admin/version'
|
65
|
+
require 'jabber_admin/errors'
|
66
|
+
|
67
|
+
# Make sure to eager load all constants
|
68
|
+
loader.eager_load
|
69
|
+
|
56
70
|
class << self
|
57
71
|
attr_writer :configuration
|
58
|
-
end
|
59
72
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
73
|
+
# A simple getter to the global JabberAdmin configuration structure.
|
74
|
+
#
|
75
|
+
# @return [JabberAdmin::Configuration] the global JabberAdmin configuration
|
76
|
+
def configuration
|
77
|
+
@configuration ||= Configuration.new
|
78
|
+
end
|
66
79
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
80
|
+
# Class method to set and change the global configuration. This is just a
|
81
|
+
# tapped variant of the +.configuration+ method.
|
82
|
+
#
|
83
|
+
# @yield [configuration]
|
84
|
+
# @yieldparam [JabberAdmin::Configuration] configuration
|
85
|
+
def configure
|
86
|
+
yield(configuration)
|
87
|
+
end
|
75
88
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
89
|
+
# Allow an easy to use DSL on the +JabberAdmin+ module. We support
|
90
|
+
# predefined (known) commands and unknown ones in bang and non-bang
|
91
|
+
# variants. This allows maximum flexibility to the user. The bang versions
|
92
|
+
# perform the response checks and raise in case of issues. The non-bang
|
93
|
+
# versions skip this checks. For unknown commands the
|
94
|
+
# +JabberAdmin::ApiCall+ is directly utilized with the method name as
|
95
|
+
# command. (Without the trailling bang, when it is present)
|
96
|
+
#
|
97
|
+
# @param method [Symbol, String, #to_s] the name of the command to run
|
98
|
+
# @param args [Array<Mixed>] all additional API call payload
|
99
|
+
# @param kwargs [Hash{Symbol => Mixed}] all additional API call payload
|
100
|
+
# @return [RestClient::Response] the actual response of the command
|
101
|
+
def method_missing(method, *args, **kwargs)
|
102
|
+
predefined_command(method).call(
|
103
|
+
predefined_callable(method), *args, **kwargs
|
104
|
+
)
|
105
|
+
rescue NameError
|
106
|
+
predefined_callable(method).call(method.to_s.chomp('!'), *args, **kwargs)
|
107
|
+
end
|
92
108
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
109
|
+
# Try to find the given name as a predefined command. When there is no such
|
110
|
+
# predefined command, we raise a +NameError+.
|
111
|
+
#
|
112
|
+
# @param name [Symbol, String, #to_s] the command name to lookup
|
113
|
+
# @return [Class] the predefined command class constant
|
114
|
+
def predefined_command(name)
|
115
|
+
# Remove bangs and build the camel case variant
|
116
|
+
"JabberAdmin::Commands::#{name.to_s.chomp('!').camelize}".constantize
|
117
|
+
end
|
102
118
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
119
|
+
# Generate a matching API call wrapper for the given command name. When we
|
120
|
+
# have to deal with a bang version, we pass the bang down to the API call
|
121
|
+
# instance. Otherwise we just run the regular +#perform+ method on the API
|
122
|
+
# call instance.
|
123
|
+
#
|
124
|
+
# @param name [Symbol, String, #to_s] the command name to match
|
125
|
+
# @return [Proc] the API call wrapper
|
126
|
+
def predefined_callable(name)
|
127
|
+
method = name.to_s.end_with?('!') ? 'perform!' : 'perform'
|
128
|
+
proc do |*args, **kwargs|
|
129
|
+
if kwargs.empty?
|
130
|
+
ApiCall.send(method, *args)
|
131
|
+
else
|
132
|
+
ApiCall.send(method, *args, **kwargs)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
114
136
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
137
|
+
# Determine if a room exists. This is a convenience method for the
|
138
|
+
# +JabberAdmin::Commands::GetRoomAffiliations+ command, which can be used
|
139
|
+
# to reliably determine whether a room exists or not.
|
140
|
+
#
|
141
|
+
# @param room [String] the name of the room to check
|
142
|
+
# @return [Boolean] whether the room exists or not
|
143
|
+
def room_exist?(room)
|
144
|
+
get_room_affiliations!(room: room)
|
145
|
+
true
|
146
|
+
rescue JabberAdmin::CommandError => e
|
147
|
+
raise e unless /room does not exist/.match? e.response.body
|
148
|
+
|
149
|
+
false
|
150
|
+
end
|
129
151
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
152
|
+
# We support all methods if you ask for. This is our dynamic command
|
153
|
+
# approach here to support predefined and custom commands in the same
|
154
|
+
# namespace.
|
155
|
+
#
|
156
|
+
# @param method [String] the method to lookup
|
157
|
+
# @param include_private [Boolean] allow the lookup of private methods
|
158
|
+
# @return [Boolean] always +true+
|
159
|
+
def respond_to_missing?(_method, _include_private = false)
|
160
|
+
true
|
161
|
+
end
|
138
162
|
end
|
139
163
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jabber_admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hermann Mayer
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2025-01-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '
|
20
|
+
version: '6.1'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '
|
27
|
+
version: '6.1'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: rest-client
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,6 +39,20 @@ dependencies:
|
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '2.1'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: zeitwerk
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '2.6'
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '2.6'
|
42
56
|
description: Library for the ejabberd RESTful admin API
|
43
57
|
email:
|
44
58
|
- hermann.mayer92@gmail.com
|
@@ -74,13 +88,11 @@ files:
|
|
74
88
|
- config/docker/.inputrc
|
75
89
|
- doc/assets/project.svg
|
76
90
|
- docker-compose.yml
|
77
|
-
- gemfiles/rails_5.2.gemfile
|
78
91
|
- gemfiles/rails_6.1.gemfile
|
79
92
|
- gemfiles/rails_7.1.gemfile
|
80
93
|
- jabber_admin.gemspec
|
81
94
|
- lib/jabber_admin.rb
|
82
95
|
- lib/jabber_admin/api_call.rb
|
83
|
-
- lib/jabber_admin/commands.rb
|
84
96
|
- lib/jabber_admin/commands/ban_account.rb
|
85
97
|
- lib/jabber_admin/commands/create_room.rb
|
86
98
|
- lib/jabber_admin/commands/create_room_with_opts.rb
|
@@ -102,7 +114,7 @@ files:
|
|
102
114
|
- lib/jabber_admin/commands/unregister.rb
|
103
115
|
- lib/jabber_admin/commands/unsubscribe_room.rb
|
104
116
|
- lib/jabber_admin/configuration.rb
|
105
|
-
- lib/jabber_admin/
|
117
|
+
- lib/jabber_admin/errors.rb
|
106
118
|
- lib/jabber_admin/version.rb
|
107
119
|
homepage:
|
108
120
|
licenses:
|
data/gemfiles/rails_5.2.gemfile
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "https://rubygems.org"
|
4
|
-
|
5
|
-
gem "appraisal", "~> 2.4"
|
6
|
-
gem "bundler", "~> 2.3"
|
7
|
-
gem "countless", "~> 1.1"
|
8
|
-
gem "guard-rspec", "~> 4.7"
|
9
|
-
gem "irb", "~> 1.2"
|
10
|
-
gem "railties", ">= 5.2"
|
11
|
-
gem "rake", "~> 13.0"
|
12
|
-
gem "rspec", "~> 3.12"
|
13
|
-
gem "rubocop", "~> 1.28"
|
14
|
-
gem "rubocop-rails", "~> 2.14"
|
15
|
-
gem "rubocop-rspec", "~> 2.10"
|
16
|
-
gem "simplecov", ">= 0.22"
|
17
|
-
gem "vcr", "~> 6.0"
|
18
|
-
gem "webmock", "~> 3.18"
|
19
|
-
gem "yard", ">= 0.9.28"
|
20
|
-
gem "yard-activesupport-concern", ">= 0.0.1"
|
21
|
-
gem "activesupport", "~> 5.2.0"
|
22
|
-
|
23
|
-
gemspec path: "../"
|
@@ -1,11 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module JabberAdmin
|
4
|
-
# Contains all predefined commands that are supported.
|
5
|
-
module Commands; end
|
6
|
-
end
|
7
|
-
|
8
|
-
# Require all commands from the commands subfolder
|
9
|
-
Dir[Pathname.new(__dir__).join('commands', '**', '*.rb')].sort.each do |file|
|
10
|
-
require file
|
11
|
-
end
|
File without changes
|