Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 2 commits
  • 5 files changed
  • 0 comments
  • 1 contributor
5 README
... ... @@ -1,5 +0,0 @@
1   -RpmGem - Ruby PubMed Gem
2   -
3   -A little gem to pull publication details from pubmed, via the ncbi.nlm.nih.gov's Entrez eutils service.
4   -Will fetch the xml document for a given pubmed id and provides handy attribute readers via REXML, ie only requires stlib.
5   -
17 README.md
Source Rendered
... ... @@ -0,0 +1,17 @@
  1 +# RpmGem - Ruby PubMed Gem
  2 +
  3 +A very small gem to pull publication details from pubmed, via the ncbi.nlm.nih.gov's Entrez eutils service.
  4 +Will fetch the xml document for a given pubmed id and provides handy attribute readers via REXML, ie only requires stlib.
  5 +
  6 +### Like how easy?
  7 +
  8 + c = RpmGem::Citation.new 12563742
  9 + => #<RpmGem::Citation:0x0000000291d988 @id=12563742>
  10 + c.article_title
  11 + => "[Dynamic changes in IL-4, IL-5 and IL-10 in liver and bone marrow of mice infected with Schistosoma japonicum]."
  12 + c.journal_title
  13 + => "Zhongguo ji sheng chong xue yu ji sheng chong bing za zhi = Chinese journal of parasitology & parasitic diseases"
  14 + c.year
  15 + => "1999"
  16 +
  17 +
12 lib/rpm_gem/citation.rb
@@ -64,15 +64,23 @@ def self.define_fields
64 64 end
65 65 end
66 66 end
67   -
  67 +
68 68 def xpath_map xpath
69 69 if xml_doc
70   - return REXML::XPath.each(xml_doc, xpath).map {|x| x.text}
  70 + return cond_rem_sq_brackets(REXML::XPath.each(xml_doc, xpath).map {|x| x.text})
71 71 else
72 72 return nil
73 73 end
74 74 end
75 75
  76 + def cond_rem_sq_brackets x
  77 + if x.is_a?(Array) && (x.size < 2)
  78 + x[0]
  79 + else
  80 + x
  81 + end
  82 + end
  83 +
76 84 define_fields
77 85 end
78 86
2  lib/rpm_gem/version.rb
... ... @@ -1,3 +1,3 @@
1 1 module RpmGem
2   - VERSION = "0.0.1"
  2 + VERSION = "0.0.2"
3 3 end
2  test/test_pub_med_xml_fetcher.rb
@@ -8,7 +8,7 @@ def setup
8 8 end
9 9
10 10 def test_fetch
11   - xml = RpmGem::PubMedXMLFetcher.fetch_xml_for_id @id
  11 + assert RpmGem::PubMedXMLFetcher.fetch_xml_for_id @id
12 12 end
13 13
14 14 end

No commit comments for this range

Something went wrong with that request. Please try again.