Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions lib/termium/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,12 @@ def uuid(str = identification_number)
UUIDTools::UUID.md5_create(UUIDTools::UUID_DNS_NAMESPACE, str).to_s
end

# TODO: Utilize "subject" in the Glossarist object:
# <subject abbreviation="YBB"
# details="Compartment - ISO/IEC JTC 1 Information Technology Vocabulary" />
def subject_field
return nil unless subject

"#{subject.details} (#{subject.abbreviation})"
end

def to_concept(options = {})
Glossarist::ManagedConcept.new.tap do |concept|
# The way to set the universal concept's identifier: data.identifier
Expand Down Expand Up @@ -73,6 +76,7 @@ def to_concept(options = {})
localized_concept.notes << Glossarist::DetailedDefinition.new(content: entry.value)
end
localized_concept.sources = concept_sources
localized_concept.subject = subject_field
concept.add_localization(localized_concept)
end
end
Expand Down
21 changes: 21 additions & 0 deletions spec/termium/core_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

RSpec.describe Termium::Core do
describe "#subject_field" do
context "with subject" do
let(:core) { described_class.new(subject: Termium::Subject.new(abbreviation: "YBB", details: "Compartment - ISO/IEC JTC 1")) }

it "returns details with abbreviation" do
expect(core.subject_field).to eq("Compartment - ISO/IEC JTC 1 (YBB)")
end
end

context "without subject" do
let(:core) { described_class.new }

it "returns nil" do
expect(core.subject_field).to be_nil
end
end
end
end
Loading