entrez 0.5.3 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/entrez.rb +6 -1
- data/lib/entrez/version.rb +1 -1
- data/spec/entrez_spec.rb +7 -1
- metadata +1 -1
data/lib/entrez.rb
CHANGED
@@ -72,7 +72,12 @@ class Entrez
|
|
72
72
|
def parse_ids_and_extend(response)
|
73
73
|
response.instance_eval do
|
74
74
|
def ids
|
75
|
-
@ids
|
75
|
+
return @ids if @ids
|
76
|
+
id_content = self['eSearchResult']['IdList']['Id']
|
77
|
+
# If there is only 1, Crack will parse it and return just the string.
|
78
|
+
# Need to always return array.
|
79
|
+
id_content = [id_content].flatten
|
80
|
+
@ids = id_content.map(&:to_i)
|
76
81
|
rescue ::NoMethodError
|
77
82
|
@ids = []
|
78
83
|
end
|
data/lib/entrez/version.rb
CHANGED
data/spec/entrez_spec.rb
CHANGED
@@ -32,11 +32,17 @@ describe Entrez do
|
|
32
32
|
response.ids.should == [60153, 29429, 28911, 48101, 59851, 59849, 59847, 59845, 59839, 59835, 59833, 59831, 51895, 59829, 59827, 60835, 59811, 60831, 60819, 33895]
|
33
33
|
end
|
34
34
|
|
35
|
-
it 'ESearch returns empty array if nothing found' do
|
35
|
+
it '#ESearch returns empty array if nothing found' do
|
36
36
|
response = Entrez.ESearch('genomeprj', {NON_EXISTENT_SEARCH_FIELD: 'does not exist even in oompaloompa land'}, retmode: :xml)
|
37
37
|
response.ids.should be_empty
|
38
38
|
end
|
39
39
|
|
40
|
+
it '#ESearch returns array even if only 1 id found' do
|
41
|
+
id = 60153
|
42
|
+
response = Entrez.ESearch('genomeprj', {uid: id}, retmode: :xml)
|
43
|
+
response.ids.should == [id]
|
44
|
+
end
|
45
|
+
|
40
46
|
it '#ESearch accepts string as search_terms parameter' do
|
41
47
|
response = Entrez.ESearch('genomeprj', 'hapmap[WORD]', retmode: :xml)
|
42
48
|
response.ids.should include(60153)
|