openlogcleaner 0.0.22 → 0.0.23
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/openlogcleaner/html_document.rb +36 -17
- data/openlogcleaner.gemspec +1 -1
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.23
|
@@ -22,28 +22,47 @@ module OpenLogCleaner
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def add_messages(doc)
|
25
|
-
doc.
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
25
|
+
if (dl = doc.at('dl'))
|
26
|
+
elements = dl.children.to_a
|
27
|
+
elements.delete_if { |elem| Nokogiri::XML::Text === elem }
|
28
|
+
until elements.empty?
|
29
|
+
dt, dd = elements.shift, elements.shift
|
30
|
+
add_list_entry(dt, dd)
|
31
|
+
end
|
32
|
+
else
|
33
|
+
doc.css('div').each do |msg|
|
34
|
+
begin
|
35
|
+
case msg['class']
|
36
|
+
when 'post'
|
37
|
+
add_post(msg)
|
38
|
+
when 'emote'
|
39
|
+
add_emote(msg)
|
40
|
+
when 'info', 'system'
|
41
|
+
next
|
42
|
+
else
|
43
|
+
# warn about an unknown div, unless it's the container div, which is
|
44
|
+
# element conversations get wrapped in by this code.
|
45
|
+
# This allows multiple passes, should this code be updated.
|
46
|
+
raise "Unknown div class '#{msg['class']}'" unless msg['id'] == 'container'
|
47
|
+
end
|
48
|
+
rescue Exception => e
|
49
|
+
warn msg.inspect
|
50
|
+
raise e
|
39
51
|
end
|
40
|
-
rescue Exception => e
|
41
|
-
warn msg.inspect
|
42
|
-
raise e
|
43
52
|
end
|
44
53
|
end
|
45
54
|
end
|
46
55
|
|
56
|
+
def add_list_entry(dt, dd)
|
57
|
+
name = dt.inner_text
|
58
|
+
if dt[:style] =~ /color: #([a-f0-9]{6});/i
|
59
|
+
color = $1
|
60
|
+
end
|
61
|
+
content = dd.inner_html
|
62
|
+
say = (dt[:class] && dt[:class] =~ /say/) ? true : false
|
63
|
+
add_message(say ? Say.new(name, content, color) : Emote.new(name, content, color))
|
64
|
+
end
|
65
|
+
|
47
66
|
def add_post(msg)
|
48
67
|
return if msg.children.first.name == 'font' # deal with system messages
|
49
68
|
return if msg.at('table') # deal with welcome messages
|
data/openlogcleaner.gemspec
CHANGED