identifiers 0.7.0 → 0.8.0
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/CHANGELOG.md +5 -0
- data/README.md +1 -1
- data/lib/identifiers/isbn.rb +2 -2
- data/spec/identifiers/isbn_spec.rb +16 -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: 1d323ecfde9659ed9a795b2b2519450d33ec77c6
|
4
|
+
data.tar.gz: 391573ad4170738967c32597eee590554f47d59a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b50b32b55b82b97b3d07bc6613c064ffadf59c760f51ba9b26b1e200c4efe883747bb47b89e889597da2f56e426138412acb21797eddc9da699f94829d65bf17
|
7
|
+
data.tar.gz: 509003d4b24d3cde4b350b5198384d42c5232ac3417007bdc9a8823e07f1551a61ba6c08553fea19f731dd319723d9c7c590d003d31152b5389aa9cb356587b7
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
All notable changes to this project will be documented in this file. This
|
3
3
|
project adheres to [Semantic Versioning](http://semver.org/).
|
4
4
|
|
5
|
+
## [0.8.0] - 2017-04-10
|
6
|
+
### Added
|
7
|
+
- Added support for ISBNs with digits separated by Unicode whitespace and dashes
|
8
|
+
|
5
9
|
## [0.7.0] - 2017-04-10
|
6
10
|
### Added
|
7
11
|
- Added support for cleaning trailing punctuation from DOIs that also end in punctuation
|
@@ -42,3 +46,4 @@ project adheres to [Semantic Versioning](http://semver.org/).
|
|
42
46
|
[0.5.0]: https://github.com/altmetric/identifiers/releases/tag/v0.5.0
|
43
47
|
[0.6.0]: https://github.com/altmetric/identifiers/releases/tag/v0.6.0
|
44
48
|
[0.7.0]: https://github.com/altmetric/identifiers/releases/tag/v0.7.0
|
49
|
+
[0.8.0]: https://github.com/altmetric/identifiers/releases/tag/v0.8.0
|
data/README.md
CHANGED
data/lib/identifiers/isbn.rb
CHANGED
@@ -13,11 +13,11 @@ module Identifiers
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.extract_thirteen_digit_isbns(str)
|
16
|
-
str.gsub(/(?<=\d)[
|
16
|
+
str.gsub(/(?<=\d)[\p{Pd}\p{Zs}](?=\d)/, '').scan(REGEX_13).select { |isbn| valid_isbn_13?(isbn) }
|
17
17
|
end
|
18
18
|
|
19
19
|
def self.extract_ten_digit_isbns(str)
|
20
|
-
str.gsub(/(?<=\d)[
|
20
|
+
str.gsub(/(?<=\d)[\p{Pd}\p{Zs}](?=[\dX])/i, '').scan(REGEX_10).select { |isbn| valid_isbn_10?(isbn) }.map { |isbn|
|
21
21
|
isbn.chop!
|
22
22
|
isbn.prepend('978')
|
23
23
|
isbn << isbn_13_check_digit(isbn).to_s
|
@@ -15,10 +15,18 @@ RSpec.describe Identifiers::ISBN do
|
|
15
15
|
expect(described_class.extract('ISBN: 978-0-80-506909-9')).to contain_exactly('9780805069099')
|
16
16
|
end
|
17
17
|
|
18
|
+
it 'extracts ISBNs with Unicode dashes' do
|
19
|
+
expect(described_class.extract('ISBN: 978–0–80–506909–9')).to contain_exactly('9780805069099')
|
20
|
+
end
|
21
|
+
|
18
22
|
it 'extracts ISBNs with spaces' do
|
19
23
|
expect(described_class.extract('ISBN: 978 0 80 506909 9')).to contain_exactly('9780805069099')
|
20
24
|
end
|
21
25
|
|
26
|
+
it 'extracts ISBNs with Unicode spaces' do
|
27
|
+
expect(described_class.extract('ISBN: 978 0 80 506909 9')).to contain_exactly('9780805069099')
|
28
|
+
end
|
29
|
+
|
22
30
|
it 'extracts ISBN-13s from ISBN-As' do
|
23
31
|
expect(described_class.extract('10.978.8898392/315')).to contain_exactly('9788898392315')
|
24
32
|
end
|
@@ -33,6 +41,10 @@ RSpec.describe Identifiers::ISBN do
|
|
33
41
|
expect(described_class.extract(str)).to contain_exactly('9780805069099', '9782759402694')
|
34
42
|
end
|
35
43
|
|
44
|
+
it 'normalizes 10-digit ISBNs with Unicode dashes' do
|
45
|
+
expect(described_class.extract('0–8050–6909–7')).to contain_exactly('9780805069099')
|
46
|
+
end
|
47
|
+
|
36
48
|
it 'normalizes 10-digit ISBNs with a check digit of 10' do
|
37
49
|
expect(described_class.extract('4423272350')).to contain_exactly('9784423272350')
|
38
50
|
end
|
@@ -41,6 +53,10 @@ RSpec.describe Identifiers::ISBN do
|
|
41
53
|
expect(described_class.extract('0 8050 6909 7')).to contain_exactly('9780805069099')
|
42
54
|
end
|
43
55
|
|
56
|
+
it 'normalizes 10-digit ISBNs with Unicode spaces' do
|
57
|
+
expect(described_class.extract('0 8050 6909 7')).to contain_exactly('9780805069099')
|
58
|
+
end
|
59
|
+
|
44
60
|
it 'normalizes 10-digit ISBNs with spaces and a check digit of X' do
|
45
61
|
expect(described_class.extract('2 7594 0269 X')).to contain_exactly('9782759402694')
|
46
62
|
end
|