sendxmpp 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d5d4bb6fb3d967150680d2da594d1e0c332ac427
4
- data.tar.gz: f0598f85d0ce9140685bd9ecaef826d57663f254
3
+ metadata.gz: 727afe5351444d8aeffcce48ffef45ffde53476b
4
+ data.tar.gz: 437f238d2cf65f544a26b23ca45cc2b0acf8fdce
5
5
  SHA512:
6
- metadata.gz: da8d0c528714ad2a46092f11f9b7fc50c58976698d60ca11a04e16e678c5f001d0e6ea2ab0b4b6d1f6797c26f38a32d1e6d38ec31755b629707259a40b2e9cdb
7
- data.tar.gz: ec18db07f7134c7fb936e48b6a8ac11d012873e6372db00417ce2d19a90d7a633a4f7a104d065641d5162a27edd485d7643eec30b60db72c359257e2a7ac447d
6
+ metadata.gz: e2ee32f8db58c583ab877e512dda685b12ebef5f750082b9002dd8948f9db76fd53b3d11cb4f0a37813affbf6c0f45f03c93ee422d071766ad1c95a3a243f40f
7
+ data.tar.gz: c5567d460b9bda1342632de165c16b488cc91ff6647767516955aacf7b8ba71a9b674ef72c48ac71dd68e1e4b989fe6fef0b8e5c95df23d69b8cdd867461b788
@@ -23,7 +23,7 @@ module Sendxmpp
23
23
  class_option :resource, default: "Sendxmpp", type: :string, required: false
24
24
  class_option :password, default: "", type: :string, required: false
25
25
  class_option :message, default: "", type: :string, aliases: '-m', required: false
26
- class_option :jid, default: "", type: :string, required: false
26
+ class_option :jid, default: "", type: :string, required: false, aliases: '-j'
27
27
  class_option :config, default: "#{ENV['HOME']}/.sendxmpprbrc", type: :string, aliases: "-c", required: false
28
28
  class_option :logfile, default: nil, aliases: '-l', required: false
29
29
 
@@ -38,15 +38,16 @@ module Sendxmpp
38
38
  # Raises ArgumentError if the main hash key was not found
39
39
  def initialize(*args)
40
40
  super
41
+ local_conf = options.dup
42
+ local_conf.delete_if{|k,v|v.nil?||(v.kind_of?(String) && v.empty?)}
43
+ update_config(local_conf)
41
44
  if File.exists?(options[:config])
42
45
  conf = IniFile.load(options[:config])["sendxmpp"]
43
46
  if conf.nil? || conf.empty?
44
47
  raise ArgumentError, "No [sendxmpp] section in ini file found!"
45
48
  end
46
- local_conf = options.dup
47
- local_conf.delete_if{|k,v|v.nil?||(v.kind_of?(String) && v.empty?)}
48
- conf.merge!(local_conf)
49
- update_config(conf)
49
+ conf.merge!(local_conf)
50
+ update_config(conf)
50
51
  end
51
52
  Log.logger.debug("finished loading configuration.")
52
53
  $stdout.sync = true
@@ -14,7 +14,7 @@ module Sendxmpp
14
14
  else
15
15
  super(STDOUT)
16
16
  end
17
- self.level = config.loglevel.to_i || 2
17
+ self.level = (config.loglevel.nil?) ? WARN : config.loglevel.to_i
18
18
  end
19
19
  end
20
20
  end
@@ -28,24 +28,26 @@ module Sendxmpp
28
28
  def initialize
29
29
  @batch=false
30
30
  if config.jid.nil? || config.jid.empty?
31
- raise ArgumentError, <<-RAISE
32
- \rJID is not configured. Please use the configuration file or specify the
33
- \r-j option.
34
- RAISE
31
+ Log.logger.error("JID is not defined.")
32
+ Log.logger.error("Please use the -j option or the directive jid=... in .sendxmpprbrc")
33
+ exit 1
35
34
  end
36
-
37
35
  jid = JID.new(config.jid)
38
36
  Log.logger.debug("Initializing a new Jabber client instance.")
39
37
  self.client = Client.new(jid)
40
38
  Log.logger.debug("Initialized a new Jabber client instance.")
41
-
42
39
  Log.logger.debug("Connecting to Jabber server.")
43
40
  client.connect(config.server, config.port)
44
41
  Log.logger.debug("Connected to Jabber server.")
45
-
46
42
  Log.logger.debug("Authenticating with Jabber server.")
47
43
  client.auth(config.password)
48
44
  Log.logger.debug("Authenticating with Jabber server.")
45
+ rescue Jabber::ClientAuthenticationFailure => e
46
+ Log.logger.error("Authentication error for jid %s" % config.jid)
47
+ exit 1
48
+ rescue SocketError => e
49
+ Log.logger.error("There was an error connecting to the server: %s" % e.message)
50
+ exit 1
49
51
  end
50
52
 
51
53
  # Public: Singleton object getter
@@ -116,7 +118,8 @@ module Sendxmpp
116
118
  def process_batch(&block)
117
119
  Log.logger.info("Batch procession started.")
118
120
  unless block_given?
119
- raise ArgumentError, "Do not use this function without a block"
121
+ Log.logger.error("Please specify a block to use this function.")
122
+ exit 1
120
123
  end
121
124
  @batch=true
122
125
  yield
@@ -1,5 +1,5 @@
1
1
  module Sendxmpp
2
2
 
3
3
  # Public: version number
4
- VERSION="0.0.2"
4
+ VERSION="0.0.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sendxmpp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Kasper