pidgin2adium 3.2.0 → 3.2.1

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/ChangeLog CHANGED
@@ -1,3 +1,12 @@
1
+ === 3.2.1 / 2010-11-08
2
+ * Use straight DateTime.parse when possible, and only fall back on hacky
3
+ Date._strptime when we have to.
4
+
5
+ === 3.2.0 / 2010-10-12
6
+ * Last release broke 1.8 compatibility due to use of strptime. 1.8 and 1.9
7
+ both work in 3.2.0.
8
+ * Moved Pidgin2Adium::VERSION to its own file
9
+
1
10
  === 3.1.1 / 2010-08-13
2
11
  * Moved BasicParser and its subclasses into parsers/ subdir
3
12
  - You can now do "require 'pidgin2adium/parsers/all'",
@@ -24,6 +24,10 @@ module Pidgin2Adium
24
24
  # using this class directly.
25
25
  class BasicParser
26
26
  include Pidgin2Adium
27
+
28
+ # Minimal times don't have a date
29
+ MINIMAL_TIME_REGEX = /^\d{1,2}:\d{1,2}:\d{1,2}(?: [AP]M)?$/
30
+
27
31
  def initialize(src_path, user_aliases)
28
32
  @src_path = src_path
29
33
  # Whitespace is removed for easy matching later on.
@@ -195,7 +199,8 @@ module Pidgin2Adium
195
199
  "%Y-%m-%d %H:%M:%S", # 2008-01-22 23:08:24
196
200
  "%Y/%m/%d %H:%M:%S", # 2008/01/22 04:01:45
197
201
  "%Y-%m-%d %H:%M:%S", # 2008-01-22 04:01:45
198
- '%a %d %b %Y %H:%M:%S %p %Z' # "Sat 18 Apr 2009 10:43:35 AM PDT"
202
+ '%a %d %b %Y %H:%M:%S %p %Z', # "Sat 18 Apr 2009 10:43:35 AM PDT"
203
+ '%a %b %d %H:%M:%S %Y' # "Wed May 24 19:00:33 2006"
199
204
  ]
200
205
  try_to_parse_time_with_formats(time, formats)
201
206
  end
@@ -209,14 +214,29 @@ module Pidgin2Adium
209
214
  try_to_parse_time_with_formats(minimal_time, formats)
210
215
  end
211
216
 
217
+ # Returns true if the time is minimal, i.e. doesn't include a date.
218
+ # Otherwise returns false.
219
+ def is_minimal_time?(str)
220
+ not str.strip.match(MINIMAL_TIME_REGEX).nil?
221
+ end
222
+
212
223
  # Converts a pidgin datestamp to an Adium one.
213
224
  # Returns a string representation of _time_ or
214
225
  # nil if it couldn't parse the provided _time_.
215
226
  def create_adium_time(time)
216
227
  return nil if time.nil?
217
- new_time = try_to_parse_time(time)
218
- if new_time.nil?
228
+ if is_minimal_time?(time)
219
229
  new_time = try_to_parse_minimal_time(time)
230
+ else
231
+ begin
232
+ new_time = DateTime.parse(time)
233
+ rescue ArgumentError
234
+ new_time = try_to_parse_time(time)
235
+ if new_time.nil?
236
+ Pidgin2Adium.oops("#{time} couldn't be parsed. Please open an issue on GitHub: https://github.com/gabebw/pidgin2adium/issues")
237
+ return nil
238
+ end
239
+ end
220
240
  end
221
241
 
222
242
  return nil if new_time.nil?
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pidgin2Adium
2
- VERSION = "3.2.0"
2
+ VERSION = "3.2.1"
3
3
  end
data/pidgin2adium.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{pidgin2adium}
8
- s.version = "3.2.0"
8
+ s.version = "3.2.1"
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"]
12
- s.date = %q{2010-10-12}
12
+ s.date = %q{2010-11-08}
13
13
  s.default_executable = %q{pidgin2adium}
14
14
  s.description = %q{Pidgin2Adium is a fast, easy way to convert Pidgin (formerly gaim) logs to the Adium format.}
15
15
  s.email = %q{gbw@brandeis.edu}
@@ -29,22 +29,22 @@ describe "BasicParser" do
29
29
 
30
30
  it "should parse a first line time correctly" do
31
31
  time = @bp.create_adium_time(@first_line_time)
32
- time.should =~ /2007-04-18T11:02:00-\d{2}:00/
32
+ time.should =~ /2007-04-18T11:02:00[-+]\d{2}:00/
33
33
  end
34
34
 
35
35
  it "should parse a normal time correctly" do
36
36
  time = @bp.create_adium_time(@time)
37
- time.should =~ /2007-08-20T12:33:13-\d{2}:00/
37
+ time.should =~ /2007-08-20T12:33:13[-+]\d{2}:00/
38
38
  end
39
39
 
40
40
  it "should parse a minimal time correctly" do
41
41
  time = @bp.create_adium_time(@minimal_time)
42
- time.should =~ /2008-01-15T04:22:05-\d{2}:00/
42
+ time.should =~ /2008-01-15T04:22:05[-+]\d{2}:00/
43
43
  end
44
44
 
45
45
  it "should parse a minimal time without AM/PM correctly" do
46
46
  time = @bp.create_adium_time(@minimal_time_2)
47
- time.should =~ /2008-01-15T04:22:05-\d{2}:00/
47
+ time.should =~ /2008-01-15T04:22:05[-+]\d{2}:00/
48
48
  end
49
49
 
50
50
  it "should return an array of nils for an invalid time" do
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 3
7
7
  - 2
8
- - 0
9
- version: 3.2.0
8
+ - 1
9
+ version: 3.2.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Gabe Berke-Williams
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-10-12 00:00:00 -04:00
17
+ date: 2010-11-08 00:00:00 -05:00
18
18
  default_executable: pidgin2adium
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency