colloquy_log_to_text 1.1.6 → 1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,11 @@
1
1
  class ColloquyLogToText
2
2
  def self.convert(file)
3
- if !file.match(/\.colloquyTranscript$/)
3
+ if !File.exists?(file)
4
+ puts "Error: File does not exist."
5
+ exit 1
6
+ elsif !file.match(/(.+)\.colloquyTranscript$/)
4
7
  puts "Error: File is not a Colloquy log."
8
+ exit 1
5
9
  end
6
10
  puts "Converting #{file}..."
7
11
  f = File.open(file)
@@ -10,13 +14,6 @@ class ColloquyLogToText
10
14
  f = File.open(file.gsub(".colloquyTranscript", ".txt"), "w")
11
15
  envelopes = doc.css("envelope")
12
16
  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
17
  senders = envelope.css("sender")
21
18
  senders.each { |sender|
22
19
  @nick = sender.content
@@ -31,11 +28,18 @@ class ColloquyLogToText
31
28
  @class = "&"
32
29
  end
33
30
  }
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
31
+ messages = envelope.css("message")
32
+ messages.each { |message|
33
+ @printed_message = message.content
34
+ @timestamp_string = message.attr("received")
35
+ @timestamp = DateTime.strptime(@timestamp_string, "%F %H:%M:%S")
36
+ @is_action = message.attr("action")
37
+ if @is_action == "yes"
38
+ f.puts "[#{@timestamp.day}-#{@timestamp.month}-#{@timestamp.year} #{@timestamp.hour}:#{@timestamp.minute}] * #{@nick} #{@printed_message}"
39
+ else
40
+ f.puts "[#{@timestamp.day}-#{@timestamp.month}-#{@timestamp.year} #{@timestamp.hour}:#{@timestamp.minute}] <#{@class}#{@nick}> #{@printed_message}"
41
+ end
42
+ }
39
43
  }
40
44
  end
41
45
  end
@@ -1,5 +1,5 @@
1
1
  class ColloquyLogToText
2
2
  def self.version
3
- "1.1.6"
3
+ "1.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -4,9 +4,8 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 1
7
- - 1
8
- - 6
9
- version: 1.1.6
7
+ - 2
8
+ version: "1.2"
10
9
  platform: ruby
11
10
  authors:
12
11
  - Mark Szymanski