identifiers 0.3.1 → 0.4.0

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: 94c2604feed758edf36b8f8f50a2b1538a8c35bc
4
- data.tar.gz: 986267a6b22a62017d96f08ebf4dbb02a988c9f0
3
+ metadata.gz: ab0f2da0f90f2dda268319d5be99dc314bd9b9fe
4
+ data.tar.gz: 443f4aead25198aa6d267fa9c67a3800739f837c
5
5
  SHA512:
6
- metadata.gz: 88eba550c8d0b5845a8313287bbbc2c17b6641a4eeb43d3b300f1e9fe7e62edc5fcb688306b2def0a6b31e6d42cc655a83f3f5b21df632ac3997818303cf6ccd
7
- data.tar.gz: 2be54f4d562fe47cae613626cc6e4637f08761cfd36430657e94de5667251255dd1e46d14d0062b99cd6227c4874dc1d622e2d8fe2df55c79eb5103e8783bda8
6
+ metadata.gz: 51dc9476b30151bda26a037ae4dba6e25d59feef23af27bbc7d9ca7ab497221ef4117194a9524a4ba552cf708061bcc80b80b4404735abc08f4bbd38b615f3ad
7
+ data.tar.gz: 088d481f41064ec32560dea76c25a0ddfdb3f731937bda7c0a0d32b2c2dd3e1d44e96f5e6eea2b4410a7fcb57c47779ca0adb68b5b41806256ef21504bc840d7
@@ -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.4.0] - 2017-01-23
6
+ ### Changed
7
+ - Extract ISBNs separated by spaces as well as hyphens
8
+
5
9
  ## [0.3.1] - 2016-12-06
6
10
  ### Fixed
7
11
  - Fix ISBN-10 to 13 conversion when check digit is 10
@@ -17,3 +21,9 @@ project adheres to [Semantic Versioning](http://semver.org/).
17
21
  ## [0.1.0] - 2016-10-21
18
22
  ### Added
19
23
  - Initial release
24
+
25
+ [0.1.0]: https://github.com/altmetric/identifiers/releases/tag/v0.1.0
26
+ [0.2.0]: https://github.com/altmetric/identifiers/releases/tag/v0.2.0
27
+ [0.3.0]: https://github.com/altmetric/identifiers/releases/tag/v0.2.0
28
+ [0.3.1]: https://github.com/altmetric/identifiers/releases/tag/v0.3.1
29
+ [0.4.0]: https://github.com/altmetric/identifiers/releases/tag/v0.4.0
data/README.md CHANGED
@@ -1,25 +1,24 @@
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)
1
+ # Identifiers [![Build Status](https://travis-ci.org/altmetric/identifiers.svg?branch=master)](https://travis-ci.org/altmetric/identifiers) [![Gem Version](https://badge.fury.io/rb/identifiers.svg)](https://badge.fury.io/rb/identifiers)
4
2
 
5
3
  Collection of utilities related to the extraction, validation and normalization of various scholarly identifiers. The supported list is:
