Skip to content
Browse files

Added data extraction to the [get_attrs_job] method. Changed type_tes…

…t to comply with changes.
  • Loading branch information...
1 parent 225ff0e commit a6de01340ef3d9d1c7b7f9cff8d5b58a49ebd554 @jcla1 committed Oct 12, 2012
Showing with 18 additions and 2 deletions.
  1. +16 −0 lib/hn2json/parser.rb
  2. +2 −2 type_test.rb
View
16 lib/hn2json/parser.rb
@@ -47,6 +47,22 @@ def determine_type
end
def get_attrs_job entity
+
+ title = @doc.css('.title a')[0].content
+
+ subtext = @doc.css('.subtext')[0]
+
+ date_regex = /(.*\s.*\sago)/
+ ago = date_regex.match(subtext.content)[1]
+ date_posted = Chronic.parse(ago).to_s
+
+ fulltext = @doc.css('td')[10].content
+
+ entity.add_attrs do |e|
+ e.title = title
+ e.date_posted = date_posted
+ e.fulltext = fulltext
+ end
end
def get_attrs_comment entity
View
4 type_test.rb
@@ -65,8 +65,8 @@
sleep(20)
-special = HN2JSON.find 4626238 # new, special
-raise RuntimeError, "Something wrong with the special" unless special.type == :special
+job = HN2JSON.find 4626238 # new, job
+raise RuntimeError, "Something wrong with the job" unless job.type == :job
puts "All test passed!"

0 comments on commit a6de013

Please sign in to comment.
Something went wrong with that request. Please try again.