glossarist-new 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c97457297f94e65b52da9de5fd9dc620f3722034e9a97dae80c81736333cf7d
4
- data.tar.gz: e8716f64a5cb9d2e84f752540854219a6ffe406fc46140158274fc135a002da0
3
+ metadata.gz: f0b88c582178e67916b7058bba75f92a14b5862926188092fa6e539c0eb05ad5
4
+ data.tar.gz: c7d3c4e294f2f77279e712d865239a824ea84ee8fb2a884e23f935c9ca5b871e
5
5
  SHA512:
6
- metadata.gz: 2f9db6e9f0f5e716c9810d44f06fd14d77140aa060b9004dbc900c2766be1bb08733789e0619d8cda633c18158ddf931b943cd9a5c4d6c025240f71453f351e4
7
- data.tar.gz: 28c854fab76b67814180a2da7043ecb8072aea4828c9bcba92cf2b45ae57af5680733532837d46427a8bfd0d2834b965a04b51791010e50b214243ab27d7b7bc
6
+ metadata.gz: 2ed31f71ae7f554ed6e4f32f27f2203d78c66ce95e6f1e33502cc610142d9cef534ba21fe6a01aee37bf75f6d889b61f99780448e12aa591e4454cf73986d891
7
+ data.tar.gz: aa4f3b7c9882afde4d1bbf541ccf509150e434a63fa0f68314d6f72e48d344a22d73524eed91524b5b81c83105cc9917c5c469a24560c181619fe0c10c827f01
@@ -122,7 +122,7 @@ module Glossarist
122
122
 
123
123
  hash.values
124
124
  .grep(Hash)
125
- .map { |subhash| LocalizedConcept.from_h(subhash) rescue nil }
125
+ .map { |subhash| Config.class_for(:localized_concept).from_h(subhash) rescue nil }
126
126
  .compact
127
127
 
128
128
  concept.related = hash.dig("related") || []
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "singleton"
4
+
5
+ module Glossarist
6
+ class Config
7
+ include Singleton
8
+
9
+ DEFAULT_CLASSES = {
10
+ localized_concept: Glossarist::LocalizedConcept,
11
+ }.freeze
12
+
13
+ attr_reader :registered_classes
14
+
15
+ def initialize
16
+ @registered_classes = DEFAULT_CLASSES.dup
17
+ end
18
+
19
+ def class_for(name)
20
+ @registered_classes[name.to_sym]
21
+ end
22
+
23
+ def register_class(class_name, klass)
24
+ @registered_classes[class_name] = klass
25
+ end
26
+
27
+ class << self
28
+ def class_for(name)
29
+ self.instance.class_for(name)
30
+ end
31
+
32
+ def register_class(class_name, klass)
33
+ self.instance.register_class(class_name, klass)
34
+ end
35
+ end
36
+ end
37
+ end
@@ -36,7 +36,7 @@ module Glossarist
36
36
  end
37
37
 
38
38
  def localized_concepts=(localized_concepts_hash)
39
- @localized_concepts = localized_concepts_hash.map { |l| LocalizedConcept.new(l) }.compact
39
+ @localized_concepts = localized_concepts_hash.map { |l| Config.class_for(:localized_concept).new(l) }.compact
40
40
 
41
41
  @localized_concepts.each do |l|
42
42
  add_l10n(l)
@@ -4,5 +4,5 @@
4
4
  #
5
5
 
6
6
  module Glossarist
7
- VERSION = "1.0.2"
7
+ VERSION = "1.0.3"
8
8
  end
data/lib/glossarist.rb CHANGED
@@ -28,8 +28,16 @@ require_relative "glossarist/non_verb_rep"
28
28
 
29
29
  require_relative "glossarist/collections"
30
30
 
31
+ require_relative "glossarist/config"
32
+
31
33
  module Glossarist
32
34
  class Error < StandardError; end
33
35
  class InvalidTypeError < StandardError; end
34
36
  # Your code goes here...
37
+
38
+ def self.configure
39
+ config = Glossarist::Config.instance
40
+
41
+ yield(config) if block_given?
42
+ end
35
43
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glossarist-new
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-03-01 00:00:00.000000000 Z
11
+ date: 2023-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: relaton
@@ -97,6 +97,7 @@ files:
97
97
  - lib/glossarist/concept_manager.rb
98
98
  - lib/glossarist/concept_set.rb
99
99
  - lib/glossarist/concept_source.rb
100
+ - lib/glossarist/config.rb
100
101
  - lib/glossarist/designation.rb
101
102
  - lib/glossarist/designation/abbreviation.rb
102
103
  - lib/glossarist/designation/base.rb