pidgin2adium 3.2.2 → 3.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,3 +1,8 @@
1
+ === 3.2.3 / 2010-11-08
2
+ * Be more liberal in what Pidgin2Adium accepts when parsing the date and
3
+ getting basic time info for the first line. Thanks to Matthew Jakubowski for
4
+ helping me fix this bug.
5
+
1
6
  === 3.2.2 / 2010-11-08
2
7
  * Use DateTime#strftime to get dates in xmlschema format. DateTime#xmlschema
3
8
  doesn't exist in Ruby 1.8, and Ruby 1.9 has DateTime#iso8601, not
@@ -20,6 +25,7 @@ both work in 3.2.0.
20
25
  * Moved Message and its subclasses into messages/ subdir
21
26
  - You can now do "require 'pidgin2adium/messages/all'",
22
27
  though the old "require 'pidgin2adium/message" will still work
28
+
23
29
  === 3.1.0 / 2010-08-13
24
30
  * Compatible with Ruby 1.9!
25
31
  - removed dependency on "parsedate" library, which 1.9 doesn't have
@@ -28,6 +28,13 @@ module Pidgin2Adium
28
28
  # Minimal times don't have a date
29
29
  MINIMAL_TIME_REGEX = /^\d{1,2}:\d{1,2}:\d{1,2}(?: [AP]M)?$/
30
30
 
31
+ # Time regexes must be set before pre_parse!().
32
+ # "4/18/2007 11:02:00 AM" => %w{4, 18, 2007}
33
+ # ONLY used (if at all) in first line of chat ("Conversation with...at...")
34
+ TIME_REGEX_FIRST_LINE = %r{^(\d{1,2})/(\d{1,2})/(\d{4}) \d{1,2}:\d{2}:\d{2} [AP]M$}
35
+ # "2007-04-17 12:33:13" => %w{2007, 04, 17}
36
+ TIME_REGEX = /^(\d{4})-(\d{2})-(\d{2}) \d{2}:\d{2}:\d{2}$/
37
+
31
38
  def initialize(src_path, user_aliases)
32
39
  @src_path = src_path
33
40
  # Whitespace is removed for easy matching later on.
@@ -50,13 +57,6 @@ module Pidgin2Adium
50
57
  return nil
51
58
  end
52
59
 
53
- # Time regexes must be set before pre_parse!().
54
- # "4/18/2007 11:02:00 AM" => %w{4, 18, 2007}
55
- # ONLY used (if at all) in first line of chat ("Conversation with...at...")
56
- @time_regex_first_line = %r{^(\d{1,2})/(\d{1,2})/(\d{4}) \d{1,2}:\d{2}:\d{2} [AP]M$}
57
- # "2007-04-17 12:33:13" => %w{2007, 04, 17}
58
- @time_regex = /^(\d{4})-(\d{2})-(\d{2}) \d{2}:\d{2}:\d{2}$/
59
-
60
60
  begin
61
61
  successfully_set_variables = pre_parse!
62
62
  if not successfully_set_variables
@@ -286,23 +286,52 @@ module Pidgin2Adium
286
286
  # You should be able to fill everything else in. If you can't,
287
287
  # something's wrong.
288
288
  @basic_time_info = case pidgin_chat_time_start
289
- when @time_regex
289
+ when TIME_REGEX
290
290
  {:year => $1.to_i,
291
291
  :mon => $2.to_i,
292
292
  :mday => $3.to_i}
293
- when @time_regex_first_line
293
+ when TIME_REGEX_FIRST_LINE
294
294
  {:year => $3.to_i,
295
295
  :mon => $1.to_i,
296
296
  :mday => $2.to_i}
297
+ else
298
+ nil
297
299
  end
298
- # Need @basic_time_info set for create_adium_time
300
+ if @basic_time_info.nil?
301
+ begin
302
+ parsed_time = DateTime.parse(pidgin_chat_time_start)
303
+ @basic_time_info = {:year => parsed_time.year,
304
+ :mon => parsed_time.mon,
305
+ :mday => parsed_time.mday}
306
+ rescue ArgumentError
307
+ # Couldn't parse the date
308
+ Pidgin2Adium.oops("#{@src_path}: couldn't parse the date in the first line.")
309
+ @basic_time_info = nil
310
+ end
311
+ end
312
+
313
+ # Note: need @basic_time_info set for create_adium_time
299
314
  # When the chat started, in Adium's format
300
315
  @adium_chat_time_start = create_adium_time(pidgin_chat_time_start)
301
- [@service,
302
- @user_SN,
303
- @partner_SN,
304
- @basic_time_info,
305
- @adium_chat_time_start].all?
316
+
317
+ first_line_variables = [@service,
318
+ @user_SN,
319
+ @partner_SN,
320
+ @basic_time_info,
321
+ @adium_chat_time_start]
322
+ if first_line_variables.all?
323
+ true
324
+ else
325
+ # Print an informative error message
326
+ unset_variable_names = []
327
+ unset_variable_names << 'service' if @service.nil?
328
+ unset_variable_names << 'user_SN' if @user_SN.nil?
329
+ unset_variable_names << 'partner_SN' if @partner_SN.nil?
330
+ unset_variable_names << 'basic_time_info' if @basic_time_info.nil?
331
+ unset_variable_names << 'adium_chat_time_start' if @adium_chat_time_start.nil?
332
+ Pidgin2Adium.oops("Couldn't set these variables: #{unset_variable_names.join(', ')}")
333
+ false
334
+ end
306
335
  end
307
336
  end
308
337
 
@@ -357,7 +386,7 @@ module Pidgin2Adium
357
386
  # Return nil, which will get compact'ed out
358
387
  return nil if @ignore_events.detect{|regex| str =~ regex }
359
388
 
360
- regex, status = @status_map.detect{|regex, status| str =~ regex}
389
+ regex, status = @status_map.detect{|rxp, stat| str =~ rxp}
361
390
  if regex and status
362
391
  # Status message
363
392
  buddy_alias = regex.match(str)[1]
@@ -365,11 +394,11 @@ module Pidgin2Adium
365
394
  msg = StatusMessage.new(sender, time, buddy_alias, status)
366
395
  else
367
396
  # Test for event
368
- regex = @lib_purple_events.detect{|regex| str =~ regex }
397
+ regex = @lib_purple_events.detect{|rxp| str =~ rxp }
369
398
  event_type = 'libpurpleEvent' if regex
370
399
  unless regex and event_type
371
400
  # not a libpurple event, try others
372
- regex, event_type = @event_map.detect{|regex,event_type| str =~ regex}
401
+ regex, event_type = @event_map.detect{|rxp,ev_type| str =~ rxp}
373
402
  unless regex and event_type
374
403
  error(sprintf("Error parsing status or event message, no status or event found: %p", str))
375
404
  return false
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pidgin2Adium
2
- VERSION = "3.2.2"
2
+ VERSION = "3.2.3"
3
3
  end
data/pidgin2adium.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{pidgin2adium}
8
- s.version = "3.2.2"
8
+ s.version = "3.2.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Gabe Berke-Williams"]
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 3
7
7
  - 2
8
- - 2
9
- version: 3.2.2
8
+ - 3
9
+ version: 3.2.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Gabe Berke-Williams