Module: JabberAdmin
- Defined in:
- lib/jabber_admin.rb,
lib/jabber_admin/version.rb,
lib/jabber_admin/api_call.rb,
lib/jabber_admin/commands.rb,
lib/jabber_admin/exceptions.rb,
lib/jabber_admin/configuration.rb,
lib/jabber_admin/commands/restart.rb,
lib/jabber_admin/commands/register.rb,
lib/jabber_admin/commands/get_vcard.rb,
lib/jabber_admin/commands/set_vcard.rb,
lib/jabber_admin/commands/unregister.rb,
lib/jabber_admin/commands/ban_account.rb,
lib/jabber_admin/commands/create_room.rb,
lib/jabber_admin/commands/send_stanza.rb,
lib/jabber_admin/commands/destroy_room.rb,
lib/jabber_admin/commands/set_nickname.rb,
lib/jabber_admin/commands/set_presence.rb,
lib/jabber_admin/commands/subscribe_room.rb,
lib/jabber_admin/commands/send_stanza_c2s.rb,
lib/jabber_admin/commands/registered_users.rb,
lib/jabber_admin/commands/unsubscribe_room.rb,
lib/jabber_admin/commands/muc_register_nick.rb,
lib/jabber_admin/commands/set_room_affiliation.rb,
lib/jabber_admin/commands/create_room_with_opts.rb,
lib/jabber_admin/commands/get_room_affiliations.rb,
lib/jabber_admin/commands/send_direct_invitation.rb
Overview
The gem version details.
Defined Under Namespace
Modules: Commands Classes: ApiCall, CommandError, Configuration, Error, RequestError, UnknownCommandError
Constant Summary collapse
- VERSION =
The version of the
jabber_admin
gem '1.2.0'
Class Attribute Summary collapse
-
.configuration ⇒ JabberAdmin::Configuration
A simple getter to the global JabberAdmin configuration structure.
Class Method Summary collapse
-
.configure {|configuration| ... } ⇒ Object
Class method to set and change the global configuration.
-
.gem_version ⇒ Gem::Version
Returns the version of the gem as a
Gem::Version
. -
.method_missing(method, *args) ⇒ RestClient::Response
Allow an easy to use DSL on the
JabberAdmin
module. -
.predefined_callable(name) ⇒ Proc
Generate a matching API call wrapper for the given command name.
-
.predefined_command(name) ⇒ Class
Try to find the given name as a predefined command.
-
.respond_to_missing?(_method, _include_private = false) ⇒ Boolean
We support all methods if you ask for.
-
.room_exist?(room) ⇒ Boolean
Determine if a room exists.
-
.version ⇒ String
Returns the version of gem as a string.
Class Attribute Details
.configuration ⇒ JabberAdmin::Configuration
A simple getter to the global JabberAdmin configuration structure.
63 64 65 |
# File 'lib/jabber_admin.rb', line 63 def self.configuration @configuration ||= Configuration.new end |
Class Method Details
.configure {|configuration| ... } ⇒ Object
Class method to set and change the global configuration. This is just a tapped variant of the .configuration
method.
72 73 74 |
# File 'lib/jabber_admin.rb', line 72 def self.configure yield(configuration) end |
.gem_version ⇒ Gem::Version
Returns the version of the gem as a Gem::Version
.
19 20 21 |
# File 'lib/jabber_admin/version.rb', line 19 def gem_version Gem::Version.new VERSION end |
.method_missing(method, *args) ⇒ RestClient::Response
Allow an easy to use DSL on the JabberAdmin
module. We support predefined (known) commands and unknown ones in bang and non-bang variants. This allows maximum flexibility to the user. The bang versions perform the response checks and raise in case of issues. The non-bang versions skip this checks. For unknown commands the JabberAdmin::ApiCall
is directly utilized with the method name as command. (Without the trailling bang, when it is present)
87 88 89 90 91 |
# File 'lib/jabber_admin.rb', line 87 def self.method_missing(method, *args) predefined_command(method).call(predefined_callable(method), *args) rescue NameError predefined_callable(method).call(method.to_s.chomp('!'), *args) end |
.predefined_callable(name) ⇒ Proc
Generate a matching API call wrapper for the given command name. When we have to deal with a bang version, we pass the bang down to the API call instance. Otherwise we just run the regular #perform
method on the API call instance.
110 111 112 113 |
# File 'lib/jabber_admin.rb', line 110 def self.predefined_callable(name) method = name.to_s.end_with?('!') ? 'perform!' : 'perform' proc { |*args| ApiCall.send(method, *args) } end |
.predefined_command(name) ⇒ Class
Try to find the given name as a predefined command. When there is no such predefined command, we raise a NameError
.
98 99 100 101 |
# File 'lib/jabber_admin.rb', line 98 def self.predefined_command(name) # Remove bangs and build the camel case variant "JabberAdmin::Commands::#{name.to_s.chomp('!').camelize}".constantize end |
.respond_to_missing?(_method, _include_private = false) ⇒ Boolean
We support all methods if you ask for. This is our dynamic command approach here to support predefined and custom commands in the same namespace.
136 137 138 |
# File 'lib/jabber_admin.rb', line 136 def self.respond_to_missing?(_method, _include_private = false) true end |
.room_exist?(room) ⇒ Boolean
Determine if a room exists. This is a convenience method for the JabberAdmin::Commands::GetRoomAffiliations
command, which can be used to reliably determine whether a room exists or not.
121 122 123 124 125 126 127 128 |
# File 'lib/jabber_admin.rb', line 121 def self.room_exist?(room) get_room_affiliations!(room: room) true rescue JabberAdmin::CommandError => e raise e unless /room does not exist/.match? e.response.body false end |
.version ⇒ String
Returns the version of gem as a string.
12 13 14 |
# File 'lib/jabber_admin/version.rb', line 12 def version VERSION end |