jabber_admin 0.1.4 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.editorconfig +30 -0
- data/.gitignore +4 -2
- data/.rubocop.yml +33 -0
- data/.simplecov +3 -0
- data/.travis.yml +7 -3
- data/.yardopts +4 -0
- data/CHANGELOG.md +30 -0
- data/Gemfile +4 -2
- data/Makefile +100 -0
- data/README.md +142 -22
- data/Rakefile +5 -3
- data/bin/console +4 -3
- data/docker-compose.yml +15 -0
- data/jabber_admin.gemspec +22 -15
- data/lib/jabber_admin.rb +100 -34
- data/lib/jabber_admin/api_call.rb +106 -20
- data/lib/jabber_admin/commands.rb +6 -5
- data/lib/jabber_admin/commands/ban_account.rb +11 -10
- data/lib/jabber_admin/commands/create_room.rb +15 -10
- data/lib/jabber_admin/commands/create_room_with_opts.rb +20 -14
- data/lib/jabber_admin/commands/muc_register_nick.rb +26 -0
- data/lib/jabber_admin/commands/register.rb +16 -11
- data/lib/jabber_admin/commands/registered_users.rb +8 -6
- data/lib/jabber_admin/commands/restart.rb +8 -5
- data/lib/jabber_admin/commands/send_direct_invitation.rb +19 -16
- data/lib/jabber_admin/commands/send_stanza.rb +12 -10
- data/lib/jabber_admin/commands/send_stanza_c2s.rb +28 -0
- data/lib/jabber_admin/commands/set_nickname.rb +22 -0
- data/lib/jabber_admin/commands/set_presence.rb +37 -0
- data/lib/jabber_admin/commands/set_room_affiliation.rb +17 -12
- data/lib/jabber_admin/commands/subscribe_room.rb +19 -12
- data/lib/jabber_admin/commands/unregister.rb +13 -7
- data/lib/jabber_admin/commands/unsubscribe_room.rb +10 -7
- data/lib/jabber_admin/configuration.rb +6 -1
- data/lib/jabber_admin/exceptions.rb +40 -0
- data/lib/jabber_admin/version.rb +3 -1
- metadata +85 -16
- data/lib/jabber_admin/initializer.rb +0 -6
| @@ -2,14 +2,17 @@ | |
| 2 2 |  | 
| 3 3 | 
             
            module JabberAdmin
         | 
| 4 4 | 
             
              module Commands
         | 
| 5 | 
            -
                 | 
| 6 | 
            -
                # | 
| 7 | 
            -
                # https:// | 
| 5 | 
            +
                # Subscribe to a MUC conference, via the mucsub feature.
         | 
| 6 | 
            +
                #
         | 
| 7 | 
            +
                # @see https://bit.ly/2G5zcrj
         | 
| 8 8 | 
             
                class UnsubscribeRoom
         | 
| 9 | 
            -
                  #  | 
| 10 | 
            -
                  # | 
| 11 | 
            -
                   | 
| 12 | 
            -
             | 
| 9 | 
            +
                  # Pass the correct data to the given callable.
         | 
| 10 | 
            +
                  #
         | 
| 11 | 
            +
                  # @param callable [Proc, #call] the callable to call
         | 
| 12 | 
            +
                  # @param user [String] user JID w/ resource (eg. +tom@localhost/dummy+)
         | 
| 13 | 
            +
                  # @param room [String] room JID (eg. +room1@conference.localhost+)
         | 
| 14 | 
            +
                  def self.call(callable, user:, room:)
         | 
| 15 | 
            +
                    callable.call('unsubscribe_room', user: user, room: room)
         | 
| 13 16 | 
             
                  end
         | 
| 14 17 | 
             
                end
         | 
| 15 18 | 
             
              end
         | 
| @@ -1,7 +1,12 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 3 | 
             
            module JabberAdmin
         | 
| 4 | 
            +
              # A JabberAdmin configuration definition. It is directly accessible via
         | 
| 5 | 
            +
              # +JabberAdmin.configuration+ or
         | 
| 6 | 
            +
              # +JabberAdmin.configure(&block(configuration))+ in a tapped variant.
         | 
| 7 | 
            +
              #
         | 
