xmpp4r-robot 0.2.3 → 0.3.0

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
  SHA1:
3
- metadata.gz: f3a308d413ded47b43f1f6d1f978f00dd6871e21
4
- data.tar.gz: a65354924d90b545c515010bacbeb8d069732bc3
3
+ metadata.gz: 69eac4120f6899a7ab40501a1d063896d19226e2
4
+ data.tar.gz: 4b01c17230863ee3bb9e9055f6976ed09a3319f9
5
5
  SHA512:
6
- metadata.gz: 7485c9ef92e7cfff7bd9614da22e1dbddbe3b4e4f6b911d410d2f5fdb3fd573930e0b51cb1bee175f3d94e53e7e4233e9633c07b755863f1625909f3d7d1e099
7
- data.tar.gz: e6a85af2d0de89655deb0ea08b1406c074e5ba2e0f9964d2cc088694810389c8da60efdc2d8385f6fee88969bcb051ed4dab5e6d1f843c5687697ed901c41359
6
+ metadata.gz: a3ec3c5ca0ebb09f75cd10a2e49f687175f6e6dd7cd985c05610f0d9abe67be5d1032545798c94ad38ce7dea38e8823afc4e4ec98bdd2bdcb55e5afaa1aa8509
7
+ data.tar.gz: aabd4acc8b4fa67b4a45906209731379bdd7a45e15def5d6b79d61d62905864bbaf7aa1b7b58c0141ff49b72c16520daf30d8e8dd2ac166d9d692dd36b3ea089
@@ -4,6 +4,6 @@ script: 'ruby -r bundler/setup -S rake test'
4
4
  rvm:
5
5
  - 1.9.3
6
6
  - 2.0.0
7
- - 2.1.0
7
+ - ruby
8
8
  - rbx
9
9
  - jruby
data/CHANGES.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # CHANGES
2
2
 
3
+ ## xmpp4r-robot 0.3.0 -- 2014-04-08
4
+
5
+ * Option :retry_time was removed. Instead, now we retry and wait
6
+ exponentially.
7
+
3
8
  ## xmpp4r-robot 0.2.3 -- 2014-03-12
4
9
 
5
10
  * Ignore nil exception. (why?)
data/README.md CHANGED
@@ -20,7 +20,7 @@ This is an attempt to make it easy for such use cases.
20
20
 
21
21
  ## REQUIREMENTS:
22
22
 
23
- * Tested with MRI (official CRuby) 2.0.0, 2.1.0, Rubinius and JRuby.
23
+ * Tested with MRI (official CRuby), Rubinius and JRuby.
24
24
 
25
25
  ## INSTALLATION:
26
26
 
@@ -32,7 +32,6 @@ This is an attempt to make it easy for such use cases.
32
32
  require 'xmpp4r/robot'
33
33
 
34
34
  robot = Jabber::Robot.new('someone@gmail.com', 'awesome password',
35
- :retry_time => 10,
36
35
  :auto_accept_subscription => true)
37
36
 
38
37
  robot.notify_presence do |from, status|
data/Rakefile CHANGED
@@ -8,6 +8,6 @@ end
8
8
 
9
9
  Gemgem.init(dir) do |s|
10
10
  s.name = 'xmpp4r-robot'
11
- s.version = '0.2.3'
11
+ s.version = '0.3.0'
12
12
  s.add_runtime_dependency('xmpp4r', '~> 0.5')
13
13
  end
@@ -17,12 +17,14 @@ class Jabber::Robot
17
17
  :away => Set.new,
18
18
  :unavailable => Set.new}
19
19
 
20
- @retry_time = Float(opts[:retry_time] || 0)
20
+ @retry_time = 1
21
21
  @auto_accept_subscription = opts[:auto_accept_subscription]
22
22
 
23
23
  @roster_mutex = Mutex.new
24
24
  @helper_mutex = Mutex.new
25
- @client = nil # eliminate warning
25
+ @client_mutex = Mutex.new
26
+ @client = nil # eliminate warning
27
+ @sleeping = false
26
28
  end
27
29
 
28
30
  def inspect
@@ -41,16 +43,20 @@ class Jabber::Robot
41
43
  #
42
44
  # @api public
43
45
  def start
44
- if @client # restart
45
- stop
46
- @client = nil
46
+ @client_mutex.synchronize do
47
+ @sleeping = false
48
+ if @client # restart
49
+ stop
50
+ @client = nil
51
+ end
52
+ initialize_callbacks
53
+ connect
54
+ login
55
+ available
56
+ roster
57
+ @retry_time = 1 # reset retry time after successfully connected
58
+ self
47
59
  end
48
- initialize_callbacks
49
- connect
50
- login
51
- available
52
- roster
53
- self
54
60
  end
55
61
 
56
62
  def stop
@@ -134,14 +140,19 @@ class Jabber::Robot
134
140
  next unless exp # why exp might be nil?
135
141
  errback.call(exp) if errback
136
142
 
137
- next if retry_time == 0.0
143
+ @client_mutex.synchronize do
144
+ @sleeping = true
145
+ @retry_time *= 2
138
146
 
139
- $stderr.puts "ERROR: #{exp}: #{exp.backtrace}" +
140
- " We'll sleep for #{retry_time} seconds and retry."
147
+ $stderr.puts "ERROR: #{exp}: #{exp.backtrace}" +
148
+ " We'll sleep for #{retry_time} seconds and retry."
141
149
 
142
- clear_roster_semaphore
143
- sleep(retry_time)
144
- start
150
+ clear_roster_semaphore
151
+ Thread.new do
152
+ sleep(retry_time)
153
+ start
154
+ end
155
+ end unless @sleeping
145
156
  end
146
157
 
147
158
  client.add_presence_callback do |presence|
@@ -1,14 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: xmpp4r-robot 0.2.3 ruby lib
2
+ # stub: xmpp4r-robot 0.3.0 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "xmpp4r-robot"
6
- s.version = "0.2.3"
6
+ s.version = "0.3.0"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib"]
10
10
  s.authors = ["Lin Jen-Shin (godfat)"]
11
- s.date = "2014-03-12"
11
+ s.date = "2014-04-08"
12
12
  s.description = "Simple XMPP client built upon xmpp4r. Intended for building simple robots."
13
13
  s.email = ["godfat (XD) godfat.org"]
14
14
  s.files = [
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xmpp4r-robot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lin Jen-Shin (godfat)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-12 00:00:00.000000000 Z
11
+ date: 2014-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xmpp4r