pidgin2adium 3.0.1 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/spec/spec_helper.rb CHANGED
@@ -1,19 +1,72 @@
1
- $LOAD_PATH.unshift(File.dirname(__FILE__))
2
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
- require 'pidgin2adium'
4
- begin
5
- # RSpec 2
6
- gem 'rspec', '>= 2.0.0.beta.18'
7
- require 'rspec'
8
- constant = RSpec
9
- rescue Gem::LoadError
10
- # RSpec 1
11
- gem 'rspec', '~> 1.3'
12
- require 'spec'
13
- require 'spec/autorun'
14
- constant = Spec::Runner
15
- end
1
+ require 'fileutils'
2
+
3
+ # Pidgin2Adium.oops and Pidgin2Adium.warn both use warn() to output errors.
4
+ # Setting $-w (the warning level) to nil suppresses them, which makes for
5
+ # much prettier test output.
6
+ $-w=nil # OMGHAX
7
+
8
+ # Wrap it in a lambda so that we can pass it to Spork.prefork, if spork is installed.
9
+ prefork_block = lambda do
10
+ # Loading more in this block will cause your tests to run faster. However,
11
+ # if you change any configuration or code from libraries loaded here, you'll
12
+ # need to restart spork for it take effect.
13
+
14
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
15
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
16
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'ext', 'balance_tags_c'))
17
+
18
+ require 'pidgin2adium'
19
+ require 'faker'
20
+ require 'time' # for Time.zone_offset
16
21
 
17
- constant.configure do |config|
22
+ rspec_configure_block = lambda do |config|
23
+ config.before(:all) do
24
+ @current_dir = File.dirname(__FILE__)
25
+ @aliases = %w{gabebw gabeb-w gbw me}.join(',')
26
+ # -7 => "-0700"
27
+ @current_tz_offset = sprintf("%+03d00", Time.zone_offset(Time.new.zone) / 3600)
18
28
 
29
+ @logfile_path = File.join(@current_dir, "logfiles/")
30
+ @text_logfile_path = "#{@logfile_path}/2006-12-21.223606.txt"
31
+ @htm_logfile_path = "#{@logfile_path}/2008-01-15.071445-0500PST.htm"
32
+ @html_logfile_path = "#{@logfile_path}/2008-01-15.071445-0500PST.html"
33
+
34
+ @nonexistent_output_dir = File.join(@current_dir, "nonexistent_output_dir/")
35
+ @output_dir = File.join(@current_dir, "output-dir/")
36
+ FileUtils.rm_r(@nonexistent_output_dir, :force => true)
37
+ end
38
+
39
+ config.after(:all) do
40
+ # Clean up.
41
+ FileUtils.rm_r(@nonexistent_output_dir, :force => true)
42
+ FileUtils.rm_r(@output_dir, :force => true)
43
+ end
44
+ end
45
+
46
+ begin
47
+ # RSpec 2
48
+ gem 'rspec', '>= 2.0.0.beta.18'
49
+ require 'rspec'
50
+ RSpec.configure(&rspec_configure_block)
51
+ rescue Gem::LoadError
52
+ # RSpec 1
53
+ gem 'rspec', '~> 1.3'
54
+ require 'spec'
55
+ require 'spec/autorun'
56
+ Spec::Runner.configure(&rspec_configure_block)
57
+ end
58
+ end
59
+
60
+ begin
61
+ require 'rubygems'
62
+ require 'spork'
63
+ Spork.prefork(&prefork_block)
64
+ Spork.each_run do
65
+ # This code will be run each time you run your specs.
66
+ end
67
+ rescue LoadError
68
+ puts 'To make the tests run faster, run "sudo gem install spork" then run "spork"'
69
+ puts 'from the base pidgin2adium directory.'
70
+ # Spork isn't installed.
71
+ prefork_block.call
19
72
  end
