pubid-core 1.5.1 → 1.5.2
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 +4 -4
- data/lib/pubid/core/identifier.rb +12 -0
- data/lib/pubid/core/type.rb +39 -0
- data/lib/pubid/core/version.rb +1 -1
- data/lib/pubid/core.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d11f67c2e955fc7a68dffe340770552b3148b1767bd3095600c35ec9696e239c
|
4
|
+
data.tar.gz: f1db402f0c58b0340ea34da7b129021be3985aed9e6573d462645240717062b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 330a2e07981ef86fa2c26ac46636d91c8737fb6a0a11e84e2b91fc15f9c7b2eee98f3d6f0792534f924cbb343d80df634febfabc4325c87f5eede56481d10d2c
|
7
|
+
data.tar.gz: e6b481d0431d82220983541c2f7162d087bc38894d9b8c8d7c6758b02adc87009a4b195ee639626af6a436ad833f6c4441b38d8c41553ff882b1c0405540f029
|
@@ -107,6 +107,18 @@ module Pubid::Core
|
|
107
107
|
new(**identifier_params)
|
108
108
|
end
|
109
109
|
|
110
|
+
def descendants
|
111
|
+
ObjectSpace.each_object(Class).select { |klass| klass < self }
|
112
|
+
end
|
113
|
+
|
114
|
+
# @param type [Symbol, String] eg. :tr, :ts, "TS"
|
115
|
+
# @return [Boolean] true if provided type matches with identifier's class type
|
116
|
+
def has_type?(type)
|
117
|
+
return type == self.type[:key] if type.is_a?(Symbol)
|
118
|
+
|
119
|
+
self.type.key?(:values) ? self.type[:values].include?(type) : type.to_s.downcase.to_sym == self.type[:key]
|
120
|
+
end
|
121
|
+
|
110
122
|
def get_amendment_class
|
111
123
|
Amendment
|
112
124
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Pubid::Core
|
2
|
+
class Type
|
3
|
+
attr_accessor :type
|
4
|
+
# Create new type
|
5
|
+
# @param type [Symbol]
|
6
|
+
def initialize(type = DEFAULT_TYPE)
|
7
|
+
type = type.to_s.downcase.to_sym unless type.is_a?(Symbol)
|
8
|
+
|
9
|
+
raise Errors::WrongTypeError, "#{type} type is not available" unless TYPE_NAMES.key?(type)
|
10
|
+
|
11
|
+
@type = type
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.parse(type_string)
|
15
|
+
TYPE_NAMES.each do |type, values|
|
16
|
+
return new(type) if values[:short] == type_string
|
17
|
+
end
|
18
|
+
raise Errors::ParseTypeError, "Cannot parse '#{type_string}' type"
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_s(format = :short)
|
22
|
+
TYPE_NAMES[type][format]
|
23
|
+
end
|
24
|
+
|
25
|
+
def ==(other)
|
26
|
+
return type == other if other.is_a?(Symbol)
|
27
|
+
|
28
|
+
return false if other.nil?
|
29
|
+
|
30
|
+
type == other.type
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.has_type?(type)
|
34
|
+
TYPE_NAMES.any? do |_, v|
|
35
|
+
v[:short] == type
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/pubid/core/version.rb
CHANGED
data/lib/pubid/core.rb
CHANGED
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.5.
|
4
|
+
version: 1.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -76,6 +76,7 @@ files:
|
|
76
76
|
- lib/pubid/core/stage.rb
|
77
77
|
- lib/pubid/core/supplement.rb
|
78
78
|
- lib/pubid/core/transformer.rb
|
79
|
+
- lib/pubid/core/type.rb
|
79
80
|
- lib/pubid/core/version.rb
|
80
81
|
homepage: https://github.com/metanorma/pubid-core
|
81
82
|
licenses:
|