hn2json 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -11,4 +11,7 @@ item.title
11
11
 
12
12
  item.votes
13
13
  # => 1
14
+
15
+ item...
16
+ # => Some other property
14
17
  ```
@@ -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 title.length < 1 || title[0].content == "More"
26
- if @doc.css('td').length > 7
27
- return :comment
28
- else
29
- return :error
30
- end
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
- td = @doc.css('td')[12]
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
@@ -1,4 +1,4 @@
1
1
  module HN2JSON
2
2
  # Public: String current version of HN2JSON
3
- VERSION = '0.0.5'
3
+ VERSION = '0.0.6'
4
4
  end
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.5
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-07 00:00:00.000000000 Z
12
+ date: 2012-10-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client