cirneco 0.9.14 → 0.9.15
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/Gemfile.lock +2 -2
- data/lib/cirneco/utils.rb +5 -2
- data/lib/cirneco/version.rb +1 -1
- data/spec/fixtures/cool-dois.html.md +1 -1
- data/spec/utils_spec.rb +11 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85c9f4ddb0364ea1d4a8135eb041b34751100ef8
|
4
|
+
data.tar.gz: fd5d0569d6592f8c3f0dd56a450d9db3066634aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 598c9c2ef3815d6d35cc7a5d6fdc738cf568abd27d456b778db615732220cbe933cd1b4d8a282201524592b8346f46516f243c84e2cbe809c9ab902c78301e0e
|
7
|
+
data.tar.gz: bc9a3797516b6f4b5f647adb19222371776975e84be7b0202cdb8c8e3500d3f7c6123411f03712e617a9c9e7ba7c169f0016dfecf261cc18bf776fd785a84b0d
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cirneco (0.9.
|
4
|
+
cirneco (0.9.15)
|
5
5
|
activesupport (>= 4.2.5, < 6)
|
6
6
|
base32-crockford-checksum (~> 0.2.2)
|
7
7
|
bergamasco (~> 0.3)
|
@@ -36,7 +36,7 @@ GEM
|
|
36
36
|
safe_yaml (~> 1.0, >= 1.0.4)
|
37
37
|
bibtex-ruby (4.4.4)
|
38
38
|
latex-decode (~> 0.0)
|
39
|
-
bolognese (0.9.
|
39
|
+
bolognese (0.9.36)
|
40
40
|
activesupport (>= 4.2.5, < 6)
|
41
41
|
benchmark_methods (~> 0.7)
|
42
42
|
bibtex-ruby (~> 4.1)
|
data/lib/cirneco/utils.rb
CHANGED
@@ -20,16 +20,19 @@ module Cirneco
|
|
20
20
|
|
21
21
|
def decode_doi(doi)
|
22
22
|
prefix, string = doi.split('/', 2)
|
23
|
-
Base32::Crockford.decode(string, checksum: true).to_i
|
23
|
+
Base32::Crockford.decode(string.upcase, checksum: true).to_i
|
24
24
|
end
|
25
25
|
|
26
26
|
def encode_doi(prefix, options={})
|
27
|
+
prefix = validate_prefix(prefix)
|
28
|
+
return nil unless prefix.present?
|
29
|
+
|
27
30
|
number = options[:number].to_s.scan(/\d+/).first.to_i
|
28
31
|
number = SecureRandom.random_number(UPPER_LIMIT) unless number > 0
|
29
32
|
shoulder = options[:shoulder].to_s
|
30
33
|
|
31
34
|
length = shoulder.length > 0 ? 6 : 8
|
32
|
-
split = shoulder.length > 0 ? nil: 4
|
35
|
+
split = shoulder.length > 0 ? nil : 4
|
33
36
|
prefix.to_s + "/" + shoulder + Base32::Crockford.encode(number, split: split, length: length, checksum: true).downcase
|
34
37
|
end
|
35
38
|
|
data/lib/cirneco/version.rb
CHANGED
@@ -8,8 +8,8 @@ tags:
|
|
8
8
|
accession_number: MS-123
|
9
9
|
image: https://blog.datacite.org/images/2016/12/cool-dois.png
|
10
10
|
published: false
|
11
|
-
doi: 10.5438/0000-03vc
|
12
11
|
date: '2016-12-15'
|
12
|
+
doi: 10.5438/0000-03vc
|
13
13
|
---
|
14
14
|
In 1998 Tim Berners-Lee coined the term cool URIs [-@https://www.w3.org/Provider/Style/URI], that is URIs that don’t change. We know that URLs referenced in the scholarly literature are often not cool, leading to link rot [@https://doi.org/10.1371/journal.pone.0115253] and making it hard or impossible to find the referenced resource.READMORE
|
15
15
|
|
data/spec/utils_spec.rb
CHANGED
@@ -50,11 +50,22 @@ describe Cirneco::DataCenter, vcr: true, :order => :defined do
|
|
50
50
|
expect(subject.encode_doi(prefix)).to start_with("10.5438")
|
51
51
|
end
|
52
52
|
|
53
|
+
it 'should not encode invalid prefix' do
|
54
|
+
prefix = "20.5438"
|
55
|
+
expect(subject.encode_doi(prefix)).to be_nil
|
56
|
+
end
|
57
|
+
|
53
58
|
it 'should encode doi with shoulder' do
|
54
59
|
number = 7654321
|
55
60
|
shoulder = "dryad."
|
56
61
|
expect(subject.encode_doi(prefix, number: number, shoulder: shoulder)).to eq("10.5438/dryad.79jxhm")
|
57
62
|
end
|
63
|
+
|
64
|
+
it 'should encode doi with empty shoulder' do
|
65
|
+
number = 7654321
|
66
|
+
shoulder = nil
|
67
|
+
expect(subject.encode_doi(prefix, number: number, shoulder: shoulder)).to eq("10.5438/0079-jxhm")
|
68
|
+
end
|
58
69
|
end
|
59
70
|
|
60
71
|
context "accession_number" do
|