pubid-core 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pubid/core/renderer/base.rb +51 -7
- data/lib/pubid/core/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a3c1e99b3327c14f2364992238d1d6a4040809dca85a6640254e2669784a449
|
4
|
+
data.tar.gz: ca910a6333a2e5e9dc1c907577bee5c3e0c34bc6a891e07b310f4be39e9ecc59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b148eeaf72cd34a292d1da244e33a4c4f7eb1549cca374e9c7da7aadc6a09de262c992de578725ebb5ecaad4c1fa625365dbfda519119ccec82c39da224d71f7
|
7
|
+
data.tar.gz: 9fb7676fbd6e7ffbf1bce920a626d70a260c24e83d59569447595c4e28157e879969b6700423d9199564e915d7929ca5c93a507e2703d79c192f0cc21d6f91cf
|
@@ -13,6 +13,22 @@ module Pubid::Core::Renderer
|
|
13
13
|
@params = params
|
14
14
|
end
|
15
15
|
|
16
|
+
# Prerender parameters and store in @prerendered_params
|
17
|
+
# @param opts [Hash] options for render method, eg. { with_language_code: :single, with_date: true }
|
18
|
+
# @return [Renderer::Base] self
|
19
|
+
def prerender(**opts)
|
20
|
+
@prerendered_params = prerender_params(@params, opts)
|
21
|
+
@prerendered_params.default = ""
|
22
|
+
self
|
23
|
+
end
|
24
|
+
|
25
|
+
def render_base_identifier(**args)
|
26
|
+
prerender(**args)
|
27
|
+
|
28
|
+
render_identifier(@prerendered_params)
|
29
|
+
end
|
30
|
+
|
31
|
+
|
16
32
|
def prerender_params(params, opts)
|
17
33
|
params.map do |key, value|
|
18
34
|
next unless value
|
@@ -24,16 +40,44 @@ module Pubid::Core::Renderer
|
|
24
40
|
end.compact.to_h
|
25
41
|
end
|
26
42
|
|
43
|
+
# Renders amendment and corrigendum when applied through identifier type
|
44
|
+
def render_supplement(supplement_params, **args)
|
45
|
+
if supplement_params[:base].type == :amd
|
46
|
+
# render inner amendment (cor -> amd -> base)
|
47
|
+
render_supplement(supplement_params[:base].get_params, **args)
|
48
|
+
else
|
49
|
+
self.class.new(supplement_params[:base].get_params).render_base_identifier(
|
50
|
+
# always render year for identifiers with supplement
|
51
|
+
**args.merge({ with_date: true }),
|
52
|
+
)
|
53
|
+
end +
|
54
|
+
case supplement_params[:type].type
|
55
|
+
when :amd
|
56
|
+
render_amendments(
|
57
|
+
[Pubid::Iso::Amendment.new(**supplement_params.slice(:number, :year, :stage, :edition, :iteration))],
|
58
|
+
args,
|
59
|
+
nil,
|
60
|
+
)
|
61
|
+
when :cor
|
62
|
+
render_corrigendums(
|
63
|
+
[Pubid::Iso::Corrigendum.new(**supplement_params.slice(:number, :year, :stage, :edition, :iteration))],
|
64
|
+
args,
|
65
|
+
nil,
|
66
|
+
)
|
67
|
+
# copy parameters from Identifier only supported by Corrigendum
|
68
|
+
end +
|
69
|
+
(supplement_params[:base].language ? render_language(supplement_params[:base].language, args, nil) : "")
|
70
|
+
end
|
71
|
+
|
27
72
|
# Render identifier
|
28
73
|
# @param with_date [Boolean] include year in output
|
29
74
|
# @param with_language_code [:iso,:single] render document language as 2-letter ISO 639-1 language code or single code
|
30
|
-
def render(with_date: true, with_language_code: :iso)
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
render_identifier(params)
|
75
|
+
def render(with_date: true, with_language_code: :iso, **args)
|
76
|
+
if %i(amd cor).include? @params[:type]&.type
|
77
|
+
render_supplement(@params, **args.merge({ with_date: with_date, with_language_code: with_language_code}))
|
78
|
+
else
|
79
|
+
render_base_identifier(**args.merge({ with_date: with_date, with_language_code: with_language_code})) + @prerendered_params[:language].to_s
|
80
|
+
end
|
37
81
|
end
|
38
82
|
|
39
83
|
def render_base(params, prefix = "")
|
data/lib/pubid/core/version.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.2.
|
4
|
+
version: 1.2.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: 2022-10-
|
11
|
+
date: 2022-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|