plos 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +1 -0
- data/README.md +1 -1
- data/lib/plos/article_ref.rb +2 -1
- data/lib/plos/client.rb +3 -3
- data/lib/plos/section.rb +1 -1
- data/lib/plos/version.rb +1 -1
- data/lib/plos/xml_helpers.rb +3 -3
- data/plos.gemspec +1 -0
- data/spec/article1_spec.rb +1 -0
- data/spec/article2_spec.rb +1 -0
- data/spec/plos_spec.rb +6 -0
- data/spec/spec_helper.rb +2 -0
- metadata +21 -21
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
M2U1ZTZlYjBmYTIxYzVjZjA1NGM2ZmYzYThkMjMwOTcyNWI5ODAyMQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MzliOTA2ODczYjE1Y2VmMWI2MDhjYWI4NzIwMzBlNmNlZDQwNGRlYg==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
OTZlMmE5MDhlY2Q2ODFmNDVkNjg5MGY4MzQ3YTRmZDI0YzA2MDY2MmRjYmJj
|
10
|
+
NmM0ZTcyODE1YTQ3MmE4YWQ3ODMyOTZiNTBkNTZjN2RmM2M1OGMxOWQ2NDFj
|
11
|
+
YjhkYjg3OGQxMDFiM2IzYjM5NDc4MDcyZGNkZDA5MzVlMTM0NWQ=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZmZiMDk2YmI3ODdmOTAxZGQ1ODcwYjhlNDgwM2VhYzE3NDU5YzE5NDViZmZh
|
14
|
+
MzdhZGQ3OGRlMmU3M2I2OWFmNTU1NGJhZmU5N2YyMzBmOTY3NzBkNjhmMmIw
|
15
|
+
ZGU4NzIyNzVkZDQzMzg5MmU5MjU2NThjOGQ3N2M0OGNmOGJiNTU=
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# PLoS [![Build Status](https://travis-ci.org/cpetersen/plos.png?branch=master)](https://travis-ci.org/cpetersen/plos)
|
1
|
+
# PLoS [![Build Status](https://travis-ci.org/cpetersen/plos.png?branch=master)](https://travis-ci.org/cpetersen/plos) [![Code Climate](https://codeclimate.com/github/cpetersen/plos.png)](https://codeclimate.com/github/cpetersen/plos) [![Coverage Status](https://coveralls.io/repos/cpetersen/plos/badge.png?branch=master)](https://coveralls.io/r/cpetersen/plos?branch=master)
|
2
2
|
|
3
3
|
A Ruby library for interacting with the Public Library of Science (PLoS) API
|
4
4
|
|
data/lib/plos/article_ref.rb
CHANGED
@@ -12,6 +12,7 @@ module PLOS
|
|
12
12
|
attr_accessor :journal
|
13
13
|
attr_accessor :published_at
|
14
14
|
attr_accessor :title
|
15
|
+
attr_accessor :abstract
|
15
16
|
|
16
17
|
alias :article_type= :type=
|
17
18
|
alias :author_display= :authors=
|
@@ -22,7 +23,7 @@ module PLOS
|
|
22
23
|
self.node = node
|
23
24
|
|
24
25
|
self.client = client
|
25
|
-
node.
|
26
|
+
node.xpath('./*').each do |child|
|
26
27
|
parse_node(child, self)
|
27
28
|
end
|
28
29
|
end
|
data/lib/plos/client.rb
CHANGED
@@ -19,9 +19,9 @@ module PLOS
|
|
19
19
|
result = PLOS::ArticleSet.new
|
20
20
|
doc = execute( search_url, { :q => query, :rows => rows, :start => start } )
|
21
21
|
if doc && doc.root
|
22
|
-
doc.root.
|
22
|
+
doc.root.xpath('./*').each do |child|
|
23
23
|
if child.name == "lst"
|
24
|
-
child.
|
24
|
+
child.xpath('./*').each do |int|
|
25
25
|
case int.attr("name")
|
26
26
|
when "status"
|
27
27
|
result.status = int.text
|
@@ -33,7 +33,7 @@ module PLOS
|
|
33
33
|
result.num_found = child.attr("numFound").to_i if child.attr("numFound")
|
34
34
|
result.start = child.attr("start").to_i if child.attr("start")
|
35
35
|
result.max_score = child.attr("maxScore").to_f if child.attr("maxScore")
|
36
|
-
child.
|
36
|
+
child.xpath('./*').each do |doc|
|
37
37
|
result << PLOS::ArticleRef.new(self, doc)
|
38
38
|
end
|
39
39
|
end
|
data/lib/plos/section.rb
CHANGED
@@ -11,7 +11,7 @@ module PLOS
|
|
11
11
|
def initialize(node)
|
12
12
|
self.id = node.attr("id") if node.attr("id")
|
13
13
|
self.type = node.attr("sec-type") if node.attr("sec-type")
|
14
|
-
node.
|
14
|
+
node.xpath('./*').each do |child|
|
15
15
|
case child.name
|
16
16
|
when "title"
|
17
17
|
self.title = child.text
|
data/lib/plos/version.rb
CHANGED
data/lib/plos/xml_helpers.rb
CHANGED
@@ -5,7 +5,7 @@ module PLOS
|
|
5
5
|
def parse_node(node, obj=nil)
|
6
6
|
value = case(node.name)
|
7
7
|
when "arr"
|
8
|
-
node.
|
8
|
+
node.xpath('./*').collect { |child| parse_node(child) }
|
9
9
|
when "date"
|
10
10
|
DateTime.parse(node.content)
|
11
11
|
when "float"
|
@@ -13,8 +13,8 @@ module PLOS
|
|
13
13
|
else
|
14
14
|
node.content
|
15
15
|
end
|
16
|
-
if node.attr("name") && obj
|
17
|
-
obj.send("#{node.attr("name")}=",value)
|
16
|
+
if node.attr("name") && obj && obj.respond_to?(:"#{node.attr("name")}=")
|
17
|
+
obj.send(:"#{node.attr("name")}=", value)
|
18
18
|
end
|
19
19
|
value
|
20
20
|
end
|
data/plos.gemspec
CHANGED
@@ -12,6 +12,7 @@ Gem::Specification.new do |gem|
|
|
12
12
|
gem.add_dependency('rest-client')
|
13
13
|
gem.add_development_dependency('rake')
|
14
14
|
gem.add_development_dependency('rspec')
|
15
|
+
gem.add_development_dependency('coveralls')
|
15
16
|
|
16
17
|
gem.files = `git ls-files`.split($\)
|
17
18
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
data/spec/article1_spec.rb
CHANGED
data/spec/article2_spec.rb
CHANGED
data/spec/plos_spec.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'plos'
|
2
|
+
require 'spec_helper'
|
2
3
|
|
3
4
|
describe PLOS do
|
4
5
|
context "A client" do
|
@@ -43,6 +44,11 @@ describe PLOS do
|
|
43
44
|
<str>Joseph E. Tomaszewski</str>
|
44
45
|
<str>James H. Doroshow</str>
|
45
46
|
</arr>
|
47
|
+
<arr name="abstract">
|
48
|
+
<str>
|
49
|
+
Lorem ipsum dolor sit amet
|
50
|
+
</str>
|
51
|
+
</arr>
|
46
52
|
<str name="eissn">1932-6203</str>
|
47
53
|
<str name="id">10.1371/journal.pone.0050494</str>
|
48
54
|
<str name="journal">PLoS ONE</str>
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: plos
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.7
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Christopher Petersen
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-03-13 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: nokogiri
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ! '>='
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ! '>='
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,7 +27,6 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rest-client
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ! '>='
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,7 +34,6 @@ dependencies:
|
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ! '>='
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -46,7 +41,6 @@ dependencies:
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rake
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
45
|
- - ! '>='
|
52
46
|
- !ruby/object:Gem::Version
|
@@ -54,7 +48,6 @@ dependencies:
|
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
52
|
- - ! '>='
|
60
53
|
- !ruby/object:Gem::Version
|
@@ -62,7 +55,6 @@ dependencies:
|
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: rspec
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
59
|
- - ! '>='
|
68
60
|
- !ruby/object:Gem::Version
|
@@ -70,7 +62,20 @@ dependencies:
|
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: coveralls
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
79
|
requirements:
|
75
80
|
- - ! '>='
|
76
81
|
- !ruby/object:Gem::Version
|
@@ -108,35 +113,29 @@ files:
|
|
108
113
|
- spec/article2.xml
|
109
114
|
- spec/article2_spec.rb
|
110
115
|
- spec/plos_spec.rb
|
116
|
+
- spec/spec_helper.rb
|
111
117
|
homepage: https://github.com/cpetersen/plos
|
112
118
|
licenses: []
|
119
|
+
metadata: {}
|
113
120
|
post_install_message:
|
114
121
|
rdoc_options: []
|
115
122
|
require_paths:
|
116
123
|
- lib
|
117
124
|
required_ruby_version: !ruby/object:Gem::Requirement
|
118
|
-
none: false
|
119
125
|
requirements:
|
120
126
|
- - ! '>='
|
121
127
|
- !ruby/object:Gem::Version
|
122
128
|
version: '0'
|
123
|
-
segments:
|
124
|
-
- 0
|
125
|
-
hash: -3893775921126940729
|
126
129
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
127
|
-
none: false
|
128
130
|
requirements:
|
129
131
|
- - ! '>='
|
130
132
|
- !ruby/object:Gem::Version
|
131
133
|
version: '0'
|
132
|
-
segments:
|
133
|
-
- 0
|
134
|
-
hash: -3893775921126940729
|
135
134
|
requirements: []
|
136
135
|
rubyforge_project:
|
137
|
-
rubygems_version:
|
136
|
+
rubygems_version: 2.2.1
|
138
137
|
signing_key:
|
139
|
-
specification_version:
|
138
|
+
specification_version: 4
|
140
139
|
summary: A Ruby library for interacting with the Public Library of Science (PLoS)
|
141
140
|
API
|
142
141
|
test_files:
|
@@ -145,3 +144,4 @@ test_files:
|
|
145
144
|
- spec/article2.xml
|
146
145
|
- spec/article2_spec.rb
|
147
146
|
- spec/plos_spec.rb
|
147
|
+
- spec/spec_helper.rb
|