plos 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -18,6 +18,17 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
+ ### Retrieving All Article References
22
+
23
+ The ```all``` methods returns all references from PLOS. The method takes the form ```PLOS::Client.all(start, rows)```. You can page the results using the start parameter. Rows determines the page size.
24
+
25
+ ```ruby
26
+ require 'plos'
27
+
28
+ client = PLOS::Client.new(ENV["API_KEY"])
29
+ hits = client.all
30
+ ```
31
+
21
32
  ### Searching
22
33
 
23
34
  You can perform a basic search using the ```PLOS::Client.search(query, start, rows)``` method. The second two parameters are optional. That method returns a ```PLOS::ArticleSet``` object. ```ArticleSet``` inherits from Array and includes some meta-information about the search. The following example show the information that's available:
@@ -55,10 +66,32 @@ client = PLOS::Client.new(ENV["API_KEY"])
55
66
  hits = client.all(200, 100)
56
67
  ```
57
68
 
69
+ Note: there may be multiple ```ArticleRef```'s pointing to the same article. For instance, a search for "*:*" will return references for:
70
+
71
+ * 10.1371/journal.pbio.0040394
72
+ * 10.1371/journal.pbio.0040394/title
73
+ * 10.1371/journal.pbio.0040394/abstract
74
+ * 10.1371/journal.pbio.0040394/references
75
+ * 10.1371/journal.pbio.0040394/body
76
+
77
+ which all point to the same article, 10.1371/journal.pbio.0040394. You can access the id of the article and identifier which part of the article this reference refers to with the methods ```article_id``` and ```article_part``` respectively.
78
+
79
+ ```ruby
80
+ require 'plos'
81
+
82
+ client = PLOS::Client.new(ENV["API_KEY"])
83
+ hits = client.all
84
+
85
+ hits.each do |hit|
86
+ puts "#{hit.title} - #{hit.article_id} - #{hit.article_part}"
87
+ end
88
+ ```
89
+
58
90
  ### Getting the Article Details
59
91
 
60
92
  You may get an ```Article``` object using ```ArticleRef.article```. For example, the following returns a ```PLOS::Article```:
61
93
 
94
+
62
95
  ```ruby
63
96
  require 'plos'
64
97
  client = PLOS::Client.new(ENV["API_KEY"])
@@ -121,7 +154,7 @@ require 'plos'
121
154
  client = PLOS::Client.new(ENV["API_KEY"])
122
155
  hits = client.search("xenograft")
123
156
  article_id = hits.first.id
124
- PLOS::Article.content(id) # Returns the xml as a string
157
+ PLOS::Article.content(article_id) # Returns the xml as a string
125
158
  ```
126
159
 
127
160
  ```PLOS::Article.xml(id)``` returns a ```Nokogiri::XML``` object of the xml contents.
@@ -27,8 +27,16 @@ module PLOS
27
27
  end
28
28
  end
29
29
 
30
+ def article_id
31
+ id.split("/")[0..1].join("/") if id
32
+ end
33
+
34
+ def article_part
35
+ id.split("/")[2] if id
36
+ end
37
+
30
38
  def article
31
- @article ||= PLOS::Article.get(id)
39
+ @article ||= PLOS::Article.get(article_id)
32
40
  end
33
41
 
34
42
  def citation(format="RIS")
data/lib/plos/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Plos
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plos
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-04 00:00:00.000000000 Z
12
+ date: 2013-02-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -122,7 +122,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
122
122
  version: '0'
123
123
  segments:
124
124
  - 0
125
- hash: -4503252399675787429
125
+ hash: -3893775921126940729
126
126
  required_rubygems_version: !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
@@ -131,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
131
  version: '0'
132
132
  segments:
133
133
  - 0
134
- hash: -4503252399675787429
134
+ hash: -3893775921126940729
135
135
  requirements: []
136
136
  rubyforge_project:
137
137
  rubygems_version: 1.8.24