jabber_admin 1.0.0 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 31b521fdd1da155402e58b436e83fcb22012648b601f543fd5e885f844fd019e
4
- data.tar.gz: 9f14f04eaa52941167b0deaeb3322d1d1e947acf8ed2cc8e16cdc00dabeaa8a4
3
+ metadata.gz: 8b04fc09ea946409fccfdb4dd37b085e84418591c8c72f990b0e46c1ddb736e4
4
+ data.tar.gz: a9a74a6d345ba34ed5e06d81eda5df5140585778b5aae2196cb5263cccba2c1b
5
5
  SHA512:
6
- metadata.gz: 57e645f24f358c679b841cde89b8d8ee9fc978d5497a979ce5e87217f936af0438f9e8a75a1bcb94f9d2f195ea469fdc3be1f55137d8b20c66e5b04e0a61bf9d
7
- data.tar.gz: b26205f1387f7b50c2ac30407402017f5ab70aa89d64d34905f6c2ddddb26e3d05fa48b6a49f418eb9716c20ec2ce95327e97155f6ab0be9d2c88ff930a732bf
6
+ metadata.gz: 326f9d15f3866893a7ec92de4a4475f59848321c8ff9c879eff6fd7d8d46b8cccad5a15a6c167650b3fba532b410837ba57cdc372e56869b35fae49e333def06
7
+ data.tar.gz: 70733d53fb23eba46c48baf9300cefadb8cfe178e1130b8640dd014f782becc8077a4186a868c8cbed8d255f6d166955f52ae48850483e906bd6247f294ea769
@@ -0,0 +1,38 @@
1
+ name: Build Documentation
2
+ on:
3
+ repository_dispatch:
4
+ types: [documentation]
5
+
6
+ concurrency:
7
+ group: 'docs'
8
+
9
+ jobs:
10
+ docs:
11
+ name: Build gem documentation
12
+ runs-on: ubuntu-20.04
13
+ timeout-minutes: 5
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+
17
+ - name: Install the correct Ruby version
18
+ uses: ruby/setup-ruby@v1
19
+ with:
20
+ ruby-version: 2.5
21
+ bundler-cache: true
22
+
23
+ - name: Prepare the virtual environment
24
+ uses: hausgold/actions/ci@master
25
+ with:
26
+ clone_token: '${{ secrets.CLONE_TOKEN }}'
27
+ settings: '${{ github.repository }}'
28
+ target: ci/gem-test
29
+
30
+ - name: Build gem documentation
31
+ run: make docs
32
+
33
+ - name: Upload the code coverage report
34
+ run: coverage
35
+
36
+ - name: Add this job to the commit status
37
+ run: commit-status '${{ job.status }}'
38
+ if: always()
@@ -0,0 +1,59 @@
1
+ name: Test
2
+ on:
3
+ push:
4
+ branches:
5
+ - '**'
6
+ schedule:
7
+ - cron: '0 0 * * MON'
8
+
9
+ concurrency:
10
+ group: '${{ github.ref }}'
11
+ cancel-in-progress: true
12
+
13
+ jobs:
14
+ test:
15
+ name: 'Test the gem (Ruby ${{ matrix.ruby }})'
16
+ runs-on: ubuntu-20.04
17
+ timeout-minutes: 5
18
+ strategy:
19
+ fail-fast: false
20
+ matrix:
21
+ ruby: [2.5, 2.6, 2.7]
22
+ steps:
23
+ - uses: actions/checkout@v2
24
+
25
+ - name: Install the correct Ruby version
26
+ uses: ruby/setup-ruby@v1
27
+ with:
28
+ ruby-version: ${{ matrix.ruby }}
29
+ bundler-cache: true
30
+
31
+ - name: Prepare the virtual environment
32
+ uses: hausgold/actions/ci@master
33
+ with:
34
+ clone_token: '${{ secrets.CLONE_TOKEN }}'
35
+ settings: '${{ github.repository }}'
36
+ target: ci/gem-test
37
+
38
+ - name: Run the gem tests
39
+ run: make test
40
+
41
+ - name: Upload the code coverage report
42
+ run: coverage
43
+
44
+ trigger-docs:
45
+ name: Trigger the documentation upload
46
+ runs-on: ubuntu-20.04
47
+ timeout-minutes: 2
48
+ needs: test
49
+ if: github.ref == 'refs/heads/master'
50
+ steps:
51
+ - name: Prepare the virtual environment
52
+ uses: hausgold/actions/ci@master
53
+ with:
54
+ clone_token: '${{ secrets.CLONE_TOKEN }}'
55
+ settings: '${{ github.repository }}'
56
+ target: ci/noop
57
+
58
+ - name: Trigger the documentation upload
59
+ run: workflow documentation
data/.gitignore CHANGED
@@ -3,7 +3,7 @@
3
3
  /Gemfile.lock