@@ -0,0 +1 @@
1
+ This folder holds already-parsed logs to allow for testing that Pidgin2Adium's output is correct.
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+ <chat xmlns="http://purl.org/net/ulf/ns/0.4-02" account="jiggerificbug" service="AIM">
3
+ <message sender="aolsystemmsg" time="2008-01-15T07:14:45-0500" alias="AOL System Msg"><div><span style="font-family: Helvetica; font-size: 12pt;">Your screen name (jiggerificbug) 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.</span></div></message>
4
+ <message sender="jiggerificbug" time="2008-01-15T07:14:48-0500" alias="Gabe B-W"><div><span style="font-family: Helvetica; font-size: 12pt;">1</span></div></message>
5
+ <message sender="aolsystemmsg" time="2008-01-15T07:14:48-0500" alias="AOL System Msg"><div><span style="font-family: Helvetica; font-size: 12pt;">Your other AIM sessions have been signed-off. You are now signed-on from 1 location(s).</span></div></message>
6
+ </chat>
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+ <chat xmlns="http://purl.org/net/ulf/ns/0.4-02" account="jiggerificbug" service="AIM">
3
+ <message sender="jiggerificbug" time="2006-12-21T22:36:11-0700" alias="Gabe B-W"><div><span style="font-family: Helvetica; font-size: 12pt;">what are you doing tomorrow?</span></div></message>
4
+ </chat>
@@ -0,0 +1,42 @@
1
+ require 'spec_helper'
2
+
3
+ describe "TextLogParser" do
4
+ before(:each) do
5
+ @time = '(04:20:06)'
6
+ @tlp = Pidgin2Adium::TextLogParser.new(@text_logfile_path,
7
+ @aliases)
8
+ end
9
+ it "should cleanup text correctly" do
10
+ dirty_text = %Q{\r\n#{@time}&<b>Hello!</b> "Hi!" 'Oh no'\n}
11
+ # "\n" not removed if it ends a line or is followed by
12
+ # a timestamp
13
+ clean_text = %Q{\n#{@time}&amp;&lt;b&gt;Hello!&lt;/b&gt; &quot;Hi!&quot; &apos;Oh no&apos;\n}
14
+ @tlp.cleanup(dirty_text).should == clean_text
15
+ end
16
+
17
+ describe "#parse" do
18
+ it "should return a LogFile instance" do
19
+ @tlp.parse().should be_instance_of(Pidgin2Adium::LogFile)
20
+ end
21
+
22
+ it "should return a LogFile with the correct number of chat_lines" do
23
+ logfile = @tlp.parse
24
+ logfile.chat_lines.size.should == 1
25
+ end
26
+
27
+ it "should return a LogFile with the correct message type" do
28
+ logfile = @tlp.parse
29
+ logfile.chat_lines[0].should be_instance_of(Pidgin2Adium::XMLMessage)
30
+ end
31
+
32
+ it "should return a LogFile with the correct data" do
33
+ logfile = @tlp.parse
34
+ msg = logfile.chat_lines[0]
35
+ msg.sender.should == "awesomesn"
36
+ msg.body.should == "what are you doing tomorrow?"
37
+ msg.buddy_alias.should == "Gabe B-W"
38
+ # Use regex to ignore time zone
39
+ msg.time.should =~ /^2006-12-21T22:36:11[-+]\d{2}00$/
40
+ end
41
+ end
42
+ end
@@ -1,3 +1,5 @@
1
+ require 'rbconfig'
2
+
1
3
  namespace :extconf do
2
4
  extension = File.basename(__FILE__, '.rake')
3
5
 
@@ -12,6 +14,8 @@ namespace :extconf do
12
14
  # "lib"
13
15
  ]
14
16
 
17
+ is_windows = Config::CONFIG['host_os'] =~ /mswin|mingw/
18
+ make_command = is_windows ? 'nmake' : 'make'
15
19
 
16
20
  task :compile => extension do
17
21
  if Dir.glob("**/#{extension}.{o,so,dll}").length == 0
@@ -32,7 +36,7 @@ namespace :extconf do
32
36
 
33
37
  file ext_so => ext_files do
34
38
  Dir.chdir(ext) do
35
- sh(PLATFORM =~ /win32/ ? 'nmake' : 'make') do |ok, res|
39
+ sh(make_command) do |ok, res|
36
40
  if !ok
37
41
  require "fileutils"
38
42
  FileUtils.rm Dir.glob('*.{so,o,dll,bundle}')
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pidgin2adium
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
5
4
  prerelease: false
6
5
  segments:
7
6
  - 3
8
- - 0
9
7
  - 1
10
- version: 3.0.1
8
+ - 0
9
+ version: 3.1.0
11
10
  platform: ruby
12
11
  authors:
13
12
  - Gabe Berke-Williams
@@ -15,91 +14,102 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-08-07 00:00:00 -07:00
19
- default_executable:
17
+ date: 2010-08-13 00:00:00 -07:00
18
+ default_executable: pidgin2adium
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
- type: :development
21
+ name: bundler
23
22
  prerelease: false
24
- version_requirements: &id001 !ruby/object:Gem::Requirement
23
+ requirement: &id001 !ruby/object:Gem::Requirement
25
24
  none: false
26
25
  requirements:
27
26
  - - ">="
28
27
  - !ruby/object:Gem::Version
29
- hash: 15
30
28
  segments:
31
29
  - 0
32
30
  - 9
33
31
  - 26
34
32
  version: 0.9.26
35
- name: bundler
36
- requirement: *id001
37
- - !ruby/object:Gem::Dependency
38
33
  type: :development
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: jeweler
39
37
  prerelease: false
40
- version_requirements: &id002 !ruby/object:Gem::Requirement
38
+ requirement: &id002 !ruby/object:Gem::Requirement
41
39
  none: false
42
40
  requirements:
43
41
  - - ">="
44
42
  - !ruby/object:Gem::Version
45
- hash: 3
46
43
  segments:
47
44
  - 0
48
45
  version: "0"
49
- name: jeweler
50
- requirement: *id002
51
- - !ruby/object:Gem::Dependency
52
46
  type: :development
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: rspec
53
50
  prerelease: false
54
- version_requirements: &id003 !ruby/object:Gem::Requirement
51
+ requirement: &id003 !ruby/object:Gem::Requirement
55
52
  none: false
56
53
  requirements:
57
54
  - - ">="
58
55
  - !ruby/object:Gem::Version
59
- hash: 13
60
56
  segments:
61
57
  - 1
62
58
  - 2
63
59
  - 9
64
60
  version: 1.2.9
65
- name: rspec
66
- requirement: *id003
61
+ type: :development
62
+ version_requirements: *id003
67
63
  description: Pidgin2Adium is a fast, easy way to convert Pidgin (formerly gaim) logs to the Adium format.
68
64
  email: gbw@brandeis.edu
69
65
  executables:
70
66
  - pidgin2adium
71
- - pidgin2adium_profiler
72
67
  extensions:
73
68
  - ext/balance_tags_c/extconf.rb
74
69
  extra_rdoc_files:
70
+ - ChangeLog
75
71
  - LICENSE
76
72
  - README.rdoc
77
73
  files:
78
74
  - .autotest
79
75
  - .gitignore
80
76
  - .rspec
77
+ - ChangeLog
81
78
  - Gemfile
82
- - History.txt
83
79
  - LICENSE
84
80
  - Manifest.txt
85
81
  - README.rdoc
86
82
  - Rakefile
87
83
  - VERSION
88
84
  - bin/pidgin2adium
89
- - bin/pidgin2adium_profiler
90
85
  - config/website.yml
91
86
  - ext/balance_tags_c/balance_tags_c.c
92
87
  - ext/balance_tags_c/extconf.rb
93
88
  - lib/pidgin2adium.rb
94
89
  - lib/pidgin2adium/balance_tags.rb
90
+ - lib/pidgin2adium/basic_parser.rb
91
+ - lib/pidgin2adium/html_log_parser.rb
95
92
  - lib/pidgin2adium/log_converter.rb
96
93
  - lib/pidgin2adium/log_file.rb
97
94
  - lib/pidgin2adium/log_parser.rb
95
+ - lib/pidgin2adium/message.rb
96
+ - lib/pidgin2adium/text_log_parser.rb
98
97
  - pidgin2adium.gemspec
98
+ - spec/balance_tags_c_extn_spec.rb
99
+ - spec/basic_parser_spec.rb
100
+ - spec/html_log_parser_spec.rb
101
+ - spec/log_converter_spec.rb
102
+ - spec/log_file_spec.rb
103
+ - spec/logfiles/2006-12-21.223606.txt
104
+ - spec/logfiles/2008-01-15.071445-0500PST.htm
105
+ - spec/logfiles/2008-01-15.071445-0500PST.html
99
106
  - spec/pidgin2adium_spec.rb
100
107
  - spec/spec.opts
101
108
  - spec/spec_helper.rb
102
- - tasks/build_profiler.rake
109
+ - spec/test-output/README.md
110
+ - spec/test-output/html_log_output.xml
111
+ - spec/test-output/text_log_output.xml
112
+ - spec/text_log_parser_spec.rb
103
113
  - tasks/extconf.rake
104
114
  - tasks/extconf/balance_tags_c.rake
105
115
  has_rdoc: true
@@ -116,7 +126,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
116
126
  requirements:
117
127
  - - ">="
118
128
  - !ruby/object:Gem::Version
119
- hash: 3
120
129
  segments:
121
130
  - 0
122
131
  version: "0"
@@ -125,7 +134,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
134
  requirements:
126
135
  - - ">="
127
136
  - !ruby/object:Gem::Version
128
- hash: 3
129
137
  segments:
130
138
  - 0
131
139
  version: "0"
@@ -137,5 +145,11 @@ signing_key:
137
145
  specification_version: 3
138
146
  summary: Pidgin2Adium is a fast, easy way to convert Pidgin (formerly gaim) logs to the Adium format
139
147
  test_files:
148
+ - spec/balance_tags_c_extn_spec.rb
149
+ - spec/basic_parser_spec.rb
150
+ - spec/html_log_parser_spec.rb
151
+ - spec/log_converter_spec.rb
152
+ - spec/log_file_spec.rb
140
153
  - spec/pidgin2adium_spec.rb
141
154
  - spec/spec_helper.rb
155
+ - spec/text_log_parser_spec.rb
@@ -1 +0,0 @@
1
-
@@ -1,49 +0,0 @@
1
- desc "Build RubyProf version of pidgin2adium script"
2
- task :build_profiler do |t|
3
- # base = location of Rakefile, e.g. repo base
4
- base = Dir.pwd
5
- orig_lines = File.readlines("#{base}/bin/pidgin2adium")
6
- # remove "log_converter.start" line so we can surround it with RubyProf
7
- lastline = orig_lines.pop
8
- orig_text = orig_lines.join
9
-
10
- prof_file = File.new("#{base}/bin/pidgin2adium_profiler", 'w')
11
- new_text = <<EOF
12
- require 'ruby-prof'
13
- RubyProf.start
14
- log_converter.start
15
- result = RubyProf.stop
16
- printer = RubyProf::GraphHtmlPrinter.new(result)
17
- highest = Dir.glob('profiler_result*').sort.last
18
- if highest.nil?
19
- # This is the first profiler html created
20
- fname = "profiler_result.html"
21
- f = File.new(fname, 'w')
22
- else
23
- match = highest.match(/(\\d+)/)
24
- if match
25
- num = match.captures.last.to_i + 1
26
- fname = "profiler_result%02d.html" % num
27
- f = File.new(fname, 'w')
28
- else
29
- puts "!!! Oops, no match but there is definitely a profile file that exists. Unsure what happened. Outputting to stdout."
30
- f = STDOUT
31
- end
32
- end
33
- printer.print(f, {:filename => nil})
34
- EOF
35
- prof_file.write(orig_text)
36
- prof_file.write(new_text)
37
- prof_file.close
38
- end
39
-
40
- desc "Set profiler to blank file"
41
- task :clear_profiler do
42
- base = Dir.pwd
43
- x = File.new("#{base}/bin/pidgin2adium_profiler", 'w')
44
- x.puts
45
- x.close
46
- end
47
-
48
- desc "Install debug version of gem, with profiler. Clears profiler file after installing."
49
- task :install_debug => [:build_profiler, :install_gem, :clear_profiler]