pubid-core 1.12.4 → 1.12.6

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
  SHA256:
3
- metadata.gz: 2905a611f0bd23030009f14b8f3c9cbe7e24efbf3fdb9c2536fb895526a60706
4
- data.tar.gz: 12380f2b1a7a2875909ac7c82e78eea20901fbe6c602819dc3054d85d31e754e
3
+ metadata.gz: e669a025185a33a0de2de0011d98e82646db6c6b38a05be0cfca6361c860a868
4
+ data.tar.gz: 7a73c303c959f8bc8c0fc2ebc3146804f68ac4a821b40921a6498e30a52defb7
5
5
  SHA512:
6
- metadata.gz: f5d25ff122a185577e2066ac58146f3b0e00059a41137100aafc6c57e412b5706dcf3b0fc1c4d86e53b413edc3933d2e0e50051b91a3d4ec7864e73116cd9316
7
- data.tar.gz: 909377bfbd364f597ac87b7bb2e95111c453942e51d533ddb147d040298d59035d7c4fd227e5bc402d1b214e6384358ae1a1760104a96d7d9a0844bba30d24ec
6
+ metadata.gz: 17a75594c20895b3c69c2e4b240b2aabc5866df8ce580874575ae3b11c370307d6a06cc6e701e16730b060f2d402c19e112dea47dbc04fc66b91f9bdf3d53149
7
+ data.tar.gz: 86ee39d91c73705fa32be75453e9d33b62674319f8b56833d8f433697f8407b8684e5fd168dbbfad65d553e78bb1a295e1eca705aade15b0bce6683736faa30a
@@ -1,14 +1,23 @@
1
1
  module Pubid::Core
2
2
  class Configuration
3
- attr_accessor :stages, :default_type, :type_class, :types, :type_names, :stage_class, :typed_stage_class
3
+ attr_accessor :stages, :default_type, :type_class, :types, :type_names,
4
+ :stage_class, :typed_stage_class, :prefixes, :identifier_module
4
5
 
5
6
  def initialize
7
+ @identifier_module = identifier_module
6
8
  @type_class = Pubid::Core::Type
7
9
  @stage_class = Pubid::Core::Stage
8
10
  @typed_stage_class = Pubid::Core::TypedStage
9
11
  @types = []
10
12
  end
11
13
 
14
+ def prefixes
15
+ # return default prefix using module name e.g.
16
+ # "ISO" for Pubid::Iso::Identifier
17
+ # "CORE" for Pubid::Core::TestIdentifier
18
+ @prefixes || [@identifier_module.to_s.split("::")[1].upcase]
19
+ end
20
+
12
21
  def typed_stages
13
22
  types.inject({}) do |res, type|
14
23
  res.merge(type::TYPED_STAGES)
@@ -80,7 +80,7 @@ module Pubid::Core
80
80
  result[:type] = type[:short]
81
81
  end
82
82
 
83
- result
83
+ result.reject { |k, v| k != :number && v.nil? }
84
84
  end
85
85
 
86
86
  def ==(other)
@@ -36,6 +36,7 @@ module Pubid::Core
36
36
  # Parse identifier from title
37
37
  def set_config(config)
38
38
  @config = config
39
+ @config.identifier_module = self
39
40
  end
40
41
 
41
42
  def build_stage(**args)
@@ -61,5 +62,11 @@ module Pubid::Core
61
62
  def build_typed_stage(**args)
62
63
  @config.typed_stage_class.new(config: @config, **args)
63
64
  end
65
+
66
+ def parseable?(pubid)
67
+ @config.prefixes.any? do |prefix|
68
+ pubid.start_with?(prefix)
69
+ end
70
+ end
64
71
  end
65
72
  end
@@ -1,5 +1,5 @@
1
1
  module Pubid
2
2
  module Core
3
- VERSION = "1.12.4".freeze
3
+ VERSION = "1.12.6".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pubid-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.12.4
4
+ version: 1.12.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: 2024-02-03 00:00:00.000000000 Z
11
+ date: 2024-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -101,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
101
  - !ruby/object:Gem::Version
102
102
  version: '0'
103
103
  requirements: []
104
- rubygems_version: 3.3.26
104
+ rubygems_version: 3.3.27
105
105
  signing_key:
106
106
  specification_version: 4
107
107
  summary: Library to generate, parse and manipulate PubID.