pubid-iso 0.1.5 → 0.1.6

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
  SHA256:
3
- metadata.gz: d0daa77a77b864f2c4799226d5a5d458a3a852ba5321bf243f5415082ca66d52
4
- data.tar.gz: 2efd25c20e35d80cd14a2f286e435eab2d017a295b08fb16f7c05ff079fe8986
3
+ metadata.gz: d3db426781c12fb80bbd99118bc9b601fe93473d0c9b395f88929ac8eb3b996d
4
+ data.tar.gz: 7e2c155d3397e1ac4888258c680357b204edb8252a3e03fa8d336292be85ccbb
5
5
  SHA512:
6
- metadata.gz: e740022023d24557f1650de284b22411176ac4fb09d6ecac8bb8c3a69a328dcaeeb79aadc0c3a5644840fadd1167699a010039dbedd5f5412f82387a7566c88c
7
- data.tar.gz: 3d7437f44ed7e4fc6496b315d30940ea79bb3e4e275ea1bb1f973fe2a7927c339ec57758a90494a27afcba71c266dae4bf1d9cd61a7002a4e9bdb515e9ca6a49
6
+ metadata.gz: 765bdaef471049f21f15ba5cf9f45bbb42edfe88baf53ee5f67d155fdba6f0b8ef8a1b8cf212a9f6d3d35ce289946c6c5281efd94e913d59274b9ea1a7143e8c
7
+ data.tar.gz: 628307f60259f11b97476d893861b73f1042104c940958ee695acc24069033e4689b0bfe490a641a6c7d557a5f8635ec6cf2140bed56d594910c8e2c46670d6f
@@ -27,6 +27,15 @@ module Pubid::Iso
27
27
  Urn.new(**get_params)
28
28
  end
29
29
 
30
+ def self.parse_from_title(title)
31
+ title.split.reverse.inject(title) do |acc, part|
32
+ return parse(acc)
33
+ rescue Pubid::Iso::Errors::ParseError
34
+ # delete parts from the title until it's parseable
35
+ acc.reverse.sub(part.reverse, "").reverse.strip
36
+ end
37
+ end
38
+
30
39
  def self.parse(code_or_params)
31
40
  params = code_or_params.is_a?(String) ? Parser.new.parse(code_or_params) : code_or_params
32
41
  # Parslet returns an array when match any copublisher
@@ -1,5 +1,5 @@
1
1
  module Pubid
2
2
  module Iso
3
- VERSION = "0.1.5".freeze
3
+ VERSION = "0.1.6".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pubid-iso
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-05-26 00:00:00.000000000 Z
11
+ date: 2022-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake