glossarist 2.9.2 → 2.10.0

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: c1b00e7f214346a1df82300439a80e6e1888609c7b981b2a9f8460a2bd5bd37b
4
- data.tar.gz: 0f91a052ae1c913e9ff52daf0f3835900eb0847fd41c0bfe287c2782ae829af8
3
+ metadata.gz: 483020f943aae466ffd07054d852c766673b71ca17c4289d59be667c2bd7fb4f
4
+ data.tar.gz: 876d6fdcdf3c087a4c6487a48e81592a14317bde57047fb7087104b2093d4e4f
5
5
  SHA512:
6
- metadata.gz: 1325227b2a204a4ebbf09331f8e57705176b985dadb03d1bd100d9d4856ed93a8850b21df06eb7d2498e61d01631517aa6284182b400d145f52eeccb0f7c7030
7
- data.tar.gz: 07e6e35d730702809b30265bb50ba8b56555cbb3bd2eedf27f14fa3f36bdb40001c551195980f04cd2d23fafbd2bfc22c29fb4ff48fc042ee49a6d4e187110f0
6
+ metadata.gz: 3f7bca485b83de6c31bcf896f95d27007794e97eb54f1fc7136e7fa590b237d4a53735f9a136e624447bb886d6d5ff52b43a3adadbd3611dde296a06f2b214f7
7
+ data.tar.gz: b7a489b23c7d504340cf7ae0c7bad68755d20cae57cacf8a6b340e2dde75a35fd64cce798157e9f0d4b0fc09a83d4f4fc94f7a58654d5cfda0c9aca835f77285
@@ -37,53 +37,6 @@ module Glossarist
37
37
  map "translations", to: :translations
38
38
  end
39
39
 
40
- def [](key)
41
- case key
42
- when "shortname", "id" then shortname
43
- when "name" then name
44
- when "description" then description
45
- when "schema_version" then schema_version
46
- when "version" then version
47
- when "owner" then owner
48
- when "languages" then languages
49
- when "subregisters" then subregisters
50
- when "uri_prefix" then uri_prefix
51
- when "concept_uri_template" then concept_uri_template
52
- when "homepage" then homepage
53
- when "repository" then repository
54
- when "license" then license
55
- when "tags" then tags
56
- when "translations" then translations
57
- end
58
- end
59
-
60
- def dig(*keys)
61
- return nil if keys.empty?
62
-
63
- first = self[keys.first]
64
- keys.length == 1 ? first : nil
65
- end
66
-
67
- def to_h
68
- h = {}
69
- h["shortname"] = shortname if shortname
70
- h["name"] = name if name
71
- h["description"] = description if description
72
- h["schema_version"] = schema_version if schema_version
73
- h["version"] = version if version
74
- h["owner"] = owner if owner
75
- h["languages"] = languages if languages && !languages.empty?
76
- h["subregisters"] = subregisters if subregisters && !subregisters.empty?
77
- h["uri_prefix"] = uri_prefix if uri_prefix
78
- h["concept_uri_template"] = concept_uri_template if concept_uri_template
79
- h["homepage"] = homepage if homepage
80
- h["repository"] = repository if repository
81
- h["license"] = license if license
82
- h["tags"] = tags if tags && !tags.empty?
83
- h["translations"] = translations if translations && !translations.empty?
84
- h
85
- end
86
-
87
40
  def self.from_file(path)
88
41
  return nil unless File.exist?(path)
89
42
 
@@ -20,10 +20,17 @@ module Glossarist
20
20
  .transform_keys(&:to_s)
21
21
  .freeze
22
22
 
23
- DATE_TYPE_MAP = {
24
- "accepted" => "#{GLOSS}status/accepted",
25
- "amended" => "#{GLOSS}status/amended",
26
- "retired" => "#{GLOSS}status/retired",
23
+ # Maps each Designation subclass to the method that builds its RDF
24
+ # counterpart. Lookup is by exact class — a Designation instance is
25
+ # always exactly one of these classes (the STI pattern in
26
+ # Designation::Base#of_yaml enforces this). Adding a new Designation
27
+ # subclass means adding one entry here, not editing a case/when.
28
+ DESIGNATION_BUILDERS = {
29
+ Designation::Abbreviation => :build_gloss_abbreviation,
30
+ Designation::Expression => :build_gloss_expression,
31
+ Designation::GraphicalSymbol => :build_gloss_graphical_symbol,
32
+ Designation::LetterSymbol => :build_gloss_letter_symbol,
33
+ Designation::Symbol => :build_gloss_symbol,
27
34
  }.freeze
28
35
 
29
36
  def self.transform(managed_concept, options = {})
@@ -165,21 +172,21 @@ module Glossarist
165
172
  end
166
173
 
167
174
  def designation_instance_for(desig, common_attrs, concept_id, lang, index)
168
- case desig
169
- when Designation::Abbreviation
170
- build_gloss_abbreviation(desig, common_attrs, concept_id, lang, index)
171
- when Designation::Expression
172
- build_gloss_expression(desig, common_attrs, concept_id, lang, index)
173
- when Designation::GraphicalSymbol
174
- Rdf::GlossGraphicalSymbol.new(common_attrs.merge(text: desig.text,
175
- image: desig.image))
176
- when Designation::LetterSymbol
177
- Rdf::GlossLetterSymbol.new(common_attrs.merge(text: desig.text))
178
- when Designation::Symbol
179
- Rdf::GlossSymbol.new(common_attrs)
180
- else
181
- Rdf::GlossExpression.new(common_attrs)
182
- end
175
+ builder = DESIGNATION_BUILDERS[desig.class] || :build_gloss_expression
176
+ send(builder, desig, common_attrs, concept_id, lang, index)
177
+ end
178
+
179
+ def build_gloss_graphical_symbol(desig, common_attrs, *_unused)
180
+ Rdf::GlossGraphicalSymbol.new(common_attrs.merge(text: desig.text,
181
+ image: desig.image))
182
+ end
183
+
184
+ def build_gloss_letter_symbol(desig, common_attrs, *_unused)
185
+ Rdf::GlossLetterSymbol.new(common_attrs.merge(text: desig.text))
186
+ end
187
+
188
+ def build_gloss_symbol(_desig, common_attrs, *_unused)
189
+ Rdf::GlossSymbol.new(common_attrs)
183
190
  end
184
191
 
185
192
  def designation_common_attrs(desig, concept_id, lang, index)
@@ -337,7 +344,7 @@ desig_index)
337
344
  Array(dates).map do |date|
338
345
  Rdf::GlossConceptDate.new(
339
346
  date_value: date.date&.to_s,
340
- date_type: DATE_TYPE_MAP[date.type] || "gloss:status/#{date.type}",
347
+ date_type: "gloss:status/#{date.type}",
341
348
  concept_id: concept_id.to_s,
342
349
  )
343
350
  end
@@ -51,8 +51,8 @@ module Glossarist
51
51
  def declared_languages
52
52
  @declared_languages ||= begin
53
53
  reg = load_register_data
54
- if reg && reg["languages"].is_a?(Array)
55
- reg["languages"]
54
+ if reg && reg.languages.is_a?(Array)
55
+ reg.languages
56
56
  else
57
57
  actual_languages
58
58
  end
@@ -4,5 +4,5 @@
4
4
  #
5
5
 
6
6
  module Glossarist
7
- VERSION = "2.9.2"
7
+ VERSION = "2.10.0"
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glossarist
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.2
4
+ version: 2.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose