ref2bibtex 0.0.1 → 0.0.2
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 +4 -4
- data/lib/ref2bibtex/version.rb +1 -1
- data/lib/ref2bibtex.rb +6 -1
- data/spec/ref2bibtex_spec.rb +7 -0
- data/spec/support/citations.yml +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7a6d2f188260ac456c771d9ec65929e9ab7ec5c
|
4
|
+
data.tar.gz: d6f2310879d26fd8624abb4249d995180b25b7dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46c5683d946d88659da4f14178f53e1bd276887a4701d84e4541b40321f3d0d1faf3d3bf4b83aaba11c9ff01821a1f3ed0b8cc0b59102b3e84bd6f3adbf4113f
|
7
|
+
data.tar.gz: 899c78be357a1b5e85bdc462a7ccda12f94d9a3050f1c0758cecd36db8a16f34b62a5d77443572205da531382304674a97a94d556128b70ee2cfc914e04f9b3b
|
data/lib/ref2bibtex/version.rb
CHANGED
data/lib/ref2bibtex.rb
CHANGED
@@ -21,6 +21,7 @@ module Ref2bibtex
|
|
21
21
|
|
22
22
|
# Pass a String doi get a bibtex formatted string back
|
23
23
|
def self.get_bibtex(doi)
|
24
|
+
return false if !doi
|
24
25
|
response = Ref2bibtex.request(URI(doi), headers: {'Accept' => 'application/x-bibtex' }, protocol: 'GET', process_response_as: 'text')
|
25
26
|
end
|
26
27
|
|
@@ -33,7 +34,11 @@ module Ref2bibtex
|
|
33
34
|
end
|
34
35
|
|
35
36
|
response = Ref2bibtex.request(payload: citation)
|
36
|
-
response['results']
|
37
|
+
if response['results'][0]['match']
|
38
|
+
response['results'].first['doi']
|
39
|
+
else
|
40
|
+
false
|
41
|
+
end
|
37
42
|
end
|
38
43
|
|
39
44
|
# Pass a citation, get a String in bibtex back
|
data/spec/ref2bibtex_spec.rb
CHANGED
@@ -30,6 +30,10 @@ describe Ref2bibtex do
|
|
30
30
|
specify 'Ref2bibtex.get_doi() takes a full citation and returns a string' do
|
31
31
|
expect(Ref2bibtex.get_doi(CITATIONS[:first])).to eq('http://dx.doi.org/10.3897/zookeys.20.205')
|
32
32
|
end
|
33
|
+
|
34
|
+
specify 'a citation that can not be resolved returns false' do
|
35
|
+
expect(Ref2bibtex.get_doi(CITATIONS[:fifth])).to eq(false)
|
36
|
+
end
|
33
37
|
end
|
34
38
|
|
35
39
|
context '#get_bibtex' do
|
@@ -41,5 +45,8 @@ describe Ref2bibtex do
|
|
41
45
|
end
|
42
46
|
end
|
43
47
|
|
48
|
+
specify "a citation that can not be resolved returns false" do
|
49
|
+
expect(Ref2bibtex.get(CITATIONS[:fifth])).to eq(false)
|
50
|
+
end
|
44
51
|
|
45
52
|
end
|
data/spec/support/citations.yml
CHANGED
@@ -7,3 +7,5 @@
|
|
7
7
|
'Collins, N., van den Berghe & Carson. 2014. Two new species of Neoxabea, three new species of Oecanthus, and documentation of two other species in Nicaragua (Orthoptera: Gryllidae: Oecanthinae). Transactions of the American Entomological Society (Trans. Amer. Entomol. Soc.) 140:170'
|
8
8
|
:fourth:
|
9
9
|
"Otte, D. 1994. Crickets (Grylloidea). Orthoptera Species File, The Orthopterists' Society and The Academy of Natural Sciences of Philadelphia, Philadelphia 1:87"
|
10
|
+
:fifth:
|
11
|
+
"Defaut. 2006. Révision préliminaire des Oedipoda ouest-paléarctiques (Caelifera, Acrididae, Oedipodinae). Matériaux Orthoptériques et Entomocénotiques 11:23-48"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ref2bibtex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Yoder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|