pidgin2adium 3.3.0 → 4.0.0.beta1

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.
Files changed (61) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +2 -3
  3. data/.rspec +1 -0
  4. data/.simplecov +5 -0
  5. data/.travis.yml +12 -0
  6. data/Gemfile +6 -1
  7. data/LICENSE +17 -17
  8. data/NEWS.md +89 -0
  9. data/README.md +60 -0
  10. data/Rakefile +5 -23
  11. data/bin/pidgin2adium +19 -90
  12. data/lib/pidgin2adium.rb +4 -136
  13. data/lib/pidgin2adium/adium_chat_file_creator.rb +64 -0
  14. data/lib/pidgin2adium/file_finder.rb +23 -0
  15. data/lib/pidgin2adium/runner.rb +23 -0
  16. data/lib/pidgin2adium/version.rb +1 -1
  17. data/pidgin2adium.gemspec +25 -21
  18. data/spec/features/parse_pidgin_log_file_spec.rb +50 -0
  19. data/spec/fixtures/input/input.html +3 -0
  20. data/spec/fixtures/output.xml +5 -0
  21. data/spec/pidgin2adium/adium_chat_file_creator_spec.rb +89 -0
  22. data/spec/pidgin2adium/file_finder_spec.rb +63 -0
  23. data/spec/spec_helper.rb +17 -59
  24. metadata +96 -89
  25. data/.autotest +0 -28
  26. data/ChangeLog +0 -79
  27. data/Manifest.txt +0 -18
  28. data/README.rdoc +0 -122
  29. data/config/website.yml +0 -2
  30. data/ext/balance_tags_c/balance_tags_c.c +0 -198
  31. data/ext/balance_tags_c/extconf.rb +0 -4
  32. data/lib/pidgin2adium/log_converter.rb +0 -71
  33. data/lib/pidgin2adium/log_file.rb +0 -100
  34. data/lib/pidgin2adium/log_parser.rb +0 -2
  35. data/lib/pidgin2adium/message.rb +0 -2
  36. data/lib/pidgin2adium/messages/all.rb +0 -5
  37. data/lib/pidgin2adium/messages/auto_reply_message.rb +0 -11
  38. data/lib/pidgin2adium/messages/event.rb +0 -17
  39. data/lib/pidgin2adium/messages/message.rb +0 -39
  40. data/lib/pidgin2adium/messages/status_message.rb +0 -17
  41. data/lib/pidgin2adium/messages/xml_message.rb +0 -40
  42. data/lib/pidgin2adium/parsers/all.rb +0 -3
  43. data/lib/pidgin2adium/parsers/basic_parser.rb +0 -456
  44. data/lib/pidgin2adium/parsers/html_log_parser.rb +0 -125
  45. data/lib/pidgin2adium/parsers/text_log_parser.rb +0 -39
  46. data/spec/balance_tags_c_extn_spec.rb +0 -47
  47. data/spec/basic_parser_spec.rb +0 -219
  48. data/spec/html_log_parser_spec.rb +0 -150
  49. data/spec/log_converter_spec.rb +0 -48
  50. data/spec/log_file_spec.rb +0 -176
  51. data/spec/logfiles/2006-12-21.223606.txt +0 -3
  52. data/spec/logfiles/2008-01-15.071445-0500PST.htm +0 -5
  53. data/spec/logfiles/2008-01-15.071445-0500PST.html +0 -5
  54. data/spec/pidgin2adium_spec.rb +0 -252
  55. data/spec/spec.opts +0 -1
  56. data/spec/test-output/README.md +0 -1
  57. data/spec/test-output/html_log_output.xml +0 -6
  58. data/spec/test-output/text_log_output.xml +0 -4
  59. data/spec/text_log_parser_spec.rb +0 -42
  60. data/tasks/extconf.rake +0 -8
  61. data/tasks/extconf/balance_tags_c.rake +0 -47
