glossarist 2.1.0 → 2.2.1

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: ab9f794633ad83fc5d35fec74fad5006d187a4cd3c5c1ba91e563506a16ddaed
4
- data.tar.gz: 1c0af3de4b228856e9adc0f579f709e2f4c63a44d827b66325f2ea1b79df776a
3
+ metadata.gz: 9111f4d1d6b0ea9180c0a61faee7fa8a823aef40b3712803757bf0cc4df76509
4
+ data.tar.gz: 47255c6c4ad7b725198d7b3f3e256e30cc2c1489d0a1a8315c84e3aabae73d32
5
5
  SHA512:
6
- metadata.gz: 0cb0ad5ac9ea10c2aaad16062c6c5a10878b7c7f7bf6dd7a9e7641417ed2d1f47ee3fd3c9fc86fbca7262234e5a05141a11f584e798fe493d99064b73bcead0d
7
- data.tar.gz: e4431def5662c9f7eceff74cbff8258128525e657fb4901e06fd21a2243ad8f3d98fad62e28766aa5bdf0d20149ffd66525389fd3b703c57907e4fb2873dbd03
6
+ metadata.gz: 635ff3fb8d7f56a2e25968700c9b025946d4fb00ae0d8785619c438a2f4aaee5a93f82ff6022298a2c89d71da9c38d4095d215509addc1c3060b66fe9ff09bff
7
+ data.tar.gz: d04bf458f1e88b0f325e2c38403d426179e8ca33277ac1e6efe12fc85837bdddf7fd80899cc370ca1930f0a0f91da97b67aef7087009217a89b06f0d861cecbe
data/Gemfile CHANGED
@@ -2,4 +2,8 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
+ gem "pry", "~> 0.14.0"
6
+ gem "rake", "~> 13.0"
7
+ gem "rspec", "~> 3.10"
8
+
5
9
  gemspec
data/glossarist.gemspec CHANGED
@@ -30,10 +30,6 @@ 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.16"
33
+ spec.add_dependency "relaton", "~> 1.19"
34
34
  spec.add_dependency "thor"
35
-
36
- spec.add_development_dependency "pry", "~> 0.14.0"
37
- spec.add_development_dependency "rake", "~> 13.0"
38
- spec.add_development_dependency "rspec", "~> 3.10"
39
35
  end
@@ -69,12 +69,12 @@ module Glossarist
69
69
  def uuid
70
70
  @uuid ||= Glossarist::Utilities::UUID.uuid_v5(
71
71
  Glossarist::Utilities::UUID::OID_NAMESPACE,
72
- to_h.to_yaml,
72
+ to_h_no_uuid.to_yaml,
73
73
  )
74
74
  end
75
75
 
76
76
  def id=(id)
77
- # Some of the glossaries that are not generated using glossarist, contains ids that are integers
77
+ # Some of the glossaries that are not generated using glossarist, contains ids that are integers
78
78
  # so adding a temporary check until every glossary is updated using glossarist.
79
79
  if !id.nil? && (id.is_a?(String) || id.is_a?(Integer))
80
80
  @id = id
@@ -82,6 +82,7 @@ module Glossarist
82
82
  raise(Glossarist::Error, "Expect id to be a String or Integer, Got #{id.class} (#{id})")
83
83
  end
84
84
  end
85
+
85
86
  alias :termid= :id=
86
87
  alias :identifier= :id=
87
88
 
@@ -119,6 +120,7 @@ module Glossarist
119
120
  def preferred_designations
120
121
  @designations.select(&:preferred?)
121
122
  end
123
+
122
124
  alias :preferred_terms :preferred_designations
123
125
 
124
126
  def dates=(dates)
@@ -141,7 +143,22 @@ module Glossarist
141
143
  end
142
144
  end
143
145
 
144
- def to_h
146
+ def date_accepted=(date)
147
+ date_hash = {
148
+ "type" => "accepted",
149
+ "date" => date,
150
+ }
151
+
152
+ @dates ||= []
153
+ @dates << ConceptDate.new(date_hash)
154
+ end
155
+
156
+ def date_accepted
157
+ return nil unless @dates
158
+ @dates.find { |date| date.accepted? }
159
+ end
160
+
161
+ def to_h_no_uuid
145
162
  {
146
163
  "data" => {
147
164
  "dates" => dates&.map(&:to_h),
@@ -154,10 +171,18 @@ module Glossarist
154
171
  "sources" => sources.empty? ? nil : sources&.map(&:to_h),
155
172
  "terms" => (terms&.map(&:to_h) || []),
156
173
  "related" => related&.map(&:to_h),
174
+ "domain" => domain,
157
175
  }.compact,
176
+
177
+ "date_accepted" => date_accepted&.date,
178
+
158
179
  }.compact
