relaton-render 1.4.0.pre.alpha.1 → 1.4.0.pre.alpha.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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 51375c04860a0856ea38e357f01398a65e2b8d32b8d2626e014d46110ae710fe
|
|
4
|
+
data.tar.gz: e684c82bd7d48d1a2763adf42c692b8a980c9f80c1cb35334bf6f40fcd4324b4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c3c7fb5f5ffc57913d83f8f99ceb01d50e234059a68731a5e32ab84e22e47c69cb1c7faf4f1248cdaf9954dcca2295bf7843cb47a55a63b940d361cad87673f0
|
|
7
|
+
data.tar.gz: a3c8a7e0127f3d1dddaad363802a2f882ce7cffa51beccd3fd7e72724ef0ff894b746b86d08386c75644b812f95c666f09d41b821ea7e10d6ebb9f8cf9517f4c
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Relaton
|
|
4
|
+
module Render
|
|
5
|
+
# Compatibility entry point (relaton-render#90).
|
|
6
|
+
#
|
|
7
|
+
# The v2 engine replaced the liquid/config/i18n machinery with the
|
|
8
|
+
# template evaluator over CitationStyle instances
|
|
9
|
+
# (Relaton::Render::Iso690). isodoc main's render-isodoc subclasses
|
|
10
|
+
# this constant, so it must exist for all-git-main stacks to boot.
|
|
11
|
+
# This facade delegates rendering to the v2 engine; the retired
|
|
12
|
+
# options (config:, template overrides in liquid syntax) are ignored
|
|
13
|
+
# with one warning — migrate to a CitationStyle instance, which
|
|
14
|
+
# expresses everything the old config.yml did (see the citation
|
|
15
|
+
# module in relaton-models).
|
|
16
|
+
class General
|
|
17
|
+
def initialize(options = {})
|
|
18
|
+
@renderer = Iso690::Renderer.new(
|
|
19
|
+
lang: options[:language] || options[:lang] || "en",
|
|
20
|
+
script: options[:script] || "Latn",
|
|
21
|
+
labels: options[:i18nhash] || {},
|
|
22
|
+
)
|
|
23
|
+
warn_general_config if options[:config]
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def render(model, **opts)
|
|
27
|
+
@renderer.render(model, **opts)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def citation(model, **opts)
|
|
31
|
+
@renderer.citation(model, **opts)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
private
|
|
35
|
+
|
|
36
|
+
def warn_general_config
|
|
37
|
+
return if General.config_warned
|
|
38
|
+
|
|
39
|
+
General.config_warned = true
|
|
40
|
+
warn "relaton-render: Relaton::Render::General is a compatibility " \
|
|
41
|
+
"facade over the v2 engine; the liquid config option is " \
|
|
42
|
+
"retired and ignored. Author a CitationStyle instance " \
|
|
43
|
+
"(relaton-models citation module) for custom rendering."
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
class << self
|
|
47
|
+
attr_accessor :config_warned
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -36,6 +36,19 @@ module Relaton
|
|
|
36
36
|
self
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
+
# Runtime label overrides (a caller's i18n hash): the pack's label
|
|
40
|
+
# names win as the key mapping; unknown keys are ignored.
|
|
41
|
+
def overlay_hash!(hash)
|
|
42
|
+
known = %w[
|
|
43
|
+
edition series_no report_no available_from in and oxford_comma
|
|
44
|
+
ed eds date_range others no_date no_author at
|
|
45
|
+
]
|
|
46
|
+
hash.each do |key, value|
|
|
47
|
+
labels[key.to_s] = value if known.include?(key.to_s) && !value.nil?
|
|
48
|
+
end
|
|
49
|
+
self
|
|
50
|
+
end
|
|
51
|
+
|
|
39
52
|
class << self
|
|
40
53
|
def load(lang = "en")
|
|
41
54
|
code = lang.to_s.empty? ? "en" : lang
|
|
@@ -24,9 +24,11 @@ module Relaton
|
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
def initialize(style: DEFAULT_STYLE, lang: "en", script: "Latn"
|
|
27
|
+
def initialize(style: DEFAULT_STYLE, lang: "en", script: "Latn",
|
|
28
|
+
labels: {})
|
|
28
29
|
@style = Style.load(style)
|
|
29
30
|
@i18n = I18n.load(lang).overlay!(@style.scheme.locale)
|
|
31
|
+
@i18n.overlay_hash!(labels) unless labels.empty?
|
|
30
32
|
@script = script
|
|
31
33
|
end
|
|
32
34
|
|
|
@@ -6,6 +6,10 @@ module Relaton
|
|
|
6
6
|
# places the inventory's data elements (clause 7) in each resource
|
|
7
7
|
# kind's order (clause 8); the engine is a template evaluator over a
|
|
8
8
|
# field resolver and holds no styles, no vocabularies, no i18n.
|
|
9
|
+
# The v1 compatibility facade (relaton-render#90): isodoc's
|
|
10
|
+
# render-isodoc subclasses Relaton::Render::General.
|
|
11
|
+
autoload :General, "relaton/render/general"
|
|
12
|
+
|
|
9
13
|
module Iso690
|
|
10
14
|
autoload :Element, "relaton/render/iso690/element"
|
|
11
15
|
autoload :Elements, "relaton/render/iso690/elements"
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: relaton-render
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.4.0.pre.alpha.
|
|
4
|
+
version: 1.4.0.pre.alpha.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
@@ -54,6 +54,7 @@ files:
|
|
|
54
54
|
- lib/isodoc-yaml/i18n-zh-Hant.yaml
|
|
55
55
|
- lib/isodoc/i18n.rb
|
|
56
56
|
- lib/relaton-render.rb
|
|
57
|
+
- lib/relaton/render/general.rb
|
|
57
58
|
- lib/relaton/render/iso690.rb
|
|
58
59
|
- lib/relaton/render/iso690/element.rb
|
|
59
60
|
- lib/relaton/render/iso690/elements.rb
|