4
+
6
5
  - [ADS Bibcodes](http://adsdoc.harvard.edu/abs_doc/help_pages/bibcodes.html)
7
- - [arXiv](https://arxiv.org/help/arxiv_identifier)
8
- - [DOI](https://www.doi.org/)
9
- - [Handle](https://en.wikipedia.org/wiki/Handle_System)
10
- - [ISBN](https://en.wikipedia.org/wiki/International_Standard_Book_Number)
11
- - [National Clinic Trials](https://clinicaltrials.gov/)
12
- - [PubMed](http://www.ncbi.nlm.nih.gov/pubmed)
13
- - [RePEc](https://en.wikipedia.org/wiki/Research_Papers_in_Economics)
14
- - [URN](https://en.wikipedia.org/wiki/Uniform_Resource_Name)
15
- - [ORCID](http://orcid.org/)
6
+ - [arXiv IDs](https://arxiv.org/help/arxiv_identifier)
7
+ - [DOIs](https://www.doi.org/)
8
+ - [Handles](https://en.wikipedia.org/wiki/Handle_System)
9
+ - [ISBNs](https://en.wikipedia.org/wiki/International_Standard_Book_Number)
10
+ - [National Clinical Trial IDs](https://clinicaltrials.gov/)
11
+ - [PubMed IDs](http://www.ncbi.nlm.nih.gov/pubmed)
12
+ - [RePEc IDs](https://en.wikipedia.org/wiki/Research_Papers_in_Economics)
13
+ - [URNs](https://en.wikipedia.org/wiki/Uniform_Resource_Name)
14
+ - [ORCID identifiers](http://orcid.org/)
16
15
 
17
16
  ## Installation
18
17
 
19
- Add this line to your application's Gemfile:
18
+ Add this line to your application's `Gemfile`:
20
19
 
21
20
  ```ruby
22
- gem 'identifiers', '~> 0.3'
21
+ gem 'identifiers', '~> 0.4'
23
22
  ```
24
23
 
25
24
  And then execute:
@@ -34,9 +33,15 @@ Or install it yourself as:
34
33
 
35
34
  ```ruby
36
35
  Identifiers::DOI.extract('example: 10.123/abcd.efghi')
36
+ # => ["10.123/abcd.efghi"]
37
+
38
+ Identifiers::DOI.extract('no DOIs here')
39
+ # => []
37
40
 
38
41
  Identifiers::URN.new('urn:abc:123')
42
+ # => #<URN:0x007ff11c13d930 @urn="urn:abc:123", @nid="abc", @nss="123">
39
43
  Identifiers::URN('urn:abc:123')
44
+ # => #<URN:0x007ff11c0ff568 @urn="urn:abc:123", @nid="abc", @nss="123">
40
45
  ```
41
46
 
42
47
  ## By identifier
@@ -56,7 +61,7 @@ Identifiers::RepecId.extract('')
56
61
  Identifiers::URN.extract('')
57
62
  ```
58
63
 
59
- But for some identifiers might have more. Check their implementation to see all the methods available.
64
+ But for some identifiers might have more. Check [their implementation](https://github.com/altmetric/identifiers/tree/master/lib/identifiers) to see all the methods available.
60
65
 
61
66
  For `URN`s, please check the [URN gem documentation](https://github.com/altmetric/urn) to see all the available options.
62
67
 
@@ -64,6 +69,10 @@ For `URN`s, please check the [URN gem documentation](https://github.com/altmetri
64
69
 
65
70
  Bug reports and pull requests are welcome on GitHub at https://github.com/altmetric/identifiers.
66
71
 
72
+ ## PHP version
73
+
74
+ We also maintain [a version of this library for PHP](https://github.com/altmetric/php-identifiers).
75
+
67
76
  ## License
68
77
 
69
78
  Copyright © 2016 Altmetric LLP
@@ -8,11 +8,11 @@ module Identifiers
8
8
  end
9
9
 
10
10
  def self.extract_thirteen_digit_isbns(str)
11
- str.tr('-', '').scan(REGEX_13).select { |isbn| valid_isbn_13?(isbn) }
11
+ str.gsub(/(?<=\d)[- ](?=\d)/, '').scan(REGEX_13).select { |isbn| valid_isbn_13?(isbn) }
12
12
  end
13
13
 
14
14
  def self.extract_ten_digit_isbns(str)
15
- str.tr('-', '').scan(REGEX_10).select { |isbn| valid_isbn_10?(isbn) }.map { |isbn|
15
+ str.gsub(/(?<=\d)[- ](?=[\dX])/i, '').scan(REGEX_10).select { |isbn| valid_isbn_10?(isbn) }.map { |isbn|
16
16
  isbn.chop!
17
17
  isbn.prepend('978')
18
18
  isbn << isbn_13_check_digit(isbn).to_s
@@ -1,3 +1,4 @@
1
+ # Documentation at https://github.com/altmetric/urn
1
2
  require 'urn'
2
3
 
3
4
  module Identifiers
@@ -11,6 +11,14 @@ RSpec.describe Identifiers::ISBN do
11
11
  expect(described_class.extract(str)).to contain_exactly('9780805069099', '9780671879198')
12
12
  end
13
13
 
14
+ it 'extracts ISBNs with hyphens' do
15
+ expect(described_class.extract('ISBN: 978-0-80-506909-9')).to contain_exactly('9780805069099')
16
+ end
17
+
18
+ it 'extracts ISBNs with spaces' do
19
+ expect(described_class.extract('ISBN: 978 0 80 506909 9')).to contain_exactly('9780805069099')
20
+ end
21
+
14
22
  it 'normalizes 10-digit ISBNs' do
15
23
  str = "0-8050-6909-7 \n 2-7594-0269-X"
16
24
 
@@ -21,6 +29,14 @@ RSpec.describe Identifiers::ISBN do
21
29
  expect(described_class.extract('4423272350')).to contain_exactly('9784423272350')
22
30
  end
23
31
 
32
+ it 'normalizes 10-digit ISBNs with spaces' do
33
+ expect(described_class.extract('0 8050 6909 7')).to contain_exactly('9780805069099')
34
+ end
35
+
36
+ it 'normalizes 10-digit ISBNs with spaces and a check digit of X' do
37
+ expect(described_class.extract('2 7594 0269 X')).to contain_exactly('9782759402694')
38
+ end
39
+
24
40
  it 'does not extract invalid 13-digit ISBNs' do
25
41
  expect(described_class.extract('9783319217280')).to be_empty
26
42
  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.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Hernandez
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2016-12-06 00:00:00.000000000 Z
12
+ date: 2017-01-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: urn