identifiers 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 19a6b42db016b656d1c1114ae8e0dee77c69f5e1
4
- data.tar.gz: a954deca478c665226f8073cc9837a4c64ad2e88
3
+ metadata.gz: 94c2604feed758edf36b8f8f50a2b1538a8c35bc
4
+ data.tar.gz: 986267a6b22a62017d96f08ebf4dbb02a988c9f0
5
5
  SHA512:
6
- metadata.gz: 22c9cc78407e5561a3122a766368278eb0258cc71d61e715411fd6c9a2224a573c5818d782fe2167d79b4aad367dfa310b062d497d5b529e4fd3bf801e4ffccd
7
- data.tar.gz: 80b229ac1c454db783a6b200d2ca225c603aaa5d5adb9a5009b31752c7358f9442d164e430c2f400bdcdbaa8c79e60f1582ee4a95615b18110307814f751d0ec
6
+ metadata.gz: 88eba550c8d0b5845a8313287bbbc2c17b6641a4eeb43d3b300f1e9fe7e62edc5fcb688306b2def0a6b31e6d42cc655a83f3f5b21df632ac3997818303cf6ccd
7
+ data.tar.gz: 2be54f4d562fe47cae613626cc6e4637f08761cfd36430657e94de5667251255dd1e46d14d0062b99cd6227c4874dc1d622e2d8fe2df55c79eb5103e8783bda8
@@ -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 [![Build Status](https://travis-ci.org/altmetric/identifiers.svg?branch=master)](https://travis-ci.org/altmetric/identifiers)
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/identifiers.svg)](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)
@@ -22,7 +22,14 @@ module Identifiers
22
22
  end
23
23
 
24
24
  def self.isbn_13_check_digit(isbn)
25
- 10 - isbn.each_char.zip([1, 3].cycle).reduce(0) { |sum, values| sum + (Integer(values[0]) * values[1]) } % 10
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.0
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-11-03 00:00:00.000000000 Z
12
+ date: 2016-12-06 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: urn