colloquy_log_to_text 1.1.2 → 1.1.6
Sign up to get free protection for your applications and to get access to all the features.
data/README.md
CHANGED
data/bin/colloquy_log_to_text
CHANGED
@@ -1,65 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require 'nokogiri'
|
3
|
-
require 'date'
|
4
2
|
|
5
|
-
|
6
|
-
docs = Array.new
|
7
|
-
filenames = Array.new
|
3
|
+
$:.push File.expand_path("../lib/", __FILE__)
|
8
4
|
|
9
|
-
|
10
|
-
puts "Error: No Colloquy log files specified."
|
11
|
-
exit 1
|
12
|
-
end
|
5
|
+
require 'colloquy_log_to_text'
|
13
6
|
|
14
|
-
|
15
|
-
case arg
|
16
|
-
when "-h"
|
17
|
-
puts "Usage: colloquy_log_to_text [-h] <LOGFILE> [[LOGFILE2]...]"
|
18
|
-
puts "The log file specified (.colloquyTranscript) will then be converted into plain text."
|
19
|
-
puts "The -h option is used to display this help message."
|
20
|
-
exit 0
|
21
|
-
else
|
22
|
-
if !arg.match(/\.colloquyTranscript$/)
|
23
|
-
puts "Error: File is not a Colloquy log."
|
24
|
-
next
|
25
|
-
end
|
26
|
-
filenames.push arg
|
27
|
-
end
|
28
|
-
end
|
7
|
+
args = ARGV.dup
|
29
8
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
doc = Nokogiri::XML(f)
|
34
|
-
f.close
|
35
|
-
f = File.open(file.gsub(".colloquyTranscript", ".txt"), "w")
|
36
|
-
envelopes = doc.css("envelope")
|
37
|
-
envelopes.each { |envelope|
|
38
|
-
messages = envelope.css("message")
|
39
|
-
messages.each { |message|
|
40
|
-
@printed_message = message.content
|
41
|
-
@timestamp_string = message.attr("received")
|
42
|
-
@timestamp = DateTime.strptime(@timestamp_string, "%F %H:%M:%S")
|
43
|
-
@is_action = message.attr("action")
|
44
|
-
}
|
45
|
-
senders = envelope.css("sender")
|
46
|
-
senders.each { |sender|
|
47
|
-
@nick = sender.content
|
48
|
-
case sender.attr("class")
|
49
|
-
when "voice"
|
50
|
-
@class = "+"
|
51
|
-
when "operator"
|
52
|
-
@class = "@"
|
53
|
-
when "founder"
|
54
|
-
@class = "~"
|
55
|
-
when "administrator"
|
56
|
-
@class = "&"
|
57
|
-
end
|
58
|
-
}
|
59
|
-
if @is_action == "yes"
|
60
|
-
f.puts "[#{@timestamp.day}-#{@timestamp.month}-#{@timestamp.year} #{@timestamp.hour}:#{@timestamp.minute}] * #{@nick} #{@printed_message}"
|
61
|
-
else
|
62
|
-
f.puts "[#{@timestamp.day}-#{@timestamp.month}-#{@timestamp.year} #{@timestamp.hour}:#{@timestamp.minute}] <#{@class}#{@nick}> #{@printed_message}"
|
63
|
-
end
|
64
|
-
}
|
65
|
-
end
|
9
|
+
ColloquyLogToText.parse_args(args)
|
10
|
+
|
11
|
+
exit 0
|
@@ -0,0 +1,41 @@
|
|
1
|
+
class ColloquyLogToText
|
2
|
+
def self.convert(file)
|
3
|
+
if !file.match(/\.colloquyTranscript$/)
|
4
|
+
puts "Error: File is not a Colloquy log."
|
5
|
+
end
|
6
|
+
puts "Converting #{file}..."
|
7
|
+
f = File.open(file)
|
8
|
+
doc = Nokogiri::XML(f)
|
9
|
+
f.close
|
10
|
+
f = File.open(file.gsub(".colloquyTranscript", ".txt"), "w")
|
11
|
+
envelopes = doc.css("envelope")
|
12
|
+
envelopes.each { |envelope|
|
13
|
+
messages = envelope.css("message")
|
14
|
+
messages.each { |message|
|
15
|
+
@printed_message = message.content
|
16
|
+
@timestamp_string = message.attr("received")
|
17
|
+
@timestamp = DateTime.strptime(@timestamp_string, "%F %H:%M:%S")
|
18
|
+
@is_action = message.attr("action")
|
19
|
+
}
|
20
|
+
senders = envelope.css("sender")
|
21
|
+
senders.each { |sender|
|
22
|
+
@nick = sender.content
|
23
|
+
case sender.attr("class")
|
24
|
+
when "voice"
|
25
|
+
@class = "+"
|
26
|
+
when "operator"
|
27
|
+
@class = "@"
|
28
|
+
when "founder"
|
29
|
+
@class = "~"
|
30
|
+
when "administrator"
|
31
|
+
@class = "&"
|
32
|
+
end
|
33
|
+
}
|
34
|
+
if @is_action == "yes"
|
35
|
+
f.puts "[#{@timestamp.day}-#{@timestamp.month}-#{@timestamp.year} #{@timestamp.hour}:#{@timestamp.minute}] * #{@nick} #{@printed_message}"
|
36
|
+
else
|
37
|
+
f.puts "[#{@timestamp.day}-#{@timestamp.month}-#{@timestamp.year} #{@timestamp.hour}:#{@timestamp.minute}] <#{@class}#{@nick}> #{@printed_message}"
|
38
|
+
end
|
39
|
+
}
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'colloquy_log_to_text/version'
|
2
|
+
|
3
|
+
class ColloquyLogToText
|
4
|
+
def self.parse_args(args)
|
5
|
+
argc = args.count
|
6
|
+
if argc < 1
|
7
|
+
puts "Error: No Colloquy log files specified."
|
8
|
+
exit 1
|
9
|
+
end
|
10
|
+
|
11
|
+
for arg in args
|
12
|
+
case arg
|
13
|
+
when "-h"
|
14
|
+
puts "Usage: colloquy_log_to_text [-h] <LOGFILE> [[LOGFILE2]...]"
|
15
|
+
puts "The log file specified (.colloquyTranscript) will then be converted into plain text."
|
16
|
+
puts "The -h option is used to display this help message."
|
17
|
+
exit 0
|
18
|
+
when "-v"
|
19
|
+
puts ColloquyLogToText.version
|
20
|
+
else
|
21
|
+
ColloquyLogToText.convert(arg)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/colloquy_log_to_text.rb
CHANGED
@@ -1,64 +1,6 @@
|
|
1
|
+
require 'colloquy_log_to_text/colloquy_log_to_text'
|
2
|
+
require 'colloquy_log_to_text/parse_args'
|
3
|
+
require 'bundler/setup'
|
1
4
|
require 'nokogiri'
|
2
5
|
require 'date'
|
3
6
|
|
4
|
-
argc = ARGV.length
|
5
|
-
docs = Array.new
|
6
|
-
filenames = Array.new
|
7
|
-
|
8
|
-
if argc < 1
|
9
|
-
puts "Error: No Colloquy log files specified."
|
10
|
-
exit 1
|
11
|
-
end
|
12
|
-
|
13
|
-
for arg in ARGV
|
14
|
-
case arg
|
15
|
-
when "-h"
|
16
|
-
puts "Usage: colloquy_log_to_text [-h] <LOGFILE> [[LOGFILE2]...]"
|
17
|
-
puts "The log file specified (.colloquyTranscript) will then be converted into plain text."
|
18
|
-
puts "The -h option is used to display this help message."
|
19
|
-
exit 0
|
20
|
-
else
|
21
|
-
if !arg.match(/\.colloquyTranscript$/)
|
22
|
-
puts "Error: File is not a Colloquy log."
|
23
|
-
next
|
24
|
-
end
|
25
|
-
filenames.push arg
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
for file in filenames
|
30
|
-
puts "Converting #{file}..."
|
31
|
-
f = File.open(file)
|
32
|
-
doc = Nokogiri::XML(f)
|
33
|
-
f.close
|
34
|
-
f = File.open(file.gsub(".colloquyTranscript", ".txt"), "w")
|
35
|
-
envelopes = doc.css("envelope")
|
36
|
-
envelopes.each { |envelope|
|
37
|
-
messages = envelope.css("message")
|
38
|
-
messages.each { |message|
|
39
|
-
@printed_message = message.content
|
40
|
-
@timestamp_string = message.attr("received")
|
41
|
-
@timestamp = DateTime.strptime(@timestamp_string, "%F %H:%M:%S")
|
42
|
-
@is_action = message.attr("action")
|
43
|
-
}
|
44
|
-
senders = envelope.css("sender")
|
45
|
-
senders.each { |sender|
|
46
|
-
@nick = sender.content
|
47
|
-
case sender.attr("class")
|
48
|
-
when "voice"
|
49
|
-
@class = "+"
|
50
|
-
when "operator"
|
51
|
-
@class = "@"
|
52
|
-
when "founder"
|
53
|
-
@class = "~"
|
54
|
-
when "administrator"
|
55
|
-
@class = "&"
|
56
|
-
end
|
57
|
-
}
|
58
|
-
if @is_action == "yes"
|
59
|
-
f.puts "[#{@timestamp.day}-#{@timestamp.month}-#{@timestamp.year} #{@timestamp.hour}:#{@timestamp.minute}] * #{@nick} #{@printed_message}"
|
60
|
-
else
|
61
|
-
f.puts "[#{@timestamp.day}-#{@timestamp.month}-#{@timestamp.year} #{@timestamp.hour}:#{@timestamp.minute}] <#{@class}#{@nick}> #{@printed_message}"
|
62
|
-
end
|
63
|
-
}
|
64
|
-
end
|
metadata
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: colloquy_log_to_text
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 1
|
8
|
+
- 6
|
9
|
+
version: 1.1.6
|
6
10
|
platform: ruby
|
7
11
|
authors:
|
8
12
|
- Mark Szymanski
|
@@ -21,6 +25,8 @@ dependencies:
|
|
21
25
|
requirements:
|
22
26
|
- - ">="
|
23
27
|
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
24
30
|
version: "0"
|
25
31
|
type: :runtime
|
26
32
|
version_requirements: *id001
|
@@ -34,6 +40,9 @@ extra_rdoc_files: []
|
|
34
40
|
|
35
41
|
files:
|
36
42
|
- README.md
|
43
|
+
- lib/colloquy_log_to_text/colloquy_log_to_text.rb
|
44
|
+
- lib/colloquy_log_to_text/version.rb
|
45
|
+
- lib/colloquy_log_to_text/parse_args.rb
|
37
46
|
- lib/colloquy_log_to_text.rb
|
38
47
|
- bin/colloquy_log_to_text
|
39
48
|
has_rdoc: true
|
@@ -50,17 +59,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
50
59
|
requirements:
|
51
60
|
- - ">="
|
52
61
|
- !ruby/object:Gem::Version
|
62
|
+
segments:
|
63
|
+
- 0
|
53
64
|
version: "0"
|
54
65
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
66
|
none: false
|
56
67
|
requirements:
|
57
68
|
- - ">="
|
58
69
|
- !ruby/object:Gem::Version
|
70
|
+
segments:
|
71
|
+
- 0
|
59
72
|
version: "0"
|
60
73
|
requirements: []
|
61
74
|
|
62
75
|
rubyforge_project:
|
63
|
-
rubygems_version: 1.
|
76
|
+
rubygems_version: 1.3.7
|
64
77
|
signing_key:
|
65
78
|
specification_version: 3
|
66
79
|
summary: A simple gem to convert Colloquy's awful XML logs into plain text.
|