colloquy_log_to_text 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README ADDED
File without changes
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/env ruby
2
+ require 'nokogiri'
3
+ require 'date'
4
+
5
+ argc = ARGV.length
6
+ docs = Array.new
7
+ filenames = Array.new
8
+
9
+ if argc < 1
10
+ puts "Error: No Colloquy log files specified."
11
+ exit 1
12
+ end
13
+
14
+ if !ARGV[0].match(/\.colloquyTranscript$/)
15
+ puts "Error: File is not a Colloquy log."
16
+ exit 1
17
+ end
18
+
19
+ f = File.open(ARGV[0])
20
+ doc = Nokogiri::XML(f)
21
+ f.close
22
+ f = File.open(ARGV[0].gsub(".colloquyTranscript", ".txt"), "w")
23
+ envelopes = doc.css("envelope")
24
+ envelopes.each { |envelope|
25
+ messages = envelope.css("message")
26
+ messages.each { |message|
27
+ @printed_message = message.content
28
+ @timestamp_string = message.attr("received")
29
+ @timestamp = DateTime.strptime(@timestamp_string, "%F %H:%M:%S")
30
+ @is_action = message.attr("action")
31
+ }
32
+ senders = envelope.css("sender")
33
+ senders.each { |sender|
34
+ @nick = sender.content
35
+ case sender.attr("class")
36
+ when "voice"
37
+ @class = "+"
38
+ when "operator"
39
+ @class = "@"
40
+ when "founder"
41
+ @class = "~"
42
+ when "administrator"
43
+ @class = "&"
44
+ end
45
+ }
46
+ if @is_action == "yes"
47
+ f.puts "[#{@timestamp.day}-#{@timestamp.month}-#{@timestamp.year} #{@timestamp.hour}:#{@timestamp.minute}] * #{@nick} #{@printed_message}"
48
+ else
49
+ f.puts "[#{@timestamp.day}-#{@timestamp.month}-#{@timestamp.year} #{@timestamp.hour}:#{@timestamp.minute}] <#{@class}#{@nick}> #{@printed_message}"
50
+ end
51
+ }
@@ -0,0 +1,50 @@
1
+ require 'nokogiri'
2
+ require 'date'
3
+
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
+ if !ARGV[0].match(/\.colloquyTranscript$/)
14
+ puts "Error: File is not a Colloquy log."
15
+ exit 1
16
+ end
17
+
18
+ f = File.open(ARGV[0])
19
+ doc = Nokogiri::XML(f)
20
+ f.close
21
+ f = File.open(ARGV[0].gsub(".colloquyTranscript", ".txt"), "w")
22
+ envelopes = doc.css("envelope")
23
+ envelopes.each { |envelope|
24
+ messages = envelope.css("message")
25
+ messages.each { |message|
26
+ @printed_message = message.content
27
+ @timestamp_string = message.attr("received")
28
+ @timestamp = DateTime.strptime(@timestamp_string, "%F %H:%M:%S")
29
+ @is_action = message.attr("action")
30
+ }
31
+ senders = envelope.css("sender")
32
+ senders.each { |sender|
33
+ @nick = sender.content
34
+ case sender.attr("class")
35
+ when "voice"
36
+ @class = "+"
37
+ when "operator"
38
+ @class = "@"
39
+ when "founder"
40
+ @class = "~"
41
+ when "administrator"
42
+ @class = "&"
43
+ end
44
+ }
45
+ if @is_action == "yes"
46
+ f.puts "[#{@timestamp.day}-#{@timestamp.month}-#{@timestamp.year} #{@timestamp.hour}:#{@timestamp.minute}] * #{@nick} #{@printed_message}"
47
+ else
48
+ f.puts "[#{@timestamp.day}-#{@timestamp.month}-#{@timestamp.year} #{@timestamp.hour}:#{@timestamp.minute}] <#{@class}#{@nick}> #{@printed_message}"
49
+ end
50
+ }
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: colloquy_log_to_text
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 1.0.5
6
+ platform: ruby
7
+ authors:
8
+ - Mark Szymanski
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-03-12 00:00:00 -06:00
14
+ default_executable:
15
+ dependencies: []
16
+
17
+ description: A simple gem to convert Colloquy's awful XML logs into plain text.
18
+ email: mrman208@me.com
19
+ executables:
20
+ - colloquy_log_to_text
21
+ extensions: []
22
+
23
+ extra_rdoc_files: []
24
+
25
+ files:
26
+ - README
27
+ - lib/colloquy_log_to_text.rb
28
+ - bin/colloquy_log_to_text
29
+ has_rdoc: true
30
+ homepage: http://github.com/mrman208/colloquy_log_to_text
31
+ licenses: []
32
+
33
+ post_install_message:
34
+ rdoc_options: []
35
+
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ required_rubygems_version: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: "0"
50
+ requirements: []
51
+
52
+ rubyforge_project:
53
+ rubygems_version: 1.6.2
54
+ signing_key:
55
+ specification_version: 3
56
+ summary: A simple gem to convert Colloquy's awful XML logs into plain text.
57
+ test_files: []
58
+