4
4
  /_yardoc/
5
5
  /coverage/
6
- /doc/
6
+ /doc/api/
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
data/.yardopts CHANGED
@@ -1,4 +1,6 @@
1
- --output-dir=doc/app
1
+ --output-dir=doc/api
2
+ --plugin activesupport-concern
3
+ --markup=rdoc
2
4
  -
3
5
  README.md
4
6
  lib/**/*.rb
data/CHANGELOG.md CHANGED
@@ -1,3 +1,22 @@
1
+ ### 1.0.4
2
+
3
+ * Added support for the predefined command `destroy_room`
4
+
5
+ ### 1.0.3
6
+
7
+ * Migrated to Github Actions
8
+ * Migrated to our own coverage reporting
9
+ * Added the code statistics to the test process
10
+
11
+ ### 1.0.2
12
+
13
+ * Corrected the GNU Make release target
14
+ * Corrected the empty arguments check
15
+
16
+ ### 1.0.1
17
+
18
+ * Gracefully handle a missing vCard when a vCard field is queried (#7)
19
+
1
20
  ### 1.0.0
2
21
 
3
22
  * All `JabberAdmin` errors `[UnknownCommandError, CommandError, RequestError]`
data/Makefile CHANGED
@@ -28,17 +28,23 @@ SORT ?= sort
28
28
  BUNDLE ?= bundle
29
29
  RAKE ?= rake
30
30
  RUBOCOP ?= rubocop
31
+ YARD ?= yard
31
32
 
32
33
  all:
33
34
  # jabber_admin
34
35
  #
35
- # install Install the dependencies
36
- # test Run the whole test suite
37
- # test-style Check the coding styles
38
- # clean Clean the dependencies
36
+ # install Install the dependencies
37
+ # test Run the whole test suite
38
+ # test-style Check the coding styles
39
+ # clean Clean the dependencies
39
40
  #
40
- # shell Run an interactive shell on the container
41
- # shell-irb Run an interactive IRB shell on the container
41
+ # docs Generate the Ruby documentation of the library
42
+ # stats Print the code statistics (library and test suite)
43
+ # notes Print all the notes from the code
44
+ # release Release a new Gem version (maintainers only)
45
+ #
46
+ # shell Run an interactive shell on the container
47
+ # shell-irb Run an interactive IRB shell on the container
42
48
  #
43
49
  # supported-commands-list Generate the supported commands list
44
50
 
@@ -62,9 +68,13 @@ install:
62
68
  @$(MKDIR) -p $(VENDOR_DIR)
63
69
  @$(call run-shell,$(BUNDLE) check || $(BUNDLE) install --path $(VENDOR_DIR))
64
70
 
65
- test: install
71
+ test: \
72
+ test-specs \
73
+ test-style
74
+
75
+ test-specs:
66
76
  # Run the whole test suite
67
- @$(call run-shell,$(BUNDLE) exec $(RAKE))
77
+ @$(call run-shell,$(BUNDLE) exec $(RAKE) stats spec)
68
78
 
69
79
  test-style: test-style-ruby
70
80
 
@@ -84,17 +94,30 @@ endif
84
94
 
85
95
  distclean: clean clean-containers
86
96
 
87
- shell: install
97
+ shell:
88
98
  # Run an interactive shell on the container
89
99
  @$(call run-shell,$(BASH) -i)
90
100
 
91
- shell-irb: install
101
+ shell-irb:
92
102
  # Run an interactive IRB shell on the container
93
103
  @$(call run-shell,bin/console)
94
104
 
105
+ docs:
106
+ # Build the API documentation
107
+ @$(call run-shell,$(BUNDLE) exec $(YARD) -q && \
108
+ $(BUNDLE) exec $(YARD) stats --list-undoc --compact)
109
+
110
+ notes:
111
+ # Print the code statistics (library and test suite)
112
+ @$(call run-shell,$(BUNDLE) exec $(RAKE) notes)
113
+
114
+ stats:
115
+ # Print all the notes from the code
116
+ @$(call run-shell,$(BUNDLE) exec $(RAKE) stats)
117
+
95
118
  release:
96
119
  # Release a new gem version
97
- @$(RAKE) release
120
+ @$(BUNDLE) exec $(RAKE) release
98
121
 
99
122
  supported-commands-list:
100
123
  # Generate the supported commands list
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  ![jabber_admin](doc/assets/project.svg)
2
2
 
3
- [![Build Status](https://travis-ci.com/hausgold/jabber_admin.svg?branch=master)](https://travis-ci.com/hausgold/jabber_admin)
3
+ [![Continuous Integration](https://github.com/hausgold/jabber_admin/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/hausgold/jabber_admin/actions/workflows/test.yml)
4
4
  [![Gem Version](https://badge.fury.io/rb/jabber_admin.svg)](https://badge.fury.io/rb/jabber_admin)
5
- [![Maintainability](https://api.codeclimate.com/v1/badges/dd51c4668e97771baaba/maintainability)](https://codeclimate.com/repos/5cac8bcb6969c376ed007c70/maintainability)
6
- [![Test Coverage](https://api.codeclimate.com/v1/badges/dd51c4668e97771baaba/test_coverage)](https://codeclimate.com/repos/5cac8bcb6969c376ed007c70/test_coverage)
7
- [![API docs](https://img.shields.io/badge/docs-API-blue.svg)](https://www.rubydoc.info/gems/jabber_admin)
5
+ [![Test Coverage](https://automate-api.hausgold.de/v1/coverage_reports/jabber_admin/coverage.svg)](https://knowledge.hausgold.de/coverage)
6
+ [![Test Ratio](https://automate-api.hausgold.de/v1/coverage_reports/jabber_admin/ratio.svg)](https://knowledge.hausgold.de/coverage)
7
+ [![API docs](https://automate-api.hausgold.de/v1/coverage_reports/jabber_admin/documentation.svg)](https://www.rubydoc.info/gems/jabber_admin)
8
8
 
9
9
  jabber_admin is a small library to easily communicate with the [ejabberd
10
10
  admin API](https://docs.ejabberd.im/developer/ejabberd-api/admin-api).
@@ -114,6 +114,7 @@ Here comes a list of all supported predefined commands:
114
114
  - [subscribe_room](https://bit.ly/2Ke7Zoy)
115
115
  - [unregister](https://bit.ly/2wwYnDE)
116
116
  - [unsubscribe_room](https://bit.ly/2G5zcrj)
117
+ - [destroy_room](https://bit.ly/31CtqxB)
117
118
 
118
119
  If you want to contribute more, we accept pull requests!
119
120
 
data/Rakefile CHANGED
@@ -2,7 +2,75 @@
2
2
 
3
3
  require 'bundler/gem_tasks'
4
4
  require 'rspec/core/rake_task'
5
+ require 'rails/code_statistics'
6
+ require 'pp'
5
7
 
6
8
  RSpec::Core::RakeTask.new(:spec)
7
9
 
8
10
  task default: :spec
11
+
12
+ # Load some railties tasks
13
+ load 'rails/tasks/statistics.rake'
14
+ load 'rails/tasks/annotations.rake'
15
+
16
+ # Clear the default statistics directory constant
17
+ #
18
+ # rubocop:disable Style/MutableConstant because we define it
19
+ Object.send(:remove_const, :STATS_DIRECTORIES)
20
+ ::STATS_DIRECTORIES = []
21
+ # rubocop:enable Style/MutableConstant
22
+
23
+ # Monkey patch the Rails +CodeStatistics+ class to support configurable
24
+ # patterns per path. This is reuqired to support top-level only file matches.
25
+ class CodeStatistics
26
+ DEFAULT_PATTERN = /^(?!\.).*?\.(rb|js|coffee|rake)$/.freeze
27
+
28
+ # Pass the possible +pattern+ argument down to the
29
+ # +calculate_directory_statistics+ method call.
30
+ def calculate_statistics
31
+ Hash[@pairs.map do |pair|
32
+ [pair.first, calculate_directory_statistics(*pair[1..-1])]
33
+ end]
34
+ end
35
+
36
+ # Match the pattern against the individual file name and the relative file
37
+ # path. This allows top-level only matches.
38
+ def calculate_directory_statistics(directory, pattern = DEFAULT_PATTERN)
39
+ stats = CodeStatisticsCalculator.new
40
+
41
+ Dir.foreach(directory) do |file_name|
42
+ path = "#{directory}/#{file_name}"
43
+
44
+ if File.directory?(path) && (/^\./ !~ file_name)
45
+ stats.add(calculate_directory_statistics(path, pattern))
46
+ elsif file_name =~ pattern || path =~ pattern
47
+ stats.add_by_file_path(path)
48
+ end
49
+ end
50
+
51
+ stats
52
+ end
53
+ end
54
+
55
+ # Configure all code statistics directories
56
+ vendors = [
57
+ [:unshift, 'Top-levels', 'lib', %r{lib(/jabber_admin)?/[^/]+\.rb$}],
58
+ [:unshift, 'Top-levels specs', 'spec',
59
+ %r{spec/jabber_admin(_spec\.rb|/[^/]+\.rb$)}],
60
+
61
+ [:unshift, 'Commands', 'lib/jabber_admin/commands'],
62
+ [:unshift, 'Commands specs', 'spec/jabber_admin/commands']
63
+ ].reverse
64
+
65
+ vendors.each do |method, type, dir, pattern|
66
+ ::STATS_DIRECTORIES.send(method, [type, dir, pattern].compact)
67
+ ::CodeStatistics::TEST_TYPES << type if type.include? 'specs'
68
+ end
69
+
70
+ # Setup annotations
71
+ ENV['SOURCE_ANNOTATION_DIRECTORIES'] = 'spec,doc'
72
+
73
+ desc 'Enumerate all annotations'
74
+ task :notes do
75
+ SourceAnnotationExtractor.enumerate '@?OPTIMIZE|@?FIXME|@?TODO', tag: true
76
+ end
data/jabber_admin.gemspec CHANGED
@@ -39,6 +39,7 @@ Gem::Specification.new do |spec|
39
39
 
40
40
  spec.add_development_dependency 'bundler', '>= 1.16', '< 3'
41
41
  spec.add_development_dependency 'irb', '~> 1.2'
42
+ spec.add_development_dependency 'railties', '>= 4.2.0', '< 6.1'
42
43
  spec.add_development_dependency 'rake', '~> 13.0'
43
44
  spec.add_development_dependency 'rspec', '~> 3.9'
44
45
  spec.add_development_dependency 'rubocop', '~> 0.93'
@@ -46,4 +47,6 @@ Gem::Specification.new do |spec|
46
47
  spec.add_development_dependency 'simplecov', '< 0.18'
47
48
  spec.add_development_dependency 'vcr', '~> 6.0'
48
49
  spec.add_development_dependency 'webmock', '~> 3.0'
50
+ spec.add_development_dependency 'yard', '~> 0.9.18'
51
+ spec.add_development_dependency 'yard-activesupport-concern', '~> 0.0.1'
49
52
  end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module JabberAdmin
4
+ module Commands
5
+ # Destroys a given room (MUC).
6
+ #
7
+ # @see https://bit.ly/31CtqxB
8
+ class DestroyRoom
9
+ # Pass the correct data to the given callable.
10
+ #
11
+ # @param callable [Proc, #call] the callable to call
12
+ # @param room [String] room JID (eg. +room1@conference.localhost+)
13
+ # @param host [String] the jabber host (eg. +localhost+)
14
+ def self.call(callable, room:, host:)
15
+ name, service = room.split('@')
16
+ callable.call('destroy_room', name: name, service: service, host: host)
17
+ end
18
+ end
19
+ end
20
+ end
@@ -53,15 +53,15 @@ module JabberAdmin
53
53
  end
54
54
  end
55
55
 
56
- res = JSON.parse(callable.call(meth, check_res_body: false,
57
- user: uid,
58
- host: host,
59
- **args).body)
60
-
61
- res.is_a?(Hash) ? res['content'] : res
62
- rescue JabberAdmin::CommandError => e
56
+ res = callable.call(meth, check_res_body: false,
57
+ user: uid, host: host, **args)
58
+ body = (200..299).cover?(res.code) ? JSON.parse(res.body) : nil
59
+ body.is_a?(Hash) ? body['content'] : body
60
+ rescue JabberAdmin::Error => e
63
61
  # When ejabberd tells us there was no value, it does this the hard way
64
62
  next if e.response.body.include? 'error_no_value_found_in_vcard'
63
+ # Same for the case when there is no vCard at all
64
+ next if e.response.body.include? 'error_no_vcard_found'
65
65
 
66
66
  raise e
67
67
  end
@@ -1,9 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # The gem module.
3
4
  module JabberAdmin
4
5
  # The version constant of the gem. Increase this value
5
6
  # in case of a gem release.
6
- VERSION = '1.0.0'
7
+ VERSION = '1.0.4'
7
8
 
8
9
  class << self
9
10
  # Returns the version of gem as a string.
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.0.0
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henning Vogt
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2020-10-13 00:00:00.000000000 Z
12
+ date: 2021-11-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -79,6 +79,26 @@ dependencies:
79
79
  - - "~>"
80
80
  - !ruby/object:Gem::Version
81
81
  version: '1.2'
82
+ - !ruby/object:Gem::Dependency
83
+ name: railties
84
+ requirement: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: 4.2.0
89
+ - - "<"
90
+ - !ruby/object:Gem::Version
91
+ version: '6.1'
92
+ type: :development
93
+ prerelease: false
94
+ version_requirements: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: 4.2.0
99
+ - - "<"
100
+ - !ruby/object:Gem::Version
101
+ version: '6.1'
82
102
  - !ruby/object:Gem::Dependency
83
103
  name: rake
84
104
  requirement: !ruby/object:Gem::Requirement
@@ -177,6 +197,34 @@ dependencies:
177
197
  - - "~>"
178
198
  - !ruby/object:Gem::Version
179
199
  version: '3.0'
200
+ - !ruby/object:Gem::Dependency
201
+ name: yard
202
+ requirement: !ruby/object:Gem::Requirement
203
+ requirements:
204
+ - - "~>"
205
+ - !ruby/object:Gem::Version
206
+ version: 0.9.18
207
+ type: :development
208
+ prerelease: false
209
+ version_requirements: !ruby/object:Gem::Requirement
210
+ requirements:
211
+ - - "~>"
212
+ - !ruby/object:Gem::Version
213
+ version: 0.9.18
214
+ - !ruby/object:Gem::Dependency
215
+ name: yard-activesupport-concern
216
+ requirement: !ruby/object:Gem::Requirement
217
+ requirements:
218
+ - - "~>"
219
+ - !ruby/object:Gem::Version
220
+ version: 0.0.1
221
+ type: :development
222
+ prerelease: false
223
+ version_requirements: !ruby/object:Gem::Requirement
224
+ requirements:
225
+ - - "~>"
226
+ - !ruby/object:Gem::Version
227
+ version: 0.0.1
180
228
  description: Library for the ejabberd RESTful admin API
181
229
  email:
182
230
  - henning.vogt@hausgold.de
@@ -186,11 +234,12 @@ extensions: []
186
234
  extra_rdoc_files: []
187
235
  files:
188
236
  - ".editorconfig"
237
+ - ".github/workflows/documentation.yml"
238
+ - ".github/workflows/test.yml"
189
239
  - ".gitignore"
190
240
  - ".rspec"
191
241
  - ".rubocop.yml"
192
242
  - ".simplecov"
193
- - ".travis.yml"
194
243
  - ".yardopts"
195
244
  - CHANGELOG.md
196
245
  - Gemfile
@@ -210,6 +259,7 @@ files:
210
259
  - lib/jabber_admin/commands/ban_account.rb
211
260
  - lib/jabber_admin/commands/create_room.rb
212
261
  - lib/jabber_admin/commands/create_room_with_opts.rb
262
+ - lib/jabber_admin/commands/destroy_room.rb
213
263
  - lib/jabber_admin/commands/get_vcard.rb
214
264
  - lib/jabber_admin/commands/muc_register_nick.rb
215
265
  - lib/jabber_admin/commands/register.rb
@@ -248,7 +298,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
248
298
  - !ruby/object:Gem::Version
249
299
  version: '0'
250
300
  requirements: []
251
- rubygems_version: 3.1.4
301
+ rubygems_version: 3.2.21
252
302
  signing_key:
253
303
  specification_version: 4
254
304
  summary: Library for the ejabberd RESTful admin API
data/.travis.yml DELETED
@@ -1,18 +0,0 @@
1
- sudo: false
2
- env:
3
- global:
4
- - CC_TEST_REPORTER_ID=05f9944a34899135739ab519c57a179a3f4677999fd832fa87da25d3643702b7
5
- language: ruby
6
- rvm:
7
- - 2.6
8
- - 2.6
9
- - 2.5
10
- before_install: gem install bundler
11
- before_script:
12
- - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
13
- - chmod +x ./cc-test-reporter
14
- - ./cc-test-reporter before-build
15
- script:
16
- - bundle exec rspec
17
- after_script:
18
- - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT