hn2json 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -0
- data/lib/hn2json/parser.rb +20 -16
- data/lib/hn2json/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
data/lib/hn2json/parser.rb
CHANGED
@@ -19,25 +19,29 @@ module HN2JSON
|
|
19
19
|
|
20
20
|
|
21
21
|
def determine_type
|
22
|
-
title = @doc.css('.title a')
|
23
22
|
|
23
|
+
comhead = @doc.css('.comhead')[0]
|
24
24
|
|
25
|
-
if
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
25
|
+
if !!comhead
|
26
|
+
|
27
|
+
return :post if comhead.content.gsub(/\s\(.*\)\s/, '').length == 0
|
28
|
+
|
29
|
+
return :comment if comhead.content.count('|') >= 2
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
subtext = @doc.css('.subtext')[0]
|
34
|
+
|
35
|
+
return :error unless subtext
|
36
|
+
|
37
|
+
return :special if subtext.content.split.length <= 3
|
38
|
+
|
39
|
+
tr = subtext.xpath('..').xpath('..').css('tr')
|
40
|
+
|
41
|
+
if tr.length == 4 || tr.last.css('form').length == 1
|
42
|
+
return :discussion
|
31
43
|
else
|
32
|
-
|
33
|
-
|
34
|
-
if td.css('table').length > 0
|
35
|
-
return :poll
|
36
|
-
elsif td.css('form').length == 1
|
37
|
-
return :discussion
|
38
|
-
else
|
39
|
-
return :post
|
40
|
-
end
|
44
|
+
return :poll
|
41
45
|
end
|
42
46
|
|
43
47
|
end
|
data/lib/hn2json/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hn2json
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|