hn2json 0.0.7 → 0.0.8

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.
@@ -78,7 +78,10 @@ module HN2JSON
78
78
  @parser.get_attrs_poll self
79
79
  when :discussion
80
80
  @parser.get_attrs_discussion self
81
+ when :job
82
+ @parser.get_attrs_job self
81
83
  when :error
84
+ raise ParseError, "Parser could not determine type on #{@id}"
82
85
  end
83
86
  end
84
87
 
@@ -34,7 +34,7 @@ module HN2JSON
34
34
 
35
35
  return :error unless subtext
36
36
 
37
- return :special if subtext.content.split.length <= 3
37
+ return :job if subtext.content.split.length <= 3
38
38
 
39
39
  tr = subtext.xpath('..').xpath('..').css('tr')
40
40
 
@@ -46,6 +46,25 @@ module HN2JSON
46
46
 
47
47
  end
48
48
 
49
+ def get_attrs_job entity
50
+
51
+ title = @doc.css('.title a')[0].content
52
+
53
+ subtext = @doc.css('.subtext')[0]
54
+
55
+ date_regex = /(.*\s.*\sago)/
56
+ ago = date_regex.match(subtext.content)[1]
57
+ date_posted = Chronic.parse(ago).to_s
58
+
59
+ fulltext = @doc.css('td')[10].content
60
+
61
+ entity.add_attrs do |e|
62
+ e.title = title
63
+ e.date_posted = date_posted
64
+ e.fulltext = fulltext
65
+ end
66
+ end
67
+
49
68
  def get_attrs_comment entity
50
69
 
51
70
  parent_url = @doc.css('.comhead a')[2]['href']
@@ -1,4 +1,4 @@
1
1
  module HN2JSON
2
2
  # Public: String current version of HN2JSON
3
- VERSION = '0.0.7'
3
+ VERSION = '0.0.8'
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.7
4
+ version: 0.0.8
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-09 00:00:00.000000000 Z
12
+ date: 2012-10-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client