pubmed_search 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +14 -14
- data/VERSION +1 -1
- data/lib/pubmed_search.rb +5 -1
- data/pubmed_search.gemspec +24 -26
- data/spec/pubmed_search_spec.rb +13 -3
- data/spec/spec_helper.rb +3 -2
- metadata +36 -17
- data/.gitignore +0 -5
data/Rakefile
CHANGED
@@ -18,20 +18,20 @@ rescue LoadError
|
|
18
18
|
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
19
19
|
end
|
20
20
|
|
21
|
-
require 'spec/rake/spectask'
|
22
|
-
Spec::Rake::SpecTask.new(:spec) do |spec|
|
23
|
-
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
|
-
task :default => :spec
|
21
|
+
# require 'spec/rake/spectask'
|
22
|
+
# Spec::Rake::SpecTask.new(:spec) do |spec|
|
23
|
+
# spec.libs << 'lib' << 'spec'
|
24
|
+
# spec.spec_files = FileList['spec/**/*_spec.rb']
|
25
|
+
# end
|
26
|
+
#
|
27
|
+
# Spec::Rake::SpecTask.new(:rcov) do |spec|
|
28
|
+
# spec.libs << 'lib' << 'spec'
|
29
|
+
# spec.pattern = 'spec/**/*_spec.rb'
|
30
|
+
# spec.rcov = true
|
31
|
+
# end
|
32
|
+
#
|
33
|
+
#
|
34
|
+
# task :default => :spec
|
35
35
|
|
36
36
|
require 'rake/rdoctask'
|
37
37
|
Rake::RDocTask.new do |rdoc|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/lib/pubmed_search.rb
CHANGED
@@ -22,9 +22,11 @@ class PubmedSearch
|
|
22
22
|
WAIT_TIME = 1 # seconds
|
23
23
|
DEFAULT_OPTIONS = {:retmax => 100000,
|
24
24
|
:retstart => 0,
|
25
|
+
:tool => 'ruby-pubmed_search',
|
26
|
+
:email => '',
|
25
27
|
:load_all_pmids => false }
|
26
28
|
|
27
|
-
@uri_template = SimpleURITemplate.new('http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&retmax={retmax}&retstart={retstart}&term={term}')
|
29
|
+
@uri_template = SimpleURITemplate.new('http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&tool={tool}&email={email}&retmax={retmax}&retstart={retstart}&term={term}')
|
28
30
|
|
29
31
|
class << self
|
30
32
|
# Performs a search to PubMed via eUtils with the given term +String+, and returns a +PubmedSearch+ object modeling the response.
|
@@ -32,6 +34,8 @@ class PubmedSearch
|
|
32
34
|
# Accepts a +Hash+ of options. Valid options are
|
33
35
|
# * :retmax - Defaults to 100,000 which is the largest retmax that PubMed will honor.
|
34
36
|
# * :retstart - Defaults to 0. Set higher if you need to page through results. You shouldn't need to do that manually, because of the +load_all_pmids+ option
|
37
|
+
# * :tool - Defaults to 'ruby-pubmed_search', set to the name of your tool per EUtils parameters specs
|
38
|
+
# * :email - Defaults to '', set to your email address per EUtils parameters specs
|
35
39
|
# * :load_all_pmids - Defaults to +false+. If this is set +true+, then search will continue sending eSearches with an increasing retstart until the list of pmids == count. For instance, an eSearch for "Mus musculus" will return ~951134 results, but the highest retmax allowable is 100000. With +load_all_pmids+ set +true+, search will automatically perform 10 eSearches and return the entire list of pmids in one go.
|
36
40
|
def search(term, options={})
|
37
41
|
options = DEFAULT_OPTIONS.merge(options)
|
data/pubmed_search.gemspec
CHANGED
@@ -1,54 +1,51 @@
|
|
1
1
|
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{pubmed_search}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ryan Schenk"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-12-13}
|
13
13
|
s.email = %q{rschenk@gmail.com}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"LICENSE",
|
16
|
-
|
16
|
+
"README.rdoc"
|
17
17
|
]
|
18
18
|
s.files = [
|
19
19
|
".document",
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
"spec/spec_helper.rb"
|
20
|
+
"LICENSE",
|
21
|
+
"README.rdoc",
|
22
|
+
"Rakefile",
|
23
|
+
"VERSION",
|
24
|
+
"lib/pubmed_search.rb",
|
25
|
+
"pubmed_search.gemspec",
|
26
|
+
"spec/pubmed_search_spec.rb",
|
27
|
+
"spec/responses/bangana_tonkinensis_cranksection.xml",
|
28
|
+
"spec/responses/biodiversity_informatics.xml",
|
29
|
+
"spec/responses/e_coli_0.xml",
|
30
|
+
"spec/responses/e_coli_1.xml",
|
31
|
+
"spec/responses/e_coli_2.xml",
|
32
|
+
"spec/responses/mus_musculus.xml",
|
33
|
+
"spec/spec_helper.rb"
|
35
34
|
]
|
36
|
-
s.has_rdoc = true
|
37
35
|
s.homepage = %q{http://github.com/rschenk/pubmed_search}
|
38
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
39
36
|
s.require_paths = ["lib"]
|
40
|
-
s.rubygems_version = %q{1.3.
|
37
|
+
s.rubygems_version = %q{1.3.7}
|
41
38
|
s.summary = %q{A PubMed searching library with more features than BioRuby}
|
42
39
|
s.test_files = [
|
43
40
|
"spec/pubmed_search_spec.rb",
|
44
|
-
|
41
|
+
"spec/spec_helper.rb"
|
45
42
|
]
|
46
43
|
|
47
44
|
if s.respond_to? :specification_version then
|
48
45
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
49
|
-
s.specification_version =
|
46
|
+
s.specification_version = 3
|
50
47
|
|
51
|
-
if Gem::Version.new(Gem::
|
48
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
52
49
|
s.add_runtime_dependency(%q<rschenk-simple_uri_template>, [">= 0"])
|
53
50
|
s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
|
54
51
|
else
|
@@ -60,3 +57,4 @@ Gem::Specification.new do |s|
|
|
60
57
|
s.add_dependency(%q<nokogiri>, [">= 0"])
|
61
58
|
end
|
62
59
|
end
|
60
|
+
|
data/spec/pubmed_search_spec.rb
CHANGED
@@ -44,10 +44,20 @@ describe PubmedSearch do
|
|
44
44
|
FakeWeb.allow_net_connect = false
|
45
45
|
end
|
46
46
|
|
47
|
+
it "should allow the user to specify the name of their tool" do
|
48
|
+
FakeWeb.register_uri(:any, "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&tool=ligercat&email=&retmax=100000&retstart=0&term=e%20coli", :body => File.dirname(__FILE__) + '/responses/e_coli_0.xml')
|
49
|
+
PubmedSearch.search "e coli", :tool => 'ligercat' # note "tool=ligercat" in above URL. Fakeweb will complain and fail spec if necessary
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should allow the user to specify their email address" do
|
53
|
+
FakeWeb.register_uri(:any, "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&tool=ruby-pubmed_search&email=someone@someplace.edu&retmax=100000&retstart=0&term=e%20coli", :body => File.dirname(__FILE__) + '/responses/e_coli_0.xml')
|
54
|
+
PubmedSearch.search "e coli", :email => 'someone@someplace.edu' # note "email=someone@someplace.edu" in above URL. Fakeweb will complain and fail spec if necessary
|
55
|
+
end
|
56
|
+
|
47
57
|
it "should allow multiple requests to NLM if Count > Retmax if desired" do
|
48
|
-
FakeWeb.register_uri(:any, "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&retmax=100000&retstart=0&term=e%20coli", :body => File.dirname(__FILE__) + '/responses/e_coli_0.xml')
|
49
|
-
FakeWeb.register_uri(:any, "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&retmax=100000&retstart=100000&term=e%20coli", :body => File.dirname(__FILE__) + '/responses/e_coli_1.xml')
|
50
|
-
FakeWeb.register_uri(:any, "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&retmax=100000&retstart=200000&term=e%20coli", :body => File.dirname(__FILE__) + '/responses/e_coli_2.xml')
|
58
|
+
FakeWeb.register_uri(:any, "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&tool=ruby-pubmed_search&email=&retmax=100000&retstart=0&term=e%20coli", :body => File.dirname(__FILE__) + '/responses/e_coli_0.xml')
|
59
|
+
FakeWeb.register_uri(:any, "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&tool=ruby-pubmed_search&email=&retmax=100000&retstart=100000&term=e%20coli", :body => File.dirname(__FILE__) + '/responses/e_coli_1.xml')
|
60
|
+
FakeWeb.register_uri(:any, "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&tool=ruby-pubmed_search&email=&retmax=100000&retstart=200000&term=e%20coli", :body => File.dirname(__FILE__) + '/responses/e_coli_2.xml')
|
51
61
|
|
52
62
|
result = PubmedSearch.search("e coli", :load_all_pmids => true)
|
53
63
|
|
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
require '
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rspec'
|
2
3
|
require 'uri'
|
3
4
|
require 'fakeweb'
|
4
5
|
|
@@ -16,7 +17,7 @@ FakeWeb.allow_net_connect = false
|
|
16
17
|
|
17
18
|
def fake_esearch_response(search_term, options={})
|
18
19
|
file = options[:file] || search_term.downcase.gsub(/\W/, '_')
|
19
|
-
FakeWeb.register_uri(:any, "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&retmax=100000&retstart=0&term=#{URI.escape search_term}",
|
20
|
+
FakeWeb.register_uri(:any, "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&tool=ruby-pubmed_search&email=&retmax=100000&retstart=0&term=#{URI.escape search_term}",
|
20
21
|
:body => File.dirname(__FILE__) + "/responses/#{file}.xml")
|
21
22
|
end
|
22
23
|
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pubmed_search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 19
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 0.3.0
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- Ryan Schenk
|
@@ -9,29 +15,37 @@ autorequire:
|
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date: 2010-
|
18
|
+
date: 2010-12-13 00:00:00 -05:00
|
13
19
|
default_executable:
|
14
20
|
dependencies:
|
15
21
|
- !ruby/object:Gem::Dependency
|
16
22
|
name: rschenk-simple_uri_template
|
17
|
-
|
18
|
-
|
19
|
-
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
20
26
|
requirements:
|
21
27
|
- - ">="
|
22
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
23
32
|
version: "0"
|
24
|
-
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
25
35
|
- !ruby/object:Gem::Dependency
|
26
36
|
name: nokogiri
|
27
|
-
|
28
|
-
|
29
|
-
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
30
40
|
requirements:
|
31
41
|
- - ">="
|
32
42
|
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
33
46
|
version: "0"
|
34
|
-
|
47
|
+
type: :runtime
|
48
|
+
version_requirements: *id002
|
35
49
|
description:
|
36
50
|
email: rschenk@gmail.com
|
37
51
|
executables: []
|
@@ -43,7 +57,6 @@ extra_rdoc_files:
|
|
43
57
|
- README.rdoc
|
44
58
|
files:
|
45
59
|
- .document
|
46
|
-
- .gitignore
|
47
60
|
- LICENSE
|
48
61
|
- README.rdoc
|
49
62
|
- Rakefile
|
@@ -63,28 +76,34 @@ homepage: http://github.com/rschenk/pubmed_search
|
|
63
76
|
licenses: []
|
64
77
|
|
65
78
|
post_install_message:
|
66
|
-
rdoc_options:
|
67
|
-
|
79
|
+
rdoc_options: []
|
80
|
+
|
68
81
|
require_paths:
|
69
82
|
- lib
|
70
83
|
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
71
85
|
requirements:
|
72
86
|
- - ">="
|
73
87
|
- !ruby/object:Gem::Version
|
88
|
+
hash: 3
|
89
|
+
segments:
|
90
|
+
- 0
|
74
91
|
version: "0"
|
75
|
-
version:
|
76
92
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
none: false
|
77
94
|
requirements:
|
78
95
|
- - ">="
|
79
96
|
- !ruby/object:Gem::Version
|
97
|
+
hash: 3
|
98
|
+
segments:
|
99
|
+
- 0
|
80
100
|
version: "0"
|
81
|
-
version:
|
82
101
|
requirements: []
|
83
102
|
|
84
103
|
rubyforge_project:
|
85
|
-
rubygems_version: 1.3.
|
104
|
+
rubygems_version: 1.3.7
|
86
105
|
signing_key:
|
87
|
-
specification_version:
|
106
|
+
specification_version: 3
|
88
107
|
summary: A PubMed searching library with more features than BioRuby
|
89
108
|
test_files:
|
90
109
|
- spec/pubmed_search_spec.rb
|