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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d5c6a569245a2c9931eb0fd3a4f4e5e234254c6d
4
- data.tar.gz: 41d5ea41e4fbf1bc967d27f671e3777991907d3a
3
+ metadata.gz: 1d323ecfde9659ed9a795b2b2519450d33ec77c6
4
+ data.tar.gz: 391573ad4170738967c32597eee590554f47d59a
5
5
  SHA512:
6
- metadata.gz: 08707a69b6d6143e13db5f8b3a4d8e58f54089fd37a7382296898ce4f5ac6b6dcb8ccd7a99535009074ce679d47f85fe0c51737cfb7f3b019b39b3855e000716
7
- data.tar.gz: 03d64f650ebe7e4c411ad77c98d83c1a58be7eb3a034183d158cd615584a4d7fd5beb2a7197cdf39ee64450cc9e09c06162f526bef7238b92c811e6704e2dffd
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
@@ -18,7 +18,7 @@ Collection of utilities related to the extraction, validation and normalization
18
18
  Add this line to your application's `Gemfile`:
19
19
 
20
20
  ```ruby
21
- gem 'identifiers', '~> 0.7'
21
+ gem 'identifiers', '~> 0.8'
22
22
  ```
23
23
 
24
24
  And then execute:
@@ -13,11 +13,11 @@ module Identifiers
13
13
  end
14
14
 
15
15
  def self.extract_thirteen_digit_isbns(str)
16
- str.gsub(/(?<=\d)[- ](?=\d)/, '').scan(REGEX_13).select { |isbn| valid_isbn_13?(isbn) }
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)[- ](?=[\dX])/i, '').scan(REGEX_10).select { |isbn| valid_isbn_10?(isbn) }.map { |isbn|
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: identifiers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Hernandez