159
180
  end
160
181
 
182
+ def to_h
183
+ to_h_no_uuid.merge("id" => uuid)
184
+ end
185
+
161
186
  # @deprecated For legacy reasons only.
162
187
  # Implicit conversion (i.e. {#to_hash} alias) will be removed soon.
163
188
  alias :to_hash :to_h
@@ -27,11 +27,11 @@ module Glossarist
27
27
  # Temporary fields
28
28
  # @todo Need to remove these once the isotc211-glossary is fixed
29
29
  attr_accessor *%i[
30
- review_date
31
- review_decision_date
32
- review_decision_event
33
- review_type
34
- ]
30
+ review_date
31
+ review_decision_date
32
+ review_decision_event
33
+ review_type
34
+ ]
35
35
 
36
36
  def language_code=(language_code)
37
37
  if language_code.is_a?(String) && language_code.length == 3
@@ -41,11 +41,10 @@ module Glossarist
41
41
  end
42
42
  end
43
43
 
44
- def to_h # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
44
+ def to_h_no_uuid # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
45
45
  hash = super
46
46
 
47
47
  hash["data"].merge!({
48
- "domain" => domain,
49
48
  "language_code" => language_code,
50
49
  "entry_status" => entry_status,
51
50
  "sources" => sources.empty? ? nil : sources&.map(&:to_h),
@@ -56,6 +55,8 @@ module Glossarist
56
55
  "review_decision_event" => review_decision_event,
57
56
  }.compact).merge!(@extension_attributes)
58
57
 
58
+ hash["status"] = entry_status if entry_status
59
+
59
60
  hash
60
61
  end
61
62
 
@@ -63,7 +64,7 @@ module Glossarist
63
64
  terms = hash["terms"]&.map { |h| Designation::Base.from_h(h) } || []
64
65
  sources = hash["authoritative_source"]&.each { |source| source.merge({ "type" => "authoritative" }) }
65
66
 
66
- super(hash.merge({"terms" => terms, "sources" => sources}))
67
+ super(hash.merge({ "terms" => terms, "sources" => sources }))
67
68
  end
68
69
 
69
70
  # @deprecated For legacy reasons only.
@@ -57,7 +57,7 @@ module Glossarist
57
57
  end
58
58
 
59
59
  def uuid
60
- @uuid ||= Glossarist::Utilities::UUID.uuid_v5(@uuid_namespace, to_h.to_yaml)
60
+ @uuid ||= Glossarist::Utilities::UUID.uuid_v5(@uuid_namespace, to_h_no_uuid.to_yaml)
61
61
  end
62
62
 
63
63
  def related=(related)
@@ -141,7 +141,7 @@ module Glossarist
141
141
 
142
142
  alias :l10n :localization
143
143
 
144
- def to_h
144
+ def to_h_no_uuid
145
145
  {
146
146
  "data" => {
147
147
  "identifier" => id,
@@ -149,9 +149,16 @@ module Glossarist
149
149
  "groups" => groups,
150
150
  "sources" => sources&.map(&:to_h),
151
151
  }.compact,
152
+ "related" => related&.map(&:to_h),
153
+ "date_accepted" => date_accepted&.date,
154
+ "status" => status,
152
155
  }.compact
153
156
  end
154
157
 
158
+ def to_h
159
+ to_h_no_uuid.merge("id" => uuid)
160
+ end
161
+
155
162
  def default_designation
156
163
  localized = localization("eng") || localizations.values.first
157
164
  terms = localized&.preferred_terms&.first || localized&.terms&.first
@@ -178,6 +185,7 @@ module Glossarist
178
185
  end
179
186
 
180
187
  def date_accepted
188
+ return nil unless @dates
181
189
  @dates.find { |date| date.accepted? }
182
190
  end
183
191
 
@@ -4,5 +4,5 @@
4
4
  #
5
5
 
6
6
  module Glossarist
7
- VERSION = "2.1.0"
7
+ VERSION = "2.2.1"
8
8
  end
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: 2.1.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-04-29 00:00:00.000000000 Z
11
+ date: 2024-11-19 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.16'
19
+ version: '1.19'
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.16'
26
+ version: '1.19'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: thor
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,48 +38,6 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: pry
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: 0.14.0
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: 0.14.0
55
- - !ruby/object:Gem::Dependency
56
- name: rake
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '13.0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '13.0'
69
- - !ruby/object:Gem::Dependency
70
- name: rspec
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '3.10'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '3.10'
83
41
  description:
84
42
  email:
85
43
  - open.source@ribose.com