@@ -1,48 +0,0 @@
1
- require 'spec_helper'
2
- require 'pidgin2adium/log_converter'
3
- require 'fileutils'
4
-
5
- describe "LogConverter" do
6
- before(:each) do
7
- @converter = Pidgin2Adium::LogConverter.new(@logfile_path,
8
- @aliases,
9
- { :output_dir => @output_dir })
10
- Pidgin2Adium::LogConverter.stub!(:puts).and_return(nil)
11
- end
12
-
13
- describe "with non-existent input dir" do
14
- it "should raise ENOENT with correct error message" do
15
- lambda do
16
- converter = Pidgin2Adium::LogConverter.new("nonexistent-dir",
17
- @aliases)
18
- end.should raise_error(Errno::ENOENT)
19
- end
20
- end
21
-
22
- it "should have correct output when files don't exist" do
23
- FileUtils.rm_f(File.join(@output_dir, '*'))
24
- # Will only convert 2 files because the .htm file == the .html file
25
- Pidgin2Adium.should_receive(:log_msg).with(/Converted 2 files of 3 total/)
26
- @converter.start()
27
- end
28
-
29
- it "should have correct output when files do exist" do
30
- @converter.start() # create files
31
- Pidgin2Adium.should_receive(:log_msg).with(/Converted 0 files of 3 total/)
32
- @converter.start()
33
- end
34
-
35
- describe "#get_all_chat_files" do
36
- it "should return correct listings" do
37
- files = @converter.get_all_chat_files
38
- dir = File.join(File.dirname(File.expand_path(__FILE__)),
39
- 'logfiles')
40
-
41
- expected_files = %w{2006-12-21.223606.txt
42
- 2008-01-15.071445-0500PST.htm
43
- 2008-01-15.071445-0500PST.html}.map!{|f| File.join(dir, f) }
44
-
45
- files.sort.should == expected_files.sort
46
- end
47
- end
48
- end
@@ -1,176 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "LogFile" do
4
- before(:each) do
5
- @user_SN = "gabebw"
6
- @user_alias = "Gabe B-W"
7
-
8
- @partner_SN = "matz"
9
- @partner_alias = "Yukihiro Matsumoto"
10
-
11
- @start_time = "2010-08-10T22:55:07-0500"
12
- times = [@start_time,
13
- "2010-08-10T22:55:12-0500",
14
- "2010-08-10T22:55:17-0500",
15
- "2010-08-10T22:55:22-0500"]
16
-
17
- message_1 = Pidgin2Adium::XMLMessage.new(@user_SN, @start_time,
18
- @user_alias, "Hello!")
19
- message_2 = Pidgin2Adium::StatusMessage.new(@partner_SN, times[1],
20
- @partner_alias, "Matz has gone away")
21
-
22
- message_3 = Pidgin2Adium::Event.new(@user_SN, times[2], @user_alias,
23
- "gabebw logged in.", 'online')
24
-
25
- message_4 = Pidgin2Adium::AutoReplyMessage.new(@partner_SN, times[3],
26
- @partner_alias,
27
- "This is an away message")
28
-
29
- @messages = [message_1, message_2, message_3, message_4]
30
- @logfile = Pidgin2Adium::LogFile.new(@messages, 'aim', @user_SN,
31
- @partner_SN, @start_time)
32
- end
33
-
34
- describe "attributes" do
35
- it "should have chat_lines readable" do
36
- @logfile.should respond_to(:chat_lines)
37
- end
38
-
39
- it "should have service readable" do
40
- @logfile.should respond_to(:service)
41
- end
42
-
43
- it "should have user_SN readable" do
44
- @logfile.should respond_to(:user_SN)
45
- end
46
-
47
- it "should have partner_SN readable" do
48
- @logfile.should respond_to(:partner_SN)
49
- end
50
-
51
- it "should have adium_chat_time_start readable" do
52
- @logfile.should respond_to(:adium_chat_time_start)
53
- end
54
- end
55
-
56
- describe "#to_s" do
57
- it "should return the correct string" do
58
- output = @logfile.to_s
59
- output.should == @messages.map{|m| m.to_s}.join
60
- end
61
- end
62
-
63
-
64
- describe "enumerable methods" do
65
- it "should include Enumerable" do
66
- Pidgin2Adium::LogFile.included_modules.include?(Enumerable).should be_true
67
- end
68
-
69
- describe "#each_with_index" do
70
- it "should yield the correct messages" do
71
- @logfile.each_with_index do |msg, n|
72
- msg.should == @messages[n]
73
- end
74
- end
75
- end
76
-
77
- describe "#max" do
78
- it "should return the most recent message" do
79
- @logfile.max.should == @messages.last
80
- end
81
- end
82
-
83
- describe "#min" do
84
- it "should return the oldest message" do
85
- @logfile.min.should == @messages.first
86
- end
87
- end
88
- end
89
-
90
- describe "#write_out" do
91
- before(:each) do
92
- @output_file_path = File.join(@output_dir,
93
- 'AIM.gabebw',
94
- 'matz',
95
- "matz (#{@start_time}).chatlog",
96
- "matz (#{@start_time}).xml")
97
- end
98
-
99
- describe "when file does not exist" do
100
- before(:each) do
101
- FileUtils.rm_r(File.join(@output_dir, 'AIM.gabebw'),
102
- :force => true)
103
- @output_file = @logfile.write_out(false, @output_dir)
104
- end
105
-
106
- it "should write out the correct content" do
107
- IO.read(@output_file).include?(@logfile.to_s).should be_true
108
- end
109
-
110
- it "should write out the correct header" do
111
- header = sprintf('<?xml version="1.0" encoding="UTF-8" ?>'+"\n"+
112
- '<chat xmlns="http://purl.org/net/ulf/ns/0.4-02" account="gabebw" service="AIM">'+"\n")
113
- IO.read(@output_file).should =~ /^#{Regexp.escape(header)}/
114
- end
115
-
116
- it "should write out the closing </chat> tag" do
117
- IO.read(@output_file).should =~ %r{</chat>$}
118
- end
119
-
120
- it "should write to the correct path" do
121
- @output_file.should == @output_file_path
122
- end
123
- end
124
-
125
- describe "when file exists" do
126
- before(:each) do
127
- FileUtils.mkdir_p(File.dirname(@output_file_path))
128
- File.new(@output_file_path, 'w').close
129
- end
130
- it "should return FILE_EXISTS" do
131
- output_file = @logfile.write_out(false, @output_dir)
132
- output_file.should == Pidgin2Adium::FILE_EXISTS
133
- end
134
- it "should return output file path if overwrite is true" do
135
- output_file = @logfile.write_out(true, @output_dir)
136
- output_file.should == @output_file_path
137
- end
138
- end
139
-
140
- describe "permissions problems" do
141
- describe "with output dir" do
142
- before(:each) do
143
- FileUtils.rm_r(@output_dir, :force => true)
144
- `chmod -w #{File.dirname(@output_dir)}`
145
- end
146
-
147
- after(:each) do
148
- `chmod +w #{File.dirname(@output_dir)}`
149
- end
150
-
151
- it "should return false if it can't create the output dir" do
152
- @logfile.write_out(false, @output_dir).should be_false
153
- end
154
- end
155
-
156
- describe "with output file" do
157
- before(:each) do
158
- # Make parent dir unwriteable because creating the
159
- # file itself and making it unwriteable returns
160
- # FILE_EXISTS
161
- @output_file_parent_dir = File.dirname(@output_file_path)
162
- FileUtils.mkdir_p(@output_file_parent_dir)
163
- `chmod -w '#{@output_file_parent_dir}'`
164
- end
165
-
166
- after(:each) do
167
- `chmod +w '#{@output_file_parent_dir}'`
168
- end
169
-
170
- it "should return false if it can't open the output file for writing" do
171
- @logfile.write_out(false, @output_dir).should be_false
172
- end
173
- end
174
- end
175
- end
176
- end
@@ -1,3 +0,0 @@
1
- Conversation with BUDDY_PERSON at 2006-12-21 22:36:06 on awesome SN (aim)
2
- (22:36:11) Gabe B-W: what are you doing tomorrow?
3
- (23:06:06) Leola Farber III logged out.
@@ -1,5 +0,0 @@
1
- <head><meta http-equiv="content-type" content="text/html; charset=UTF-8"><title>Conversation with aolsystemmsg at 1/15/2008 7:14:45 AM on otherSN (aim)</title></head><h3>Conversation with aolsystemmsg at 1/15/2008 7:14:45 AM on otherSN (aim)</h3>
2
- <font color="#A82F2F"><font size="2">(2008-01-15 07:14:45)</font> <b>AOL System Msg:</b></font> Your screen name (otherSN) is now signed into AOL(R) Instant Messenger (TM) in 2 locations. To sign off the other location(s), reply to this message with the number 1. Click <a href='http://www.aim.com/password/routing.adp'>here</a> for more information.<br/>
3
- <font color="#16569E"><font size="2">(2008-01-15 07:14:48)</font> <b>Gabe B-W:</b></font> <span style='color: #000000;'>1</span><br/>
4
- <font color="#A82F2F"><font size="2">(2008-01-15 07:14:48)</font> <b>AOL System Msg:</b></font> Your other AIM sessions have been signed-off. You are now signed-on from 1 location(s).<br/>
5
-
@@ -1,5 +0,0 @@
1
- <head><meta http-equiv="content-type" content="text/html; charset=UTF-8"><title>Conversation with aolsystemmsg at 1/15/2008 7:14:45 AM on otherSN (aim)</title></head><h3>Conversation with aolsystemmsg at 1/15/2008 7:14:45 AM on otherSN (aim)</h3>
2
- <font color="#A82F2F"><font size="2">(2008-01-15 07:14:45)</font> <b>AOL System Msg:</b></font> Your screen name (otherSN) is now signed into AOL(R) Instant Messenger (TM) in 2 locations. To sign off the other location(s), reply to this message with the number 1. Click <a href='http://www.aim.com/password/routing.adp'>here</a> for more information.<br/>
3
- <font color="#16569E"><font size="2">(2008-01-15 07:14:48)</font> <b>Gabe B-W:</b></font> <span style='color: #000000;'>1</span><br/>
4
- <font color="#A82F2F"><font size="2">(2008-01-15 07:14:48)</font> <b>AOL System Msg:</b></font> Your other AIM sessions have been signed-off. You are now signed-on from 1 location(s).<br/>
5
-
@@ -1,252 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe "Pidgin2Adium" do
4
- before(:all) do
5
- @nonexistent_logfile_path = "./nonexistent_logfile_path/"
6
- end
7
-
8
- before(:each) do
9
- # "Kernel gets mixed in to an object, so you need to stub [its methods] on the object
10
- # itself." - http://www.ruby-forum.com/topic/128619
11
- Pidgin2Adium.stub!(:puts).and_return(nil) # Doesn't work in the before(:all) block
12
- end
13
-
14
- describe "constants" do
15
- it "should set ADIUM_LOG_DIR correctly" do
16
- Pidgin2Adium::ADIUM_LOG_DIR.should == File.expand_path('~/Library/Application Support/Adium 2.0/Users/Default/Logs/') + '/'
17
- end
18
-
19
- it "should set BAD_DIRS correctly" do
20
- Pidgin2Adium::BAD_DIRS.should == %w{. .. .DS_Store Thumbs.db .system}
21
- end
22
- end # constants
23
-
24
- describe "utility methods" do
25
- before(:each) do
26
- Pidgin2Adium.stub!(:log_msg).and_return(nil)
27
- end
28
-
29
- describe "::oops()" do
30
- it "should add a message to @@oops_messages" do
31
- message = "Oops! I messed up!"
32
- Pidgin2Adium.oops(message)
33
- Pidgin2Adium.send(:class_variable_get, :@@oops_messages).include?(message).should be_true
34
- end
35
- end
36
-
37
- describe "::error()" do
38
- it "should add a message to @@error_messages" do
39
- err_message = "Error! I *really* messed up!"
40
- Pidgin2Adium.error(err_message)
41
- Pidgin2Adium.send(:class_variable_get, :@@error_messages).include?(err_message).should be_true
42
- end
43
- end
44
-
45
- describe "#delete_search_indexes" do
46
- before(:each) do
47
- @dirty_file = File.expand_path("~/Library/Caches/Adium/Default/DirtyLogs.plist")
48
- @log_index_file = File.expand_path("~/Library/Caches/Adium/Default/Logs.index")
49
- end
50
-
51
- describe "when search indices exist" do
52
- before(:each) do
53
- `touch #{@dirty_file}`
54
- `touch #{@log_index_file}`
55
- end
56
-
57
- after(:each) do
58
- # Recreate search indices
59
- `touch #{@dirty_file}`
60
- `touch #{@log_index_file}`
61
- [@dirty_file, @log_index_file].each do |f|
62
- `chmod +w #{f}` # make writeable
63
- end
64
- end
65
-
66
- it "should delete the search indices when they are writeable" do
67
- [@dirty_file, @log_index_file].each do |f|
68
- `chmod +w #{f}` # make writeable
69
- end
70
- Pidgin2Adium.delete_search_indexes()
71
- File.exist?(@dirty_file).should be_false
72
- File.exist?(@log_index_file).should be_false
73
- end
74
-
75
- it "should give an error message when they are not writable" do
76
- [@dirty_file, @log_index_file].each do |f|
77
- `chmod -w #{f}` # make unwriteable
78
- end
79
- Pidgin2Adium.should_receive(:error).with("File exists but is not writable. Please delete it yourself: #{@dirty_file}")
80
- Pidgin2Adium.should_receive(:error).with("File exists but is not writable. Please delete it yourself: #{@log_index_file}")
81
- Pidgin2Adium.should_receive(:log_msg).with("...done.")
82
- Pidgin2Adium.should_receive(:log_msg).with("When you next start the Adium Chat Transcript Viewer, " +
83
- "it will re-index the logs, which may take a while.")
84
- Pidgin2Adium.delete_search_indexes()
85
- File.exist?(@dirty_file).should be_true
86
- File.exist?(@log_index_file).should be_true
87
- end
88
- end # when search indices exist
89
- end # delete_search_indexes
90
- end # utility methods
91
-
92
- describe "#parse" do
93
- describe "failure" do
94
- before(:each) do
95
- @weird_logfile_path = File.join(@current_dir, 'logfile.foobar')
96
- end
97
- it "should give an error when file is not text or html" do
98
- Pidgin2Adium.should_receive(:error).with(/Doing nothing, logfile is not a text or html file/)
99
- Pidgin2Adium.parse(@weird_logfile_path, @aliases).should be_false
100
- end
101
-
102
- it "should gracefully handle nonexistent files" do
103
- Pidgin2Adium.parse("i_do_not_exist.html", @aliases).should be_false
104
- Pidgin2Adium.parse("i_do_not_exist.txt", @aliases).should be_false
105
- end
106
- end # failure
107
-
108
- describe "success" do
109
- context "for a text file" do
110
- specify { Pidgin2Adium.parse(@text_logfile_path, @aliases).should be_instance_of(Pidgin2Adium::LogFile) }
111
- end
112
- context "for an htm file" do
113
- specify { Pidgin2Adium.parse(@htm_logfile_path, @aliases).should be_instance_of(Pidgin2Adium::LogFile) }
114
- end
115
- context "for an html file" do
116
- specify { Pidgin2Adium.parse(@html_logfile_path, @aliases).should be_instance_of(Pidgin2Adium::LogFile) }
117
- end
118
- end # success
119
- end # parse
120
-
121
- describe "#parse_and_generate" do
122
- before(:each) do
123
- # text logfile has screenname awesomeSN,
124
- # and html logfiles have screenname otherSN
125
- @text_output_file_path = File.join(@output_dir,
126
- "AIM.awesomeSN",
127
- "BUDDY_PERSON",
128
- "BUDDY_PERSON (2006-12-21T22.36.06-0700).chatlog",
129
- "BUDDY_PERSON (2006-12-21T22.36.06-0700).xml")
130
- @htm_output_file_path = File.join(@output_dir,
131
- "AIM.otherSN",
132
- "aolsystemmsg",
133
- "aolsystemmsg (2008-01-15T07.14.45-0500).chatlog",
134
- "aolsystemmsg (2008-01-15T07.14.45-0500).xml")
135
- @html_output_file_path = @htm_output_file_path
136
- end
137
-
138
- describe "failure" do
139
- describe "when output_dir does not exist" do
140
- before(:each) do
141
- @opts = { :output_dir => @nonexistent_output_dir }
142
- FileUtils.rm_r(@nonexistent_output_dir, :force => true)
143
- end
144
-
145
- after(:each) do
146
- # In case the test fails
147
- `chmod +w #{@current_dir}`
148
- end
149
-
150
- it "should return false when it can't create the output dir" do
151
- `chmod -w #{@current_dir}` # prevent creation of output_dir
152
- Pidgin2Adium.parse_and_generate(@text_logfile_path,
153
- @aliases,
154
- @opts).should be_false
155
- `chmod +w #{@current_dir}`
156
- end
157
- end
158
-
159
- describe "when output_dir does exist" do
160
- before(:each) do
161
- @opts = { :output_dir => @output_dir }
162
- end
163
-
164
- describe "when file already exists" do
165
- describe "when :force is not set" do
166
- context "for a text file" do
167
- before(:each) do
168
- FileUtils.mkdir_p(File.dirname(@text_output_file_path))
169
- File.new(@text_output_file_path, 'w').close # create file
170
- end
171
- it "should return FILE_EXISTS" do
172
- Pidgin2Adium.parse_and_generate(@text_logfile_path,
173
- @aliases,
174
- @opts).should == Pidgin2Adium::FILE_EXISTS
175
- end
176
- end
177
-
178
- context "for an HTM file" do
179
- before(:each) do
180
- FileUtils.mkdir_p(File.dirname(@htm_output_file_path))
181
- File.new(@htm_output_file_path, 'w').close # create file
182
- end
183
- it "should return FILE_EXISTS" do
184
- Pidgin2Adium.parse_and_generate(@htm_logfile_path,
185
- @aliases,
186
- @opts).should == Pidgin2Adium::FILE_EXISTS
187
- end
188
- end
189
-
190
- context "for an HTML file" do
191
- before(:each) do
192
- FileUtils.mkdir_p(File.dirname(@html_output_file_path))
193
- File.new(@html_output_file_path, 'w').close # create file
194
- end
195
- it "should return FILE_EXISTS" do
196
- Pidgin2Adium.parse_and_generate(@html_logfile_path,
197
- @aliases,
198
- @opts).should == Pidgin2Adium::FILE_EXISTS
199
- end
200
- end
201
- end
202
- end
203
- end
204
- end # failure
205
-
206
- describe "success" do
207
- describe "when output_dir does not exist" do
208
- before(:each) do
209
- @opts = { :output_dir => @nonexistent_output_dir }
210
- FileUtils.rm_r(@nonexistent_output_dir, :force => true)
211
- end
212
-
213
- context "for a text file" do
214
- specify { Pidgin2Adium.parse_and_generate(@text_logfile_path, @aliases, @opts).should be_true }
215
- end
216
- context "for an htm file" do
217
- specify { Pidgin2Adium.parse_and_generate(@htm_logfile_path, @aliases, @opts).should be_true }
218
- end
219
- context "for an html file" do
220
- specify { Pidgin2Adium.parse_and_generate(@html_logfile_path, @aliases, @opts).should be_true }
221
- end
222
- end
223
-
224
- describe "when output_dir does exist" do
225
- before(:each) do
226
- @opts = { :output_dir => @output_dir }
227
- end
228
- context "for a text file" do
229
- specify do
230
- Pidgin2Adium.parse_and_generate(@text_logfile_path,
231
- @aliases,
232
- @opts).should be_true
233
- end
234
- end
235
- context "for an htm file" do
236
- specify do
237
- Pidgin2Adium.parse_and_generate(@htm_logfile_path,
238
- @aliases,
239
- @opts).should be_true
240
- end
241
- end
242
- context "for an html file" do
243
- specify do
244
- Pidgin2Adium.parse_and_generate(@html_logfile_path,
245
- @aliases,
246
- @opts).should be_true
247
- end
248
- end
249
- end
250
- end # success
251
- end # parse_and_generate
252
- end