twitter2jabber 0.3.1 → 0.3.2

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.
data/README CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  == VERSION
4
4
 
5
- This documentation refers to twitter2jabber version 0.3.1
5
+ This documentation refers to twitter2jabber version 0.3.2
6
6
 
7
7
 
8
8
  == DESCRIPTION
@@ -73,8 +73,8 @@ class Twitter2Jabber
73
73
  log.sync = true
74
74
  logm 'HAI!'
75
75
 
76
- @twitter = twitter_connect(options[:twitter])
77
- @jabber = jabber_connect(options[:jabber])
76
+ twitter_connect(options[:twitter])
77
+ jabber_connect(options[:jabber])
78
78
 
79
79
  @filter = options[:filter] || block
80
80
  @formats = options[:formats] || DEFAULT_FORMATS
@@ -156,28 +156,32 @@ class Twitter2Jabber
156
156
 
157
157
  private
158
158
 
159
- def twitter_connect(options)
160
- auth = Twitter::OAuth.new(options[:consumer_token], options[:consumer_secret])
159
+ def twitter_connect(options = @twitter_options)
160
+ @twitter_options = options
161
+
162
+ auth = Twitter::OAuth.new(options[:consumer_token], options[:consumer_secret])
161
163
  auth.authorize_from_access(options[:access_token], options[:access_secret])
162
164
 
163
- client = Twitter::Base.new(auth)
165
+ @twitter = Twitter::Base.new(auth)
164
166
 
165
167
  # verify credentials
166
- client.verify_credentials
168
+ @twitter.verify_credentials
167
169
 
168
170
  logt 'connected'
169
171
 
170
- client
172
+ @twitter
171
173
  rescue Twitter::TwitterError => err
172
174
  raise "Can't connect to Twitter with ID '#{options[:consumer_token]}': #{err}"
173
175
  end
174
176
 
175
- def jabber_connect(options)
176
- client = Jabber::Simple.new(options[:user], options[:pass])
177
+ def jabber_connect(options = @jabber_options)
178
+ @jabber_options = options
179
+
180
+ @jabber = Jabber::Simple.new(options[:user], options[:pass])
177
181
 
178
182
  logj 'connected'
179
183
 
180
- client
184
+ @jabber
181
185
  rescue Jabber::JabberError => err
182
186
  raise "Can't connect to Jabber with JID '#{options[:user]}': #{err}"
183
187
  end
@@ -391,6 +395,7 @@ le[n[gth]] STATUS -- Determine length
391
395
  jabber.deliver(recipient, msg)
392
396
  rescue => err
393
397
  warn "#{err} (#{err.class})"
398
+ jabber_connect and retry if err.is_a?(Jabber::ServerDisconnected)
394
399
  end
395
400
 
396
401
  def update(msg, options = {})
@@ -4,7 +4,7 @@ class Twitter2Jabber
4
4
 
5
5
  MAJOR = 0
6
6
  MINOR = 3
7
- TINY = 1
7
+ TINY = 2
8
8
 
9
9
  class << self
10
10
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twitter2jabber
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 1
10
- version: 0.3.1
9
+ - 2
10
+ version: 0.3.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jens Wille
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-29 00:00:00 Z
18
+ date: 2011-05-03 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: twitter
@@ -149,7 +149,7 @@ rdoc_options:
149
149
  - UTF-8
150
150
  - --all
151
151
  - --title
152
- - twitter2jabber Application documentation (v0.3.1)
152
+ - twitter2jabber Application documentation (v0.3.2)
153
153
  require_paths:
154
154
  - lib
155
155
  required_ruby_version: !ruby/object:Gem::Requirement