paper_metadata 0.0.2 → 0.0.3

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6feae0c4735bc5e79114e6ade692e83b31cafcaa
4
+ data.tar.gz: 177849e6b701c11472db0cf332eb58a554a8f419
5
+ SHA512:
6
+ metadata.gz: 635965a8441b3d67fd8c659ebd44a642c0ee9bc5da72e720922a23c72c64d1c884122c01cfc4ae3969e9c629123f2f3addabe6575974745f94ac7d584a41bd3d
7
+ data.tar.gz: 47cbc3c5b7d8e5ea250c2da42dffd3f87d9c4fc8c55bc06da3e35a959df5d00f181bd43adf8ab559405fc41aaa0842887904b6da07534f0ce9e25cc6d9972952
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # PaperMetadata
2
2
 
3
- TODO: Write a gem description
3
+ PaperMetadata is a gem that gets a publication's metadata by accessing the CrossRef OpenURL API.
4
4
 
5
5
  ## Installation
6
6
 
@@ -18,7 +18,25 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- TODO: Write usage instructions here
21
+ You must first configure PaperMetadata with your CrossRef API username (which you can obtain here [http://www.crossref.org/requestaccount/](http://www.crossref.org/requestaccount/)):
22
+
23
+ PaperMetadata.doi_username = 'email@example.com'
24
+
25
+ You can then access API:
26
+
27
+ result = PaperMetadata.metadata_for('doi:10.1021/ac1014832')
28
+
29
+ The result will be a hash similar to this one:
30
+
31
+ { :volume=>"82",
32
+ :isssue=>"19",
33
+ :first_page=>"8153",
34
+ :last_page=>"8160",
35
+ :title=>
36
+ "Basic Modeling Approach To Optimize Elemental Imaging by Laser Ablation ICPMS",
37
+ :authors=>"Jure Triglav, Johannes T. van Elteren, Vid S. Šelih",
38
+ :journal=>"Anal. Chem. 2010",
39
+ :resource=>"http://pubs.acs.org/doi/abs/10.1021/ac1014832" }
22
40
 
23
41
  ## Contributing
24
42
 
@@ -27,3 +45,5 @@ TODO: Write usage instructions here
27
45
  3. Commit your changes (`git commit -am 'Add some feature'`)
28
46
  4. Push to the branch (`git push origin my-new-feature`)
29
47
  5. Create new Pull Request
48
+
49
+ Be sure to run the specs too.
@@ -1,3 +1,3 @@
1
1
  module PaperMetadata
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -2,6 +2,7 @@ require 'paper_metadata/version'
2
2
  require 'nokogiri'
3
3
  require 'net/http'
4
4
  require 'open-uri'
5
+ require 'cgi'
5
6
 
6
7
  module PaperMetadata
7
8
  class << self
@@ -21,7 +22,7 @@ module PaperMetadata
21
22
  end
22
23
 
23
24
  def metadata_for_doi(doi)
24
- doc = Nokogiri::XML(open("http://www.crossref.org/openurl/?id=doi:#{doi}&noredirect=true&pid=#{PaperMetadata.doi_username}&format=unixref"))
25
+ doc = Nokogiri::XML(open("http://www.crossref.org/openurl/?id=#{CGI.escape(doi)}&noredirect=true&pid=#{PaperMetadata.doi_username}&format=unixref"))
25
26
  paper = Hash.new
26
27
 
27
28
  if doc.xpath("//titles/title").first
@@ -48,7 +49,7 @@ module PaperMetadata
48
49
 
49
50
  def metadata_for_arxiv(identifier)
50
51
  identifier.gsub!(/^arXiv\:/i, '')
51
- url = URI.parse("http://export.arxiv.org/api/query?search_query=#{identifier}&start=0&max_results=1")
52
+ url = URI.parse("http://export.arxiv.org/api/query?search_query=#{CGI.escape(identifier)}&start=0&max_results=1")
52
53
  res = Net::HTTP.get_response(url)
53
54
  doc = Nokogiri::XML(res.body)
54
55
  doc.remove_namespaces!
@@ -10,6 +10,7 @@ class PaperMetadataTest < Test::Unit::TestCase
10
10
  to_return(:body => doi_response, :status => 200, :headers => { 'Content-Length' => doi_response.length } )
11
11
 
12
12
  PaperMetadata.doi_username = 'test@example.com'
13
+
13
14
  assert_equal "Basic Modeling Approach To Optimize Elemental Imaging by Laser Ablation ICPMS",
14
15
  PaperMetadata.metadata_for('doi:10.1021/ac1014832')[:title]
15
16
  end
metadata CHANGED
@@ -1,68 +1,60 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paper_metadata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
5
- prerelease:
4
+ version: 0.0.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Jure Triglav
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-02-03 00:00:00.000000000 Z
11
+ date: 2013-05-24 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: pry
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :development
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
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
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
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: webmock
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
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
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: nokogiri
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - '='
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - '='
76
67
  - !ruby/object:Gem::Version
@@ -97,33 +88,26 @@ files:
97
88
  - test/test_paper_metadata.rb
98
89
  homepage: http://github.com/jure/paper_metadata
99
90
  licenses: []
91
+ metadata: {}
100
92
  post_install_message:
101
93
  rdoc_options: []
102
94
  require_paths:
103
95
  - lib
104
96
  required_ruby_version: !ruby/object:Gem::Requirement
105
- none: false
106
97
  requirements:
107
- - - ! '>='
98
+ - - '>='
108
99
  - !ruby/object:Gem::Version
109
100
  version: '0'
110
- segments:
111
- - 0
112
- hash: 3600841422175900460
113
101
  required_rubygems_version: !ruby/object:Gem::Requirement
114
- none: false
115
102
  requirements:
116
- - - ! '>='
103
+ - - '>='
117
104
  - !ruby/object:Gem::Version
118
105
  version: '0'
119
- segments:
120
- - 0
121
- hash: 3600841422175900460
122
106
  requirements: []
123
107
  rubyforge_project:
124
- rubygems_version: 1.8.23
108
+ rubygems_version: 2.0.0
125
109
  signing_key:
126
- specification_version: 3
110
+ specification_version: 4
127
111
  summary: Paper_metadata gem gets the metadata for papers with a DOI or an arXiv identifier
128
112
  test_files:
129
113
  - test/arxiv.xml