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.
- checksums.yaml +7 -0
- data/.gitignore +2 -3
- data/.rspec +1 -0
- data/.simplecov +5 -0
- data/.travis.yml +12 -0
- data/Gemfile +6 -1
- data/LICENSE +17 -17
- data/NEWS.md +89 -0
- data/README.md +60 -0
- data/Rakefile +5 -23
- data/bin/pidgin2adium +19 -90
- data/lib/pidgin2adium.rb +4 -136
- data/lib/pidgin2adium/adium_chat_file_creator.rb +64 -0
- data/lib/pidgin2adium/file_finder.rb +23 -0
- data/lib/pidgin2adium/runner.rb +23 -0
- data/lib/pidgin2adium/version.rb +1 -1
- data/pidgin2adium.gemspec +25 -21
- data/spec/features/parse_pidgin_log_file_spec.rb +50 -0
- data/spec/fixtures/input/input.html +3 -0
- data/spec/fixtures/output.xml +5 -0
- data/spec/pidgin2adium/adium_chat_file_creator_spec.rb +89 -0
- data/spec/pidgin2adium/file_finder_spec.rb +63 -0
- data/spec/spec_helper.rb +17 -59
- metadata +96 -89
- data/.autotest +0 -28
- data/ChangeLog +0 -79
- data/Manifest.txt +0 -18
- data/README.rdoc +0 -122
- data/config/website.yml +0 -2
- data/ext/balance_tags_c/balance_tags_c.c +0 -198
- data/ext/balance_tags_c/extconf.rb +0 -4
- data/lib/pidgin2adium/log_converter.rb +0 -71
- data/lib/pidgin2adium/log_file.rb +0 -100
- data/lib/pidgin2adium/log_parser.rb +0 -2
- data/lib/pidgin2adium/message.rb +0 -2
- data/lib/pidgin2adium/messages/all.rb +0 -5
- data/lib/pidgin2adium/messages/auto_reply_message.rb +0 -11
- data/lib/pidgin2adium/messages/event.rb +0 -17
- data/lib/pidgin2adium/messages/message.rb +0 -39
- data/lib/pidgin2adium/messages/status_message.rb +0 -17
- data/lib/pidgin2adium/messages/xml_message.rb +0 -40
- data/lib/pidgin2adium/parsers/all.rb +0 -3
- data/lib/pidgin2adium/parsers/basic_parser.rb +0 -456
- data/lib/pidgin2adium/parsers/html_log_parser.rb +0 -125
- data/lib/pidgin2adium/parsers/text_log_parser.rb +0 -39
- data/spec/balance_tags_c_extn_spec.rb +0 -47
- data/spec/basic_parser_spec.rb +0 -219
- data/spec/html_log_parser_spec.rb +0 -150
- data/spec/log_converter_spec.rb +0 -48
- data/spec/log_file_spec.rb +0 -176
- data/spec/logfiles/2006-12-21.223606.txt +0 -3
- data/spec/logfiles/2008-01-15.071445-0500PST.htm +0 -5
- data/spec/logfiles/2008-01-15.071445-0500PST.html +0 -5
- data/spec/pidgin2adium_spec.rb +0 -252
- data/spec/spec.opts +0 -1
- data/spec/test-output/README.md +0 -1
- data/spec/test-output/html_log_output.xml +0 -6
- data/spec/test-output/text_log_output.xml +0 -4
- data/spec/text_log_parser_spec.rb +0 -42
- data/tasks/extconf.rake +0 -8
- data/tasks/extconf/balance_tags_c.rake +0 -47
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1a19269fc564ee7b96212824080a049dcc6fe3b8
|
4
|
+
data.tar.gz: 5314c9de5efe136193a156a71cd09ce65cccd72b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 60269903641f9776950be83fa2fa99a0cf72c09d5826f30eaf0bc5c94e79678d5e8485d1a1bb450b53e93a1c18d8ff014be0e2863c164b2183f1a96e0f5d6cdd
|
7
|
+
data.tar.gz: 3c52742c8416ca06cc4d2695c0e78b3c648e0bc43441bebe82b072e91dfb304e7c520d5fe5cce37c2821ba5bbc99da1300c83c4a4636810a18bc9da6b55437dd
|
data/.gitignore
CHANGED
@@ -17,13 +17,12 @@ tmtags
|
|
17
17
|
coverage
|
18
18
|
rdoc
|
19
19
|
pkg
|
20
|
+
tags
|
20
21
|
|
21
22
|
## PROJECT::SPECIFIC
|
22
23
|
.bundle
|
23
|
-
ext/balance_tags_c/Makefile
|
24
|
-
ext/balance_tags_c/balance_tags_c.bundle
|
25
|
-
ext/balance_tags_c/balance_tags_c.o
|
26
24
|
.rvmrc
|
27
25
|
spec/output-dir
|
28
26
|
spec/nonexistent_output_dir
|
29
27
|
Gemfile.lock
|
28
|
+
tmp
|
data/.rspec
CHANGED
data/.simplecov
ADDED
data/.travis.yml
ADDED
data/Gemfile
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
-
source
|
1
|
+
source "https://rubygems.org"
|
2
2
|
|
3
3
|
gemspec
|
4
|
+
|
5
|
+
gem "pipio", github: "gabebw/pipio"
|
6
|
+
# Use FakeFS from GitHub so that this commit is available:
|
7
|
+
# https://github.com/defunkt/fakefs/commit/41e2e46446dfacb07135a82e24858b5e06220ec9
|
8
|
+
gem "fakefs", github: "defunkt/fakefs", require: false
|
data/LICENSE
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
|
1
|
+
The MIT License (MIT)
|
2
2
|
|
3
|
-
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
3
|
+
Copyright (c) 2013 Gabriel Berke-Williams
|
10
4
|
|
11
|
-
|
12
|
-
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
13
11
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/NEWS.md
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
### HEAD (unreleased)
|
2
|
+
|
3
|
+
* Massive refactoring
|
4
|
+
* Chat times respect time zones instead of assuming inputs are UTC
|
5
|
+
* Remove C extension
|
6
|
+
* Test against Travis
|
7
|
+
|
8
|
+
### 3.3.0 / 2011-10-16
|
9
|
+
* Pidgin2Adium depended on itself for some reason. Now it doesn't.
|
10
|
+
|
11
|
+
### 3.2.3 / 2010-11-08
|
12
|
+
* Be more liberal in what Pidgin2Adium accepts when parsing the date and
|
13
|
+
getting basic time info for the first line. Thanks to Matthew Jakubowski for
|
14
|
+
helping me fix this bug.
|
15
|
+
|
16
|
+
### 3.2.2 / 2010-11-08
|
17
|
+
* Use DateTime#strftime to get dates in xmlschema format. DateTime#xmlschema
|
18
|
+
doesn't exist in Ruby 1.8, and Ruby 1.9 has DateTime#iso8601, not
|
19
|
+
DateTime#xmlschema. Just use strftime. Thanks to Matthew Jakubowski for
|
20
|
+
pointing this bug out.
|
21
|
+
|
22
|
+
### 3.2.1 / 2010-11-08
|
23
|
+
* Use straight `DateTime.parse` when possible, and only fall back on hacky
|
24
|
+
`Date._strptime` when we have to.
|
25
|
+
|
26
|
+
### 3.2.0 / 2010-10-12
|
27
|
+
* Last release broke 1.8 compatibility due to use of strptime. 1.8 and 1.9
|
28
|
+
both work in 3.2.0.
|
29
|
+
* Moved Pidgin2Adium::VERSION to its own file
|
30
|
+
|
31
|
+
### 3.1.1 / 2010-08-13
|
32
|
+
* Moved BasicParser and its subclasses into parsers/ subdir.
|
33
|
+
- You can now do `require 'pidgin2adium/parsers/all'`,
|
34
|
+
though the old `require 'pidgin2adium/log_parser'` will still work
|
35
|
+
* Moved Message and its subclasses into messages/ subdir
|
36
|
+
- You can now do `require 'pidgin2adium/messages/all'`,
|
37
|
+
though the old `require 'pidgin2adium/message'` will still work
|
38
|
+
|
39
|
+
### 3.1.0 / 2010-08-13
|
40
|
+
* Compatible with Ruby 1.9!
|
41
|
+
- removed dependency on `parsedate` library, which 1.9 doesn't have
|
42
|
+
* `log_parser.rb` has been split into separate files (1 per class, more or less)
|
43
|
+
- `require pidgin2adium/log_parser` will still pull in all of the split-up
|
44
|
+
classes
|
45
|
+
* `balance_tags_c` extension really does work now
|
46
|
+
* Cleans up more junk from Pidgin logfiles when parsing
|
47
|
+
* Bugfixes and more graceful handling of error states
|
48
|
+
* Fully tested (except bin/pidgin2adium, which remains tricky)
|
49
|
+
|
50
|
+
### 3.0.1 / 2010-08-07
|
51
|
+
Bugfix release.
|
52
|
+
|
53
|
+
* `balance_tags_c.c`: Use `rb_eval_string` instead of `rb_reg_regcomp` to avoid
|
54
|
+
segfaults (commit #733ce88b0836256e14f0, fixes #27811)
|
55
|
+
|
56
|
+
Non-user-facing stuff:
|
57
|
+
|
58
|
+
* Switched to Jeweler, RSpec, and Bundler
|
59
|
+
* Rakefile now doesn't choke if Hanna gem isn't installed
|
60
|
+
|
61
|
+
### 3.0.0 / 2010-01-31
|
62
|
+
* `lbalance_tags.rb` is now a C extension (`Pidgin2Adium.balance_tags_c`)
|
63
|
+
- the pure-ruby mixin `balance_tags` (without the trailing `_c`) is gone
|
64
|
+
* Better handling of command-line arguments
|
65
|
+
* Format time zones offsets correctly (e.g. "+0500", not "+-0500")
|
66
|
+
* Write Yahoo! and Jabber logs to correct directories (#27710)
|
67
|
+
* Better matching of regexes against time strings
|
68
|
+
* Better documentation
|
69
|
+
|
70
|
+
### 2.0.2 / 2009-12-18
|
71
|
+
* Much better documentation (more of it, and higher quality too!)
|
72
|
+
* Allow user-provided output dir at commandline
|
73
|
+
* Cleaner error messages
|
74
|
+
* require 'time' for `Time.zone_offset` (fixes bug)
|
75
|
+
* Gracefully handle lack of timezone info
|
76
|
+
* Gracefully handle nonexistent output dir
|
77
|
+
* Gracefully handle parsing errors
|
78
|
+
* Print error messages during *and* after batch converting so they're actually seen
|
79
|
+
|
80
|
+
### 2.0.1 / 2009-12-06
|
81
|
+
* Fix timestamps so they show up in Adium chat log viewer
|
82
|
+
|
83
|
+
### 2.0.0 / 2009-11-24
|
84
|
+
* Added documentation, available at http://pidgin2adium.rubyforge.org/rdoc/
|
85
|
+
* Added public interface for scripting purposes
|
86
|
+
* Removed -o and -l options. Now gem automatically outputs to Adium log dir with no intermediate folder.
|
87
|
+
|
88
|
+
### 1.0.0 / 2009-09-27
|
89
|
+
* Birthday!
|
data/README.md
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# pidgin2adium [](http://travis-ci.org/gabebw/pidgin2adium) [](https://codeclimate.com/github/gabebw/pidgin2adium)
|
2
|
+
|
3
|
+
Convert [Pidgin](http://pidgin.im/) (formerly gaim) logs to the
|
4
|
+
[Adium](http://adium.im/) format. This is a command-line wrapper around the
|
5
|
+
[Pipio] log-parsing library.
|
6
|
+
|
7
|
+
[Pipio]: https://github.com/gabebw/pipio
|
8
|
+
|
9
|
+
## Install
|
10
|
+
|
11
|
+
gem install pidgin2adium
|
12
|
+
|
13
|
+
## Quick Start
|
14
|
+
|
15
|
+
Let's say you have some logs in `~/pidgin-logs`, and your aliases are "Gabe
|
16
|
+
B-W", "Gabe", and "Gabe Berke-Williams". Then you should run this:
|
17
|
+
|
18
|
+
pidgin2adium --in ~/pidgin-logs --aliases "Gabe B-W,Gabe,Gabe Berke-Williams"
|
19
|
+
|
20
|
+
## OK, what's with the aliases?
|
21
|
+
|
22
|
+
Pidgin2adium needs a comma-separated list of your aliases to work. Aliases make
|
23
|
+
it so that you show up in chats as (for example) `Me` instead of as
|
24
|
+
`best_screen_name_ever_018845`.
|
25
|
+
|
26
|
+
Pidgin then uses aliases in the log file instead of the actual screen name,
|
27
|
+
which makes it impossible to match "Me" to your actual screen name. Therefore
|
28
|
+
Pidgin2adium needs to know which aliases belong to you so it can map them to the
|
29
|
+
correct screen name.
|
30
|
+
|
31
|
+
If Pidgin2adium encounters an alias that you did not list, it assumes that it
|
32
|
+
belongs to the person to whom you are chatting.
|
33
|
+
|
34
|
+
You do not need to provide your screenname in the alias list.
|
35
|
+
|
36
|
+
## Testing
|
37
|
+
|
38
|
+
To get a coverage report, run `rake` with the `COVERAGE` environment variable
|
39
|
+
set:
|
40
|
+
|
41
|
+
COVERAGE=1 rake
|
42
|
+
|
43
|
+
## THANKS
|
44
|
+
|
45
|
+
With thanks to Li Ma, whose [blog post](http://li-ma.blogspot.com/2008/10/pidgin-log-file-to-adium-log-converter.html)
|
46
|
+
helped tremendously.
|
47
|
+
|
48
|
+
## Note on Patches/Pull Requests
|
49
|
+
|
50
|
+
* Fork the project.
|
51
|
+
* Make your feature addition or bug fix.
|
52
|
+
* Add tests for it. This is important so I don't break it in a
|
53
|
+
future version unintentionally.
|
54
|
+
* Commit, do not mess with rakefile, version, or history.
|
55
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
56
|
+
* Send me a pull request. Bonus points for topic branches.
|
57
|
+
|
58
|
+
## Copyright
|
59
|
+
|
60
|
+
Copyright (c) 2009-2014 Gabe Berke-Williams. See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -1,31 +1,13 @@
|
|
1
1
|
require 'bundler'
|
2
|
+
require 'bundler/setup'
|
2
3
|
Bundler::GemHelper.install_tasks
|
3
4
|
|
4
5
|
require 'rspec/core/rake_task'
|
5
6
|
|
6
|
-
RSpec::Core::RakeTask.new(:spec)
|
7
|
-
spec.rspec_opts = %w{-Ilib -Ispec}
|
8
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
9
|
-
end
|
10
|
-
|
11
|
-
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
12
|
-
spec.rspec_opts = %w{-Ilib -Ispec}
|
13
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
14
|
-
spec.rcov = true
|
15
|
-
end
|
16
|
-
|
17
|
-
task :spec => "extconf:compile"
|
18
|
-
|
19
|
-
task :default => :spec
|
20
|
-
|
21
|
-
require 'rake/rdoctask'
|
22
|
-
Rake::RDocTask.new do |rdoc|
|
23
|
-
version = Pidgin2Adium::VERSION
|
7
|
+
RSpec::Core::RakeTask.new(:spec)
|
24
8
|
|
25
|
-
|
26
|
-
|
27
|
-
rdoc.rdoc_files.include('README*')
|
28
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
9
|
+
task :coverage do
|
10
|
+
system "COVERAGE=1 rake ; open coverage/index.html"
|
29
11
|
end
|
30
12
|
|
31
|
-
|
13
|
+
task default: :spec
|
data/bin/pidgin2adium
CHANGED
@@ -1,109 +1,38 @@
|
|
1
|
-
#!/usr/bin/ruby
|
1
|
+
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
Usage:
|
6
|
-
This is the shell script, which is a wrapper around Pidgin2Adium::LogConverter.
|
7
|
-
Call it like so:
|
8
|
-
<tt>pidgin2adium -i ~/in_logs/ -a "me,my_pidgin_alias,other_pidgin_alias"</tt>
|
9
|
-
For <tt>-a/--aliases</tt>, there is no need to use spaces or capitalization,
|
10
|
-
since spaces will be stripped out and the aliases will be lowercased anyway.
|
11
|
-
Aliases doesn't have to include screennames, either, since these are
|
12
|
-
automatically recognized.
|
13
|
-
=end
|
14
|
-
|
15
|
-
require 'pidgin2adium/log_converter'
|
16
|
-
require 'optparse'
|
17
|
-
|
18
|
-
version = <<EOL
|
19
|
-
Pidgin2Adium, version #{Pidgin2Adium::VERSION}
|
20
|
-
Written by Gabe Berke-Williams (gbw@rubyforge.org)
|
21
|
-
EOL
|
3
|
+
require "pidgin2adium"
|
4
|
+
require "optparse"
|
22
5
|
|
23
6
|
options = {}
|
24
7
|
|
25
|
-
|
26
|
-
|
27
|
-
opts.on('-i', '--in=IN_DIR', String, 'Directory where pidgin logs are stored') do |i|
|
28
|
-
options[:in] = i
|
29
|
-
end
|
30
|
-
|
31
|
-
opts.on('-a alias1,alias2', "--aliases alias1,alias2",
|
32
|
-
"A comma-separated list of your alias(es)",
|
33
|
-
"so this script knows which person in a chat",
|
34
|
-
"is you. Whitespace and case do not matter.") do |aliases|
|
35
|
-
options[:aliases] = aliases
|
36
|
-
end
|
37
|
-
|
38
|
-
opts.on('-o', '--out OUT_DIR',
|
39
|
-
'The top-level directory under which to',
|
40
|
-
'store the logs (each in its own folder',
|
41
|
-
'by screen name).',
|
42
|
-
"Defaults to: #{Pidgin2Adium::ADIUM_LOG_DIR}") do |out|
|
43
|
-
options[:output_dir] = out
|
44
|
-
end
|
8
|
+
parser = OptionParser.new do |parser|
|
9
|
+
parser.banner = "Usage: #{File.basename($0)} -i PIDGIN_LOG_DIR"
|
45
10
|
|
46
|
-
|
47
|
-
|
48
|
-
'logs will be overwritten.') do |f|
|
49
|
-
options[:force] = f
|
11
|
+
parser.on('-i', '--in IN_DIR', 'Directory where pidgin logs are stored') do |in_directory|
|
12
|
+
options[:in_directory] = in_directory
|
50
13
|
end
|
51
14
|
|
52
|
-
|
53
|
-
options[:
|
15
|
+
parser.on('-a', '--aliases "gabebw,Gabe B-W"', "Your aliases from Pidgin") do |aliases|
|
16
|
+
options[:aliases] = aliases.split(",")
|
54
17
|
end
|
55
18
|
|
56
|
-
|
57
|
-
puts version
|
19
|
+
parser.on("-v", "--version", "Show version information") do
|
20
|
+
puts "Pidgin2Adium, version #{Pidgin2Adium::VERSION}"
|
58
21
|
exit
|
59
22
|
end
|
60
23
|
|
61
|
-
|
62
|
-
puts
|
63
|
-
puts opts
|
24
|
+
parser.on_tail("-h", "--help", "Show this message") do
|
25
|
+
puts parser
|
64
26
|
exit
|
65
27
|
end
|
66
28
|
end
|
67
29
|
|
68
|
-
|
69
|
-
oparser.parse!
|
70
|
-
rescue => bang
|
71
|
-
if bang.class == OptionParser::MissingArgument
|
72
|
-
# No argument provided for a switch that requires an argument.
|
73
|
-
puts '"%s" requires an argument.' % bang.args[0]
|
74
|
-
exit 1
|
75
|
-
elsif bang.class == OptionParser::InvalidOption
|
76
|
-
# Provided a switch that we don't handle.
|
77
|
-
puts '"%s" is not a valid switch.' % bang.args[0]
|
78
|
-
elsif bang.class == OptionParser::NeedlessArgument
|
79
|
-
# Raised when argument provided for a switch that doesn't take an argument.
|
80
|
-
puts bang.message
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
need_opts = false
|
85
|
-
required_opts = [[:i, :in], [:a, :aliases]]
|
86
|
-
|
87
|
-
required_opts.each do |short, long|
|
88
|
-
if options.has_key?(long)
|
89
|
-
next
|
90
|
-
else
|
91
|
-
need_opts = true
|
92
|
-
puts "Required option -#{short}/--#{long} missing."
|
93
|
-
end
|
94
|
-
end
|
30
|
+
parser.parse!
|
95
31
|
|
96
|
-
if
|
97
|
-
|
32
|
+
if options[:in_directory] && options[:aliases]
|
33
|
+
runner = Pidgin2Adium::Runner.new(options[:in_directory], option[:aliases])
|
34
|
+
runner.run
|
35
|
+
else
|
36
|
+
STDERR.puts "Please provide -i/--in argument and -a/--aliases. Run with --help for more information"
|
98
37
|
exit 1
|
99
38
|
end
|
100
|
-
|
101
|
-
extra_opts = {:overwrite => options[:force]}
|
102
|
-
|
103
|
-
extra_opts[:output_dir] = options[:output_dir]
|
104
|
-
extra_opts[:force_conversion] = options[:force_conversion]
|
105
|
-
|
106
|
-
log_converter = Pidgin2Adium::LogConverter.new(options[:in],
|
107
|
-
options[:aliases],
|
108
|
-
extra_opts)
|
109
|
-
log_converter.start
|
data/lib/pidgin2adium.rb
CHANGED
@@ -1,137 +1,5 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
# A ruby program to convert Pidgin log files to Adium log files, then place
|
4
|
-
# them in the Adium log directory.
|
5
|
-
|
6
|
-
require 'fileutils'
|
7
|
-
require 'time'
|
1
|
+
require 'pipio'
|
8
2
|
require 'pidgin2adium/version'
|
9
|
-
require 'pidgin2adium/
|
10
|
-
|
11
|
-
|
12
|
-
# Returned by LogFile.write_out if the output logfile already exists.
|
13
|
-
FILE_EXISTS = 42
|
14
|
-
ADIUM_LOG_DIR = File.expand_path('~/Library/Application Support/Adium 2.0/Users/Default/Logs/') << '/'
|
15
|
-
# These files/directories show up in Dir.entries()
|
16
|
-
BAD_DIRS = %w{. .. .DS_Store Thumbs.db .system}
|
17
|
-
# For displaying after we finish converting
|
18
|
-
@@oops_messages = []
|
19
|
-
@@error_messages = []
|
20
|
-
|
21
|
-
def log_msg(str) #:nodoc:
|
22
|
-
puts str.to_s
|
23
|
-
end
|
24
|
-
|
25
|
-
def oops(str) #:nodoc:
|
26
|
-
@@oops_messages << str
|
27
|
-
warn("Oops: #{str}")
|
28
|
-
end
|
29
|
-
|
30
|
-
def error(str) #:nodoc:
|
31
|
-
@@error_messages << str
|
32
|
-
warn("Error: #{str}")
|
33
|
-
end
|
34
|
-
|
35
|
-
#######################
|
36
|
-
#So that we can use log_msg when calling delete_search_indexes() by itself
|
37
|
-
module_function :log_msg, :oops, :error
|
38
|
-
#######################
|
39
|
-
|
40
|
-
# Parses the provided log.
|
41
|
-
# Returns a LogFile instance or false if an error occurred.
|
42
|
-
def parse(logfile_path, my_aliases, force_conversion)
|
43
|
-
logfile_path = File.expand_path(logfile_path)
|
44
|
-
ext = File.extname(logfile_path).sub('.', '').downcase
|
45
|
-
|
46
|
-
if(ext == "html" || ext == "htm")
|
47
|
-
parser_class = HtmlLogParser
|
48
|
-
elsif(ext == "txt")
|
49
|
-
parser_class = TextLogParser
|
50
|
-
else
|
51
|
-
error("Doing nothing, logfile is not a text or html file. Path: #{logfile_path}.")
|
52
|
-
return false
|
53
|
-
end
|
54
|
-
|
55
|
-
parser = parser_class.new(logfile_path, my_aliases, force_conversion)
|
56
|
-
return parser.parse()
|
57
|
-
end
|
58
|
-
|
59
|
-
# Parses the provided log and writes out the log in Adium format.
|
60
|
-
# Returns:
|
61
|
-
# * true if it successfully converted and wrote out the log,
|
62
|
-
# * false if an error occurred, or
|
63
|
-
# * Pidgin2Adium::FILE_EXISTS if file already exists AND
|
64
|
-
# opts[:overwrite] = false.
|
65
|
-
#
|
66
|
-
# You can add options using the _opts_ hash, which can have the following
|
67
|
-
# keys, all of which are optional:
|
68
|
-
# * *overwrite*: If true, then overwrite even if log is found.
|
69
|
-
# Defaults to false.
|
70
|
-
# * *output_dir*: The top-level dir to put the logs in.
|
71
|
-
# Logs under output_dir are still each in their own folders, etc.
|
72
|
-
# Defaults to Pidgin2Adium::ADIUM_LOG_DIR
|
73
|
-
def parse_and_generate(logfile_path, my_aliases, opts = {})
|
74
|
-
opts = {} unless opts.is_a?(Hash)
|
75
|
-
overwrite = !!opts[:overwrite]
|
76
|
-
force_conversion = opts[:force_conversion]
|
77
|
-
|
78
|
-
if opts.key?(:output_dir)
|
79
|
-
output_dir = opts[:output_dir]
|
80
|
-
else
|
81
|
-
output_dir = ADIUM_LOG_DIR
|
82
|
-
end
|
83
|
-
|
84
|
-
unless File.directory?(output_dir)
|
85
|
-
puts "Output log directory (#{output_dir}) does not exist or is not a directory."
|
86
|
-
begin
|
87
|
-
FileUtils.mkdir_p(output_dir)
|
88
|
-
rescue Errno::EACCES
|
89
|
-
puts "Permission denied, could not create output directory (#{output_dir})"
|
90
|
-
return false
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
logfile_obj = parse(logfile_path, my_aliases, force_conversion)
|
95
|
-
return false if logfile_obj == false
|
96
|
-
dest_file_path = logfile_obj.write_out(overwrite, output_dir)
|
97
|
-
if dest_file_path == false
|
98
|
-
error("Successfully parsed file, but failed to write it out. Path: #{logfile_path}.")
|
99
|
-
return false
|
100
|
-
elsif dest_file_path == FILE_EXISTS
|
101
|
-
log_msg("File already exists.")
|
102
|
-
return FILE_EXISTS
|
103
|
-
else
|
104
|
-
log_msg("Output to: #{dest_file_path}")
|
105
|
-
return true
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
# Newly-converted logs are viewable in the Adium Chat Transcript
|
110
|
-
# Viewer, but are not indexed, so a search of the logs doesn't give
|
111
|
-
# results from the converted logs. To fix this, we delete the cached log
|
112
|
-
# indexes, which forces Adium to re-index.
|
113
|
-
#
|
114
|
-
# Note: This function is run by LogConverter after converting all of its
|
115
|
-
# files. LogFile.write_out intentionally does _not_ run it in order to
|
116
|
-
# allow for batch-processing of files. Thus, you will probably want to run
|
117
|
-
# Pidgin2Adium.delete_search_indexes after running LogFile.write_out in
|
118
|
-
# your own scripts.
|
119
|
-
def delete_search_indexes()
|
120
|
-
log_msg "Deleting log search indexes in order to force re-indexing of imported logs..."
|
121
|
-
dirty_file = File.expand_path("~/Library/Caches/Adium/Default/DirtyLogs.plist")
|
122
|
-
log_index_file = File.expand_path("~/Library/Caches/Adium/Default/Logs.index")
|
123
|
-
[dirty_file, log_index_file].each do |f|
|
124
|
-
if File.exist?(f)
|
125
|
-
if File.writable?(f)
|
126
|
-
File.delete(f)
|
127
|
-
else
|
128
|
-
error("File exists but is not writable. Please delete it yourself: #{f}")
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
132
|
-
log_msg "...done."
|
133
|
-
log_msg "When you next start the Adium Chat Transcript Viewer, it will re-index the logs, which may take a while."
|
134
|
-
end
|
135
|
-
|
136
|
-
module_function :parse, :parse_and_generate, :delete_search_indexes
|
137
|
-
end
|
3
|
+
require 'pidgin2adium/file_finder'
|
4
|
+
require 'pidgin2adium/runner'
|
5
|
+
require 'pidgin2adium/adium_chat_file_creator'
|