identifiers 0.3.0 → 0.3.1
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 +4 -0
- data/README.md +3 -1
- data/lib/identifiers/isbn.rb +8 -1
- data/spec/identifiers/isbn_spec.rb +5 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94c2604feed758edf36b8f8f50a2b1538a8c35bc
|
4
|
+
data.tar.gz: 986267a6b22a62017d96f08ebf4dbb02a988c9f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88eba550c8d0b5845a8313287bbbc2c17b6641a4eeb43d3b300f1e9fe7e62edc5fcb688306b2def0a6b31e6d42cc655a83f3f5b21df632ac3997818303cf6ccd
|
7
|
+
data.tar.gz: 2be54f4d562fe47cae613626cc6e4637f08761cfd36430657e94de5667251255dd1e46d14d0062b99cd6227c4874dc1d622e2d8fe2df55c79eb5103e8783bda8
|
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.3.1] - 2016-12-06
|
6
|
+
### Fixed
|
7
|
+
- Fix ISBN-10 to 13 conversion when check digit is 10
|
8
|
+
|
5
9
|
## [0.3.0] - 2016-11-03
|
6
10
|
### Added
|
7
11
|
- Support for ORCID
|
data/README.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
# Identifiers
|
1
|
+
# Identifiers [](https://travis-ci.org/altmetric/identifiers)
|
2
|
+
|
3
|
+
[](https://badge.fury.io/rb/identifiers)
|
2
4
|
|
3
5
|
Collection of utilities related to the extraction, validation and normalization of various scholarly identifiers. The supported list is:
|
4
6
|
- [ADS Bibcodes](http://adsdoc.harvard.edu/abs_doc/help_pages/bibcodes.html)
|
data/lib/identifiers/isbn.rb
CHANGED
@@ -22,7 +22,14 @@ module Identifiers
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def self.isbn_13_check_digit(isbn)
|
25
|
-
|
25
|
+
sum = isbn.each_char.zip([1, 3].cycle).reduce(0) { |sum, values| sum + (Integer(values[0]) * values[1]) }
|
26
|
+
check_digit = 10 - (sum % 10)
|
27
|
+
|
28
|
+
if check_digit == 10
|
29
|
+
0
|
30
|
+
else
|
31
|
+
check_digit
|
32
|
+
end
|
26
33
|
end
|
27
34
|
|
28
35
|
def self.valid_isbn_13?(isbn)
|
@@ -13,9 +13,14 @@ RSpec.describe Identifiers::ISBN do
|
|
13
13
|
|
14
14
|
it 'normalizes 10-digit ISBNs' do
|
15
15
|
str = "0-8050-6909-7 \n 2-7594-0269-X"
|
16
|
+
|
16
17
|
expect(described_class.extract(str)).to contain_exactly('9780805069099', '9782759402694')
|
17
18
|
end
|
18
19
|
|
20
|
+
it 'normalizes 10-digit ISBNs with a check digit of 10' do
|
21
|
+
expect(described_class.extract('4423272350')).to contain_exactly('9784423272350')
|
22
|
+
end
|
23
|
+
|
19
24
|
it 'does not extract invalid 13-digit ISBNs' do
|
20
25
|
expect(described_class.extract('9783319217280')).to be_empty
|
21
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: identifiers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Hernandez
|
8
|
+
- Paul Mucur
|
8
9
|
autorequire:
|
9
10
|
bindir: exe
|
10
11
|
cert_chain: []
|
11
|
-
date: 2016-
|
12
|
+
date: 2016-12-06 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: urn
|