| 8 | 
            +
              # See the +JabberAdmin+ documentation for further details.
         | 
| 4 9 | 
             
              class Configuration
         | 
| 5 | 
            -
                attr_accessor : | 
| 10 | 
            +
                attr_accessor :username, :password, :url
         | 
| 6 11 | 
             
              end
         | 
| 7 12 | 
             
            end
         | 
| @@ -0,0 +1,40 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module JabberAdmin
         | 
| 4 | 
            +
              # The base exception which all other exceptions inherit. In case you want to
         | 
| 5 | 
            +
              # use our error handling with the bang variants, you can rescue all
         | 
| 6 | 
            +
              # exceptions like this:
         | 
| 7 | 
            +
              #
         | 
| 8 | 
            +
              #   begin
         | 
| 9 | 
            +
              #     JabberAdmin.COMMAND!
         | 
| 10 | 
            +
              #   rescue JabberAdmin::Error => err
         | 
| 11 | 
            +
              #     # Do your error handling here
         | 
| 12 | 
            +
              #   end
         | 
| 13 | 
            +
              class Error < StandardError
         | 
| 14 | 
            +
                attr_accessor :response
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                # Create a new exception.
         | 
| 17 | 
            +
                #
         | 
| 18 | 
            +
                # @param msg [String] the excpetion message
         | 
| 19 | 
            +
                # @param response [RestClient::Response] the response when available
         | 
| 20 | 
            +
                def initialize(msg, response = nil)
         | 
| 21 | 
            +
                  @response = response
         | 
| 22 | 
            +
                  super(msg)
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
              end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
              # This exception is raised when the request was denied due to premission
         | 
| 27 | 
            +
              # issues or a general unavaliability of the command on the REST API. This
         | 
| 28 | 
            +
              # simply means the response code from ejabberd was not 200 OK.
         | 
| 29 | 
            +
              class RequestError < Error; end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
              # This exception is raised when the response from the ejabberd REST API
         | 
| 32 | 
            +
              # indicated that the status of the command was not successful. In this case
         | 
| 33 | 
            +
              # the response body includes a one (1). In case everything was fine, it
         | 
| 34 | 
            +
              # includes a zero (0).
         | 
| 35 | 
            +
              class CommandError < Error; end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
              # This exception is raised when we send an unknown command to the REST API.
         | 
| 38 | 
            +
              # It will respond with a 404 status code in this case.
         | 
| 39 | 
            +
              class UnknownCommandError < Error; end
         | 
| 40 | 
            +
            end
         | 
    
        data/lib/jabber_admin/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,49 +1,50 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: jabber_admin
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.2.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Henning Vogt
         | 
| 8 | 
            +
            - Hermann Mayer
         | 
| 8 9 | 
             
            autorequire: 
         | 
| 9 10 | 
             
            bindir: exe
         | 
| 10 11 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2018- | 
| 12 | 
            +
            date: 2018-05-14 00:00:00.000000000 Z
         | 
| 12 13 | 
             
            dependencies:
         | 
| 13 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            -
              name:  | 
| 15 | 
            +
              name: activesupport
         | 
| 15 16 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 17 | 
             
                requirements:
         | 
| 17 | 
            -
                - - "~>"
         | 
| 18 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            -
                    version: '2.0'
         | 
| 20 18 | 
             
                - - ">="
         | 
| 21 19 | 
             
                  - !ruby/object:Gem::Version
         | 
| 22 | 
            -
                    version: 2. | 
| 20 | 
            +
                    version: 4.2.5
         | 
| 23 21 | 
             
              type: :runtime
         | 
| 24 22 | 
             
              prerelease: false
         | 
| 25 23 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 26 24 | 
             
                requirements:
         | 
| 27 | 
            -
                - - "~>"
         | 
| 28 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 29 | 
            -
                    version: '2.0'
         | 
| 30 25 | 
             
                - - ">="
         | 
| 31 26 | 
             
                  - !ruby/object:Gem::Version
         | 
| 32 | 
            -
                    version: 2. | 
| 27 | 
            +
                    version: 4.2.5
         | 
| 33 28 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 34 | 
            -
              name:  | 
| 29 | 
            +
              name: rest-client
         | 
| 35 30 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 36 31 | 
             
                requirements:
         | 
| 32 | 
            +
                - - "~>"
         | 
| 33 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 34 | 
            +
                    version: '2.0'
         | 
| 37 35 | 
             
                - - ">="
         | 
| 38 36 | 
             
                  - !ruby/object:Gem::Version
         | 
| 39 | 
            -
                    version:  | 
| 37 | 
            +
                    version: 2.0.2
         | 
| 40 38 | 
             
              type: :runtime
         | 
| 41 39 | 
             
              prerelease: false
         | 
| 42 40 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 43 41 | 
             
                requirements:
         | 
| 42 | 
            +
                - - "~>"
         | 
| 43 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 44 | 
            +
                    version: '2.0'
         | 
| 44 45 | 
             
                - - ">="
         | 
| 45 46 | 
             
                  - !ruby/object:Gem::Version
         | 
| 46 | 
            -
                    version:  | 
| 47 | 
            +
                    version: 2.0.2
         | 
| 47 48 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 48 49 | 
             
              name: bundler
         | 
| 49 50 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -86,6 +87,34 @@ dependencies: | |
| 86 87 | 
             
                - - "~>"
         | 
| 87 88 | 
             
                  - !ruby/object:Gem::Version
         | 
| 88 89 | 
             
                    version: '3.0'
         | 
| 90 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 91 | 
            +
              name: rubocop
         | 
| 92 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 93 | 
            +
                requirements:
         | 
| 94 | 
            +
                - - ">="
         | 
| 95 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 96 | 
            +
                    version: '0'
         | 
| 97 | 
            +
              type: :development
         | 
| 98 | 
            +
              prerelease: false
         | 
| 99 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 100 | 
            +
                requirements:
         | 
| 101 | 
            +
                - - ">="
         | 
| 102 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 103 | 
            +
                    version: '0'
         | 
| 104 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 105 | 
            +
              name: rubocop-rspec
         | 
| 106 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 107 | 
            +
                requirements:
         | 
| 108 | 
            +
                - - ">="
         | 
| 109 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 110 | 
            +
                    version: '0'
         | 
| 111 | 
            +
              type: :development
         | 
| 112 | 
            +
              prerelease: false
         | 
| 113 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 114 | 
            +
                requirements:
         | 
| 115 | 
            +
                - - ">="
         | 
| 116 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 117 | 
            +
                    version: '0'
         | 
| 89 118 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 90 119 | 
             
              name: simplecov
         | 
| 91 120 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -100,18 +129,53 @@ dependencies: | |
| 100 129 | 
             
                - - "~>"
         | 
| 101 130 | 
             
                  - !ruby/object:Gem::Version
         | 
| 102 131 | 
             
                    version: '0.15'
         | 
| 132 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 133 | 
            +
              name: vcr
         | 
| 134 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 135 | 
            +
                requirements:
         | 
| 136 | 
            +
                - - "~>"
         | 
| 137 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 138 | 
            +
                    version: '3.0'
         | 
| 139 | 
            +
              type: :development
         | 
| 140 | 
            +
              prerelease: false
         | 
| 141 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 142 | 
            +
                requirements:
         | 
| 143 | 
            +
                - - "~>"
         | 
| 144 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 145 | 
            +
                    version: '3.0'
         | 
| 146 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 147 | 
            +
              name: webmock
         | 
| 148 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 149 | 
            +
                requirements:
         | 
| 150 | 
            +
                - - "~>"
         | 
| 151 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 152 | 
            +
                    version: '3.0'
         | 
| 153 | 
            +
              type: :development
         | 
| 154 | 
            +
              prerelease: false
         | 
| 155 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 156 | 
            +
                requirements:
         | 
| 157 | 
            +
                - - "~>"
         | 
| 158 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 159 | 
            +
                    version: '3.0'
         | 
| 103 160 | 
             
            description: Library for the ejabberd RESTful admin API
         | 
| 104 161 | 
             
            email:
         | 
| 105 162 | 
             
            - henning.vogt@hausgold.de
         | 
| 163 | 
            +
            - hermann.mayer@hausgold.de
         | 
| 106 164 | 
             
            executables: []
         | 
| 107 165 | 
             
            extensions: []
         | 
| 108 166 | 
             
            extra_rdoc_files: []
         | 
| 109 167 | 
             
            files:
         | 
| 168 | 
            +
            - ".editorconfig"
         | 
| 110 169 | 
             
            - ".gitignore"
         | 
| 111 170 | 
             
            - ".rspec"
         | 
| 171 | 
            +
            - ".rubocop.yml"
         | 
| 172 | 
            +
            - ".simplecov"
         | 
| 112 173 | 
             
            - ".travis.yml"
         | 
| 174 | 
            +
            - ".yardopts"
         | 
| 175 | 
            +
            - CHANGELOG.md
         | 
| 113 176 | 
             
            - Gemfile
         | 
| 114 177 | 
             
            - LICENSE
         | 
| 178 | 
            +
            - Makefile
         | 
| 115 179 | 
             
            - README.md
         | 
| 116 180 | 
             
            - Rakefile
         | 
| 117 181 | 
             
            - bin/console
         | 
| @@ -119,6 +183,7 @@ files: | |
| 119 183 | 
             
            - doc/assets/logo.png
         | 
| 120 184 | 
             
            - doc/assets/project.png
         | 
| 121 185 | 
             
            - doc/assets/project.xcf
         | 
| 186 | 
            +
            - docker-compose.yml
         | 
| 122 187 | 
             
            - jabber_admin.gemspec
         | 
| 123 188 | 
             
            - lib/jabber_admin.rb
         | 
| 124 189 | 
             
            - lib/jabber_admin/api_call.rb
         | 
| @@ -126,17 +191,21 @@ files: | |
| 126 191 | 
             
            - lib/jabber_admin/commands/ban_account.rb
         | 
| 127 192 | 
             
            - lib/jabber_admin/commands/create_room.rb
         | 
| 128 193 | 
             
            - lib/jabber_admin/commands/create_room_with_opts.rb
         | 
| 194 | 
            +
            - lib/jabber_admin/commands/muc_register_nick.rb
         | 
| 129 195 | 
             
            - lib/jabber_admin/commands/register.rb
         | 
| 130 196 | 
             
            - lib/jabber_admin/commands/registered_users.rb
         | 
| 131 197 | 
             
            - lib/jabber_admin/commands/restart.rb
         | 
| 132 198 | 
             
            - lib/jabber_admin/commands/send_direct_invitation.rb
         | 
| 133 199 | 
             
            - lib/jabber_admin/commands/send_stanza.rb
         | 
| 200 | 
            +
            - lib/jabber_admin/commands/send_stanza_c2s.rb
         | 
| 201 | 
            +
            - lib/jabber_admin/commands/set_nickname.rb
         | 
| 202 | 
            +
            - lib/jabber_admin/commands/set_presence.rb
         | 
| 134 203 | 
             
            - lib/jabber_admin/commands/set_room_affiliation.rb
         | 
| 135 204 | 
             
            - lib/jabber_admin/commands/subscribe_room.rb
         | 
| 136 205 | 
             
            - lib/jabber_admin/commands/unregister.rb
         | 
| 137 206 | 
             
            - lib/jabber_admin/commands/unsubscribe_room.rb
         | 
| 138 207 | 
             
            - lib/jabber_admin/configuration.rb
         | 
| 139 | 
            -
            - lib/jabber_admin/ | 
| 208 | 
            +
            - lib/jabber_admin/exceptions.rb
         | 
| 140 209 | 
             
            - lib/jabber_admin/version.rb
         | 
| 141 210 | 
             
            homepage: https://github.com/hausgold/jabber_admin
         | 
| 142 211 | 
             
            licenses:
         | 
| @@ -159,7 +228,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 159 228 | 
             
                  version: '0'
         | 
| 160 229 | 
             
            requirements: []
         | 
| 161 230 | 
             
            rubyforge_project: 
         | 
| 162 | 
            -
            rubygems_version: 2.6 | 
| 231 | 
            +
            rubygems_version: 2.7.6
         | 
| 163 232 | 
             
            signing_key: 
         | 
| 164 233 | 
             
            specification_version: 4
         | 
| 165 234 | 
             
            summary: Library for the ejabberd RESTful admin API
         |