glossarist 1.0.9 → 1.1.0

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: b8fa4ca87465329dfee265b0c813794fbb857d5bbd174c2f7f28f6b4e678f372
4
- data.tar.gz: c83f9967b06603b4e756f47a8c9bd78ad89b0c1ac8201d6bfcd34c2efc0c5db4
3
+ metadata.gz: 351ee7a983e5566dab9124def66fef23e1a8517b463c695e72388d40939c6031
4
+ data.tar.gz: d7f4b103f7a60ed7bb80983d30d8f9bba281a1f6c8ec293dcd73eecdbec8e2bf
5
5
  SHA512:
6
- metadata.gz: 06207f39595d5ba32421f836268c71a081b028b32183062096c994fef1d794007f32093992716c97a39e91ccda07879405d934d7ea4e9746cf14470fd6e48993
7
- data.tar.gz: 53b67a4ed78221ea53e2d4d498a39bf01b487d1ec7682a39da16a00ae17dfabc0f162a4b39ea25a6a8dc4259c30e3f0c38835743fbda821b4f53c4dd77ea8318
6
+ metadata.gz: 4614c9b4457b76d5f7936f9b43a6f97c8ceeb62442aafb4d865e3bdc8aa786493af6062a9cef48e3328085cf38a876822eb0dd48b8ac1d490ad166eeaaf8713e
7
+ data.tar.gz: dcdb5aca4bda8c3ebae41a7ef1c3cfcbf3c154fe2e0aa38ea8c1b76e175c08b7c3d070daddbb9e54e3079f324f7b229b5e6f60d77908e1689d05e35ac84347e5
data/glossarist.gemspec CHANGED
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
30
30
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
31
31
  spec.require_paths = ["lib"]
32
32
 
33
- spec.add_dependency "relaton", "~> 1.15.0"
33
+ spec.add_dependency "relaton", "~> 1.16.0"
34
34
  spec.add_dependency "thor"
35
35
 
36
36
  spec.add_development_dependency "pry", "~> 0.14.0"
@@ -7,8 +7,7 @@ module Glossarist
7
7
  class Concept < Model
8
8
  # Concept ID.
9
9
  # @return [String]
10
- attr_accessor :id
11
- alias :termid= :id=
10
+ attr_reader :id
12
11
 
13
12
  # Concept designations.
14
13
  # @todo Alias +terms+ exists only for legacy reasons and will be removed.
@@ -54,6 +53,13 @@ module Glossarist
54
53
  super
55
54
  end
56
55
 
56
+ def id=(id)
57
+ raise(Glossarist::Error, "id must be a string") unless id.is_a?(String) || id.nil?
58
+
59
+ @id = id
60
+ end
61
+ alias :termid= :id=
62
+
57
63
  # List of authorative sources.
58
64
  # @todo Alias +authoritative_source+ exists for legacy reasons and may be
59
65
  # removed.
@@ -119,7 +125,7 @@ module Glossarist
119
125
  # rubocop:disable Metrics/AbcSize, Style/RescueModifier
120
126
  def self.from_h(hash)
121
127
  new.tap do |concept|
122
- concept.id = hash.dig("termid")
128
+ concept.id = hash.dig("termid") || hash.dig("id")
123
129
  concept.sources = hash.dig("sources")
124
130
  concept.related = hash.dig("related")
125
131
  concept.definition = hash.dig("definition")
@@ -0,0 +1,15 @@
1
+ module Glossarist
2
+ class InvalidLanguageCodeError < Error
3
+ attr_reader :code
4
+
5
+ def initialize(code:)
6
+ @code = code
7
+
8
+ super()
9
+ end
10
+
11
+ def to_s
12
+ "Invalid value for language_code: `#{code}`. It must be 3 characters long string."
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,4 @@
1
+ module Glossarist
2
+ class InvalidTypeError < Error
3
+ end
4
+ end
@@ -0,0 +1,16 @@
1
+ module Glossarist
2
+ class ParseError < Error
3
+ attr_accessor :line, :filename
4
+
5
+ def initialize(filename:, line: nil)
6
+ @filename = filename
7
+ @line = line
8
+
9
+ super()
10
+ end
11
+
12
+ def to_s
13
+ "Unable to parse file: #{filename}, error on line: #{line}"
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,8 @@
1
+ require_relative "error/invalid_type_error"
2
+ require_relative "error/invalid_language_code_error"
3
+ require_relative "error/parse_error"
4
+
5
+ module Glossarist
6
+ class Error < StandardError
7
+ end
8
+ end
@@ -8,7 +8,7 @@ module Glossarist
8
8
  # ISO 639-2 code for terminology.
9
9
  # @see https://www.loc.gov/standards/iso639-2/php/code_list.php code list
10
10
  # @return [String]
11
- attr_accessor :language_code
11
+ attr_reader :language_code
12
12
 
13
13
  # Must be one of the following:
14
14
  # +notValid+, +valid+, +superseded+, +retired+.
@@ -34,6 +34,14 @@ module Glossarist
34
34
  super
35
35
  end
36
36
 
37
+ def language_code=(language_code)
38
+ if language_code.is_a?(String) && language_code.length == 3
39
+ @language_code = language_code
40
+ else
41
+ raise Glossarist::InvalidLanguageCodeError.new(code: language_code)
42
+ end
43
+ end
44
+
37
45
  def to_h # rubocop:disable Metrics/MethodLength
38
46
  super.merge({
39
47
  "language_code" => language_code,
@@ -4,5 +4,5 @@
4
4
  #
5
5
 
6
6
  module Glossarist
7
- VERSION = "1.0.9"
7
+ VERSION = "1.1.0"
8
8
  end
data/lib/glossarist.rb CHANGED
@@ -30,28 +30,9 @@ require_relative "glossarist/non_verb_rep"
30
30
  require_relative "glossarist/collections"
31
31
 
32
32
  require_relative "glossarist/config"
33
+ require_relative "glossarist/error"
33
34
 
34
35
  module Glossarist
35
- class Error < StandardError; end
36
-
37
- class InvalidTypeError < StandardError; end
38
-
39
- class ParseError < StandardError
40
- attr_accessor :line, :filename
41
-
42
- def initialize(filename:, line: nil)
43
- @filename = filename
44
- @line = line
45
-
46
- super()
47
- end
48
-
49
- def to_s
50
- "Unable to parse file: #{filename}, error on line: #{line}"
51
- end
52
- end
53
- # Your code goes here...
54
-
55
36
  def self.configure
56
37
  config = Glossarist::Config.instance
57
38
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glossarist
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.9
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-12 00:00:00.000000000 Z
11
+ date: 2023-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: relaton
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.15.0
19
+ version: 1.16.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.15.0
26
+ version: 1.16.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: thor
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -124,6 +124,10 @@ files:
124
124
  - lib/glossarist/designation/letter_symbol.rb
125
125
  - lib/glossarist/designation/symbol.rb
126
126
  - lib/glossarist/detailed_definition.rb
127
+ - lib/glossarist/error.rb
128
+ - lib/glossarist/error/invalid_language_code_error.rb
129
+ - lib/glossarist/error/invalid_type_error.rb
130
+ - lib/glossarist/error/parse_error.rb
127
131
  - lib/glossarist/glossary_definition.rb
128
132
  - lib/glossarist/localized_concept.rb
129
133
  - lib/glossarist/managed_concept.rb