lib/onebox/engine/pubmed_onebox.rb in onebox-1.8.1 vs lib/onebox/engine/pubmed_onebox.rb in onebox-1.8.2

- old
+ new

@@ -2,11 +2,11 @@ module Engine class PubmedOnebox include Engine include LayoutSupport - matches_regexp Regexp.new("^https?://(?:(?:\\w)+\\.)?(www.ncbi.nlm.nih)\\.gov(?:/)?/pubmed/") + matches_regexp Regexp.new("^https?://(?:(?:\\w)+\\.)?(www.ncbi.nlm.nih)\\.gov(?:/)?/pubmed/\\d+") private def get_xml doc = Nokogiri::XML(open(URI.join(@url, "?report=xml&format=text"))) @@ -24,22 +24,22 @@ end author_list.join(", ") end def date_of_xml(xml) - date_arr = (xml.css("PubDate")[0].children).map{|x| x.content} + date_arr = (xml.css("PubDate").children).map{|x| x.content} date_arr = date_arr.select{|s| !s.match(/^\s+$/)} date_arr = (date_arr.map{|s| s.split}).flatten date_arr.sort.reverse.join(" ") # Reverse sort so month before year. end def data xml = get_xml() { - title: xml.css("ArticleTitle")[0].content, + title: xml.css("ArticleTitle").text, authors: authors_of_xml(xml), - journal: xml.css("Title")[0].content, - abstract: xml.css("AbstractText")[0].content, + journal: xml.css("Title").text, + abstract: xml.css("AbstractText").text, date: date_of_xml(xml), link: @url, pmid: match[:pmid] } end