biburi 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.travis.yml +6 -0
- data/CHANGELOG.mediawiki +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +52 -0
- data/Rakefile +11 -0
- data/biburi.gemspec +28 -0
- data/lib/biburi/driver/doi.rb +174 -0
- data/lib/biburi/driver.rb +50 -0
- data/lib/biburi/version.rb +3 -0
- data/lib/biburi.rb +33 -0
- data/spec/biburi_spec.rb +64 -0
- data/spec/doi_spec.rb +83 -0
- data/spec/spec_helper.rb +5 -0
- metadata +146 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a1c33a8d71f4dfb1035bb83a6f4be20820372286
|
4
|
+
data.tar.gz: 85efe72c97ada25dd9fb831b253e8237eee4341f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4fc5f2c69f6a36372d25f94517bd4e926328c830cac8bdcda80f147b47ad454674a872e28413514bedb98fe0e510c8cb296b18749d8f36efde09c67ce6365114
|
7
|
+
data.tar.gz: d6fe457ac2cf2538a2b82e7735183b55819c2162b22eee6e8a2310031c35caba939f13e4ffd13165e4f2bab2850761053374393a0254b5910faee0494b2217f6
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.mediawiki
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Gaurav Vaidya
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# BibURI
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/biburi.png)](http://badge.fury.io/rb/biburi)
|
4
|
+
[![Continuous Integration Status][1]][2]
|
5
|
+
[![Coverage Status][3]][4]
|
6
|
+
[![Dependency Status][5]][6]
|
7
|
+
|
8
|
+
This is a gem to extract BibTeX information for URIs which refer to bibliographic
|
9
|
+
resources, such as DOIs, Biodiversity Heritage Library links, and others.
|
10
|
+
|
11
|
+
Currently, BibURI supports the following types of data:
|
12
|
+
|
13
|
+
- DOIs (via CrossRef)
|
14
|
+
|
15
|
+
## Installation
|
16
|
+
|
17
|
+
Add this line to your application's Gemfile:
|
18
|
+
|
19
|
+
gem 'biburi'
|
20
|
+
|
21
|
+
And then execute:
|
22
|
+
|
23
|
+
$ bundle
|
24
|
+
|
25
|
+
Or install it yourself as:
|
26
|
+
|
27
|
+
$ gem install biburi
|
28
|
+
|
29
|
+
## Usage
|
30
|
+
|
31
|
+
BibURI mainly works out of a single method:
|
32
|
+
|
33
|
+
require 'biburi'
|
34
|
+
|
35
|
+
results = BibURI::lookup('doi:10.1038/171737a0')
|
36
|
+
|
37
|
+
Full documentation is [available online at RubyDoc.org](http://rubydoc.org/github/gaurav/biburi/master/frames).
|
38
|
+
|
39
|
+
## Contributing
|
40
|
+
|
41
|
+
1. Fork it
|
42
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
43
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
44
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
45
|
+
5. Create new pull request
|
46
|
+
|
47
|
+
[1]: https://secure.travis-ci.org/gaurav/biburi.png
|
48
|
+
[2]: http://travis-ci.org/gaurav/biburi
|
49
|
+
[3]: https://coveralls.io/repos/gaurav/biburi/badge.png?branch=master
|
50
|
+
[4]: https://coveralls.io/r/gaurav/biburi?branch=master
|
51
|
+
[5]: https://gemnasium.com/gaurav/biburi.png
|
52
|
+
[6]: https://gemnasium.com/gaurav/biburi
|
data/Rakefile
ADDED
data/biburi.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'biburi/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "biburi"
|
8
|
+
spec.version = BibURI::VERSION
|
9
|
+
spec.authors = ["Gaurav Vaidya"]
|
10
|
+
spec.email = ["gaurav@ggvaidya.com"]
|
11
|
+
spec.description = %q{Find the BibTeX information when your citation has an identifier}
|
12
|
+
spec.summary = %q{URI to BibTeX lookup gem}
|
13
|
+
spec.homepage = "http://github.com/gaurav/biburi"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
spec.add_development_dependency "rspec-core"
|
25
|
+
spec.add_development_dependency "coveralls"
|
26
|
+
|
27
|
+
spec.add_runtime_dependency 'bibtex-ruby', '~> 2.0'
|
28
|
+
end
|
@@ -0,0 +1,174 @@
|
|
1
|
+
# A driver to read BibTeX for DOI via CrossRef's
|
2
|
+
# public API: http://search.crossref.org/help/api
|
3
|
+
#
|
4
|
+
# Author:: Gaurav Vaidya
|
5
|
+
# Copyright:: Copyright (c) 2013 Gaurav Vaidya
|
6
|
+
# License:: MIT
|
7
|
+
|
8
|
+
require 'biburi'
|
9
|
+
require 'biburi/driver'
|
10
|
+
require 'net/http'
|
11
|
+
require 'json'
|
12
|
+
require 'bibtex'
|
13
|
+
|
14
|
+
# For CGI::parse to make sense of COinS
|
15
|
+
require 'cgi'
|
16
|
+
|
17
|
+
# This driver provides information in BibTeX on a DOI by
|
18
|
+
# querying CrossRef's metadata search API.
|
19
|
+
|
20
|
+
module BibURI::Driver::DOI
|
21
|
+
include BibURI::Driver
|
22
|
+
|
23
|
+
# We support an identifier if we can make them look
|
24
|
+
# canonical.
|
25
|
+
def self.supported?(id)
|
26
|
+
canonical = BibURI::Driver::DOI::canonical(id)
|
27
|
+
return !(canonical.nil?)
|
28
|
+
end
|
29
|
+
|
30
|
+
# The canonical form of a DOI can be one of
|
31
|
+
# - http://dx.doi.org/10.1234/abcd-5678
|
32
|
+
# - doi:10.1234/abcd-5678
|
33
|
+
def self.canonical(id)
|
34
|
+
# doi:10.1234/abcd-5678
|
35
|
+
match = id.match(/^doi:(.*)$/i)
|
36
|
+
if match
|
37
|
+
return "http://dx.doi.org/" + match[1]
|
38
|
+
end
|
39
|
+
|
40
|
+
# http://dx.doi.org/10.1234/abcd-5678
|
41
|
+
match = id.match(/^http:\/\/dx\.doi\.org\/(.*)$/i)
|
42
|
+
if match
|
43
|
+
return "http://dx.doi.org/" + match[1]
|
44
|
+
end
|
45
|
+
|
46
|
+
# If no match, return nil.
|
47
|
+
nil
|
48
|
+
end
|
49
|
+
|
50
|
+
# Returns a list of parsed values with
|
51
|
+
# BibTeX names by looking up the provided id.
|
52
|
+
def self.lookup(id)
|
53
|
+
# Calculate the canonical identifier.
|
54
|
+
canonical_id = canonical(id)
|
55
|
+
if canonical_id.nil? then
|
56
|
+
return nil
|
57
|
+
end
|
58
|
+
|
59
|
+
# Search for the DOI on CrossRef.
|
60
|
+
crossref_url = "http://search.crossref.org/dois?" +
|
61
|
+
URI.encode_www_form([["q", canonical_id]])
|
62
|
+
|
63
|
+
content = Net::HTTP.get(URI(crossref_url))
|
64
|
+
as_json = JSON.parse(content)
|
65
|
+
|
66
|
+
# No values returned? Returned nil so that the search
|
67
|
+
# can continue.
|
68
|
+
if as_json.length == 0 then
|
69
|
+
return nil
|
70
|
+
end
|
71
|
+
|
72
|
+
# Go through results and format them as BibTeX::Entry.
|
73
|
+
# We support both
|
74
|
+
results = [] unless block_given?
|
75
|
+
as_json.each do |match|
|
76
|
+
# Skip non-identical DOI matches.
|
77
|
+
next unless match['doi'].downcase == canonical_id.downcase
|
78
|
+
|
79
|
+
# Create a BibTeX entry to store these values.
|
80
|
+
bibentry = BibTeX::Entry.new
|
81
|
+
|
82
|
+
# Set identifiers so we know where this came from.
|
83
|
+
bibentry[:url] = canonical_id
|
84
|
+
bibentry[:doi] = canonical_id.match(/^http:\/\/dx\.doi\.org\/(.*)$/)[1]
|
85
|
+
|
86
|
+
# CrossRef itself provides a full citation and year.
|
87
|
+
if match.key?('fullCitation') then
|
88
|
+
bibentry[:title] = match['fullCitation']
|
89
|
+
end
|
90
|
+
|
91
|
+
if match.key?('year') then
|
92
|
+
bibentry[:year] = match['year']
|
93
|
+
end
|
94
|
+
|
95
|
+
# If we have COinS data, we have a lot more data.
|
96
|
+
if match.key?('coins') then
|
97
|
+
coins_kv = CGI::parse(match['coins'])
|
98
|
+
metadata = {}
|
99
|
+
coins_kv.each do |key, val|
|
100
|
+
if val.length == 1 then
|
101
|
+
metadata[key] = val[0]
|
102
|
+
else
|
103
|
+
metadata[key] = val
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
# COinS values are explained at http://ocoins.info/cobg.html
|
108
|
+
# Some values need to be handled separately.
|
109
|
+
|
110
|
+
# Journal title: title, jtitle
|
111
|
+
journal_title = metadata['rft.title'] # The old-style journal title.
|
112
|
+
journal_title ||= metadata['rft.stitle'] # An abbreviated title.
|
113
|
+
journal_title ||= metadata['rft.jtitle'] # Complete title.
|
114
|
+
bibentry[:journal] = journal_title
|
115
|
+
|
116
|
+
# Pages: spage, epage
|
117
|
+
pages = metadata['rft.pages'] # If only pages are provided
|
118
|
+
pages ||= metadata['rft.spage'] + "-" + metadata['rft.epage']
|
119
|
+
# If we have start and end pages
|
120
|
+
bibentry[:pages] = pages
|
121
|
+
|
122
|
+
# Authors are all in 'rft.au'
|
123
|
+
authors = BibTeX::Names.new
|
124
|
+
metadata['rft.au'].each do |author|
|
125
|
+
authors.add(BibTeX::Name.parse(author))
|
126
|
+
end
|
127
|
+
bibentry[:author] = authors
|
128
|
+
|
129
|
+
# COinS supports some types
|
130
|
+
genre = metadata['rft.genre']
|
131
|
+
if genre == 'article' then
|
132
|
+
bibentry.type = "article"
|
133
|
+
elsif genre == 'proceeding' || genre == 'conference' then
|
134
|
+
bibentry.type = "inproceeding"
|
135
|
+
end
|
136
|
+
|
137
|
+
# Map remaining fields to BibTeX.
|
138
|
+
standard_mappings = {
|
139
|
+
"rft.atitle" => "title",
|
140
|
+
"rft.date" => "date",
|
141
|
+
"rft.volume" => "volume",
|
142
|
+
"rft.issue" => "number",
|
143
|
+
"rft.artnum" => "article_number",
|
144
|
+
"rft.issn" => "issn",
|
145
|
+
"rft.eissn" => "eissn",
|
146
|
+
"rft.isbn" => "isbn",
|
147
|
+
"rft.coden" => "CODEN",
|
148
|
+
"rft.sici" => "SICI",
|
149
|
+
"rft.chron" => "chronology",
|
150
|
+
"rft.ssn" => "season",
|
151
|
+
"rft.quarter" => "quarter",
|
152
|
+
"rft.part" => "part",
|
153
|
+
}
|
154
|
+
standard_mappings.keys.each do |field|
|
155
|
+
if metadata.key?(field) then
|
156
|
+
bibentry[standard_mappings[field]] = metadata[field]
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
# Yield values or return array.
|
162
|
+
if block_given? then
|
163
|
+
yield(bibentry)
|
164
|
+
else
|
165
|
+
results.push(bibentry)
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
# If we built an array, return it.
|
170
|
+
unless block_given? then
|
171
|
+
return results
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# All lookup types implement this mixin, which
|
2
|
+
# defines the interface lookups use to talk to
|
3
|
+
# the main controller.
|
4
|
+
#
|
5
|
+
# Author:: Gaurav Vaidya
|
6
|
+
# Copyright:: Copyright (c) 2013 Gaurav Vaidya
|
7
|
+
# License:: MIT
|
8
|
+
|
9
|
+
require 'biburi'
|
10
|
+
|
11
|
+
module BibURI::Driver
|
12
|
+
# An array of drivers in order of preference. The
|
13
|
+
# first driver which supports the ID and which
|
14
|
+
# provides a valid lookup will stop processing.
|
15
|
+
@@drivers = Array.new
|
16
|
+
|
17
|
+
# Return a list of drivers.
|
18
|
+
def self.drivers
|
19
|
+
return @@drivers
|
20
|
+
end
|
21
|
+
|
22
|
+
# Returns true if this Lookup supports this id.
|
23
|
+
def self.supported?(id)
|
24
|
+
raise NotImplementedError
|
25
|
+
end
|
26
|
+
|
27
|
+
# Returns a canonical form of the identifier,
|
28
|
+
# preferably as a URL.
|
29
|
+
def self.canonical(id)
|
30
|
+
raise NotImplementedError
|
31
|
+
end
|
32
|
+
|
33
|
+
# Returns a dictionary of parsed values with
|
34
|
+
# BibTeX names by looking up the provided id.
|
35
|
+
def self.lookup(id)
|
36
|
+
raise NotImplementedError
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
# Load all the drivers, and add them to BibURI::Driver
|
42
|
+
# in order of preference.
|
43
|
+
require "biburi/driver/doi"
|
44
|
+
|
45
|
+
module BibURI::Driver
|
46
|
+
@@drivers = [
|
47
|
+
BibURI::Driver::DOI
|
48
|
+
]
|
49
|
+
end
|
50
|
+
|
data/lib/biburi.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# BibURI looks up URIs refering to citations (such as DOIs,
|
2
|
+
# Mendeley or Zotero URLs, and so on) and extracts the BibTeX
|
3
|
+
# data associated with them.
|
4
|
+
#
|
5
|
+
# Author:: Gaurav Vaidya
|
6
|
+
# Copyright:: Copyright (c) 2013 Gaurav Vaidya
|
7
|
+
|
8
|
+
require 'biburi/version'
|
9
|
+
|
10
|
+
module BibURI
|
11
|
+
# Returns a list of all drivers.
|
12
|
+
def self.drivers
|
13
|
+
return BibURI::Driver::drivers
|
14
|
+
end
|
15
|
+
|
16
|
+
# Query all the drivers in the order
|
17
|
+
# they are recorded in; return the results
|
18
|
+
# for the first driver.
|
19
|
+
def self.lookup(id)
|
20
|
+
self.drivers.each do |driver|
|
21
|
+
if driver.supported?(id) then
|
22
|
+
results = driver.lookup(id)
|
23
|
+
if !results.nil? then
|
24
|
+
return results
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
return nil
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
require 'biburi/driver'
|
data/spec/biburi_spec.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
|
3
|
+
describe BibURI do
|
4
|
+
describe "VERSION" do
|
5
|
+
it "should exist" do
|
6
|
+
version = BibURI::VERSION
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "drivers" do
|
11
|
+
it "should have multiple drivers" do
|
12
|
+
drivers = BibURI::drivers
|
13
|
+
|
14
|
+
expect(drivers).to be_an_instance_of(Array)
|
15
|
+
expect(drivers.length).to be > 0
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "lookup" do
|
20
|
+
it "should be able to do simple lookups" do
|
21
|
+
queries = {
|
22
|
+
"doi:10.1038/171737a0" => [
|
23
|
+
BibTeX::Entry.new(
|
24
|
+
:url => "http://dx.doi.org/10.1038/171737a0",
|
25
|
+
:doi => "10.1038/171737a0",
|
26
|
+
:title => "Molecular Structure of Nucleic Acids: A Structure for Deoxyribose Nucleic Acid, year = 1953, journal = Nature, pages = 737-738",
|
27
|
+
:author => "WATSON, J. D. and CRICK, F. H. C.",
|
28
|
+
:date => "1953",
|
29
|
+
:volume => "171",
|
30
|
+
:number => "4356"
|
31
|
+
)
|
32
|
+
],
|
33
|
+
"http://dx.doi.org/10.1111/j.1096-0031.2010.00329.x" => [
|
34
|
+
BibTeX::Entry.new({
|
35
|
+
"url" => "http://dx.doi.org/10.1111/j.1096-0031.2010.00329.x",
|
36
|
+
"doi" => "10.1111/j.1096-0031.2010.00329.x",
|
37
|
+
"title" => "SequenceMatrix: concatenation software for the fast assembly of multi-gene datasets with character set and codon information",
|
38
|
+
"year" => "2011",
|
39
|
+
"journal" => "Cladistics",
|
40
|
+
"pages" => "171-180",
|
41
|
+
"author" => "Vaidya, Gaurav and Lohman, David J. and Meier, Rudolf",
|
42
|
+
"date" => "2011",
|
43
|
+
"volume" => "27",
|
44
|
+
"number" => "2"
|
45
|
+
})
|
46
|
+
]
|
47
|
+
}
|
48
|
+
|
49
|
+
queries.keys.each do |query|
|
50
|
+
result = BibURI::lookup(query)
|
51
|
+
|
52
|
+
expect(result.to_s).to eq(queries[query].to_s)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe BibURI::Driver do
|
59
|
+
it "should return NotImplementedError for all methods" do
|
60
|
+
expect { BibURI::Driver::supported?("doi:10.1038/171737a0") }.to raise_error(NotImplementedError)
|
61
|
+
expect { BibURI::Driver::canonical("doi:10.1038/171737a0") }.to raise_error(NotImplementedError)
|
62
|
+
expect { BibURI::Driver::lookup("doi:10.1038/171737a0") }.to raise_error(NotImplementedError)
|
63
|
+
end
|
64
|
+
end
|
data/spec/doi_spec.rb
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
|
3
|
+
describe BibURI::Driver::DOI do
|
4
|
+
describe "supported" do
|
5
|
+
it "should support real DOIs" do
|
6
|
+
real_dois = [
|
7
|
+
"doi:10.1111/j.1529-8817.2010.00939.x",
|
8
|
+
"doi:10.1038/171737a0",
|
9
|
+
"DOI:10.1038/171737A0",
|
10
|
+
"http://dx.doi.org/doi:10.1038/171737a0"
|
11
|
+
]
|
12
|
+
|
13
|
+
real_dois.each do |doi|
|
14
|
+
expect(BibURI::Driver::DOI::supported?(doi)).to be_true;
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should not support incorrect DOIs" do
|
19
|
+
incorrect_dois = [
|
20
|
+
"10.1111/j.1529-8817.2010.00939.x",
|
21
|
+
"dxoi:10.1038/171737a0",
|
22
|
+
"https://dx.doi.org/doi:10.1038/171737a0"
|
23
|
+
]
|
24
|
+
|
25
|
+
incorrect_dois.each do |doi|
|
26
|
+
expect(BibURI::Driver::DOI::supported?(doi)).to be_false;
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "canonical" do
|
33
|
+
it "should canonicalize DOIs correctly" do
|
34
|
+
canonicalize = {
|
35
|
+
"doi:10.1038/171737a0" => "http://dx.doi.org/10.1038/171737a0",
|
36
|
+
"http://dx.doi.org/10.1038/171737a0" => "http://dx.doi.org/10.1038/171737a0"
|
37
|
+
}
|
38
|
+
|
39
|
+
canonicalize.keys.each do |value|
|
40
|
+
expected = canonicalize[value]
|
41
|
+
expect(BibURI::Driver::DOI::canonical(value)).to eq(expected)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "lookup" do
|
47
|
+
it "should be able to download information on some DOIs" do
|
48
|
+
queries = {
|
49
|
+
"doi:10.1038/171737a0" => [
|
50
|
+
BibTeX::Entry.new(
|
51
|
+
:url => "http://dx.doi.org/10.1038/171737a0",
|
52
|
+
:doi => "10.1038/171737a0",
|
53
|
+
:title => "Molecular Structure of Nucleic Acids: A Structure for Deoxyribose Nucleic Acid, year = 1953, journal = Nature, pages = 737-738",
|
54
|
+
:author => "WATSON, J. D. and CRICK, F. H. C.",
|
55
|
+
:date => "1953",
|
56
|
+
:volume => "171",
|
57
|
+
:number => "4356"
|
58
|
+
)
|
59
|
+
],
|
60
|
+
"http://dx.doi.org/10.1111/j.1096-0031.2010.00329.x" => [
|
61
|
+
BibTeX::Entry.new({
|
62
|
+
"url" => "http://dx.doi.org/10.1111/j.1096-0031.2010.00329.x",
|
63
|
+
"doi" => "10.1111/j.1096-0031.2010.00329.x",
|
64
|
+
"title" => "SequenceMatrix: concatenation software for the fast assembly of multi-gene datasets with character set and codon information",
|
65
|
+
"year" => "2011",
|
66
|
+
"journal" => "Cladistics",
|
67
|
+
"pages" => "171-180",
|
68
|
+
"author" => "Vaidya, Gaurav and Lohman, David J. and Meier, Rudolf",
|
69
|
+
"date" => "2011",
|
70
|
+
"volume" => "27",
|
71
|
+
"number" => "2"
|
72
|
+
})
|
73
|
+
]
|
74
|
+
}
|
75
|
+
|
76
|
+
queries.keys.each do |query|
|
77
|
+
result = BibURI::Driver::DOI::lookup(query)
|
78
|
+
|
79
|
+
expect(result.to_s).to eq(queries[query].to_s)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: biburi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gaurav Vaidya
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-10-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec-core
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
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
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: bibtex-ruby
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '2.0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '2.0'
|
97
|
+
description: Find the BibTeX information when your citation has an identifier
|
98
|
+
email:
|
99
|
+
- gaurav@ggvaidya.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- .gitignore
|
105
|
+
- .travis.yml
|
106
|
+
- CHANGELOG.mediawiki
|
107
|
+
- Gemfile
|
108
|
+
- LICENSE.txt
|
109
|
+
- README.md
|
110
|
+
- Rakefile
|
111
|
+
- biburi.gemspec
|
112
|
+
- lib/biburi.rb
|
113
|
+
- lib/biburi/driver.rb
|
114
|
+
- lib/biburi/driver/doi.rb
|
115
|
+
- lib/biburi/version.rb
|
116
|
+
- spec/biburi_spec.rb
|
117
|
+
- spec/doi_spec.rb
|
118
|
+
- spec/spec_helper.rb
|
119
|
+
homepage: http://github.com/gaurav/biburi
|
120
|
+
licenses:
|
121
|
+
- MIT
|
122
|
+
metadata: {}
|
123
|
+
post_install_message:
|
124
|
+
rdoc_options: []
|
125
|
+
require_paths:
|
126
|
+
- lib
|
127
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - '>='
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
requirements: []
|
138
|
+
rubyforge_project:
|
139
|
+
rubygems_version: 2.0.0
|
140
|
+
signing_key:
|
141
|
+
specification_version: 4
|
142
|
+
summary: URI to BibTeX lookup gem
|
143
|
+
test_files:
|
144
|
+
- spec/biburi_spec.rb
|
145
|
+
- spec/doi_spec.rb
|
146
|
+
- spec/spec_helper.rb
|