Skip to content

glossarist-ruby

Ruby gem implementing the Glossarist concept model in Ruby. All the entities in the model are available as classes and all the attributes are available as methods of those classes. This gem also allows you to read/write data to concept datasets or create your own collection and save that to Glossarist model V2 dataset.

Install

Add this line to your application's Gemfile:

ruby
gem 'glossarist'

And then execute:

bash
bundle install

Or install it yourself as:

bash
gem install glossarist

Usage

Reading a Glossarist model V2 from files

Glossarist model V2 dataset is a collection of concepts and their localized concepts in the form of YAML files. The storage structure of the dataset has 2 forms:

  1. Each concept is stored in a concept YAML file and its localized concepts are stored in separate YAML files. The concept files are stored in the concept folder and its localized concepts are stored in the localized_concept folder.
  2. Each concept and its related localized concepts are stored in a single YAML file. These concept files are stored directly in the specified path.

To load the Glossarist model V2 dataset:

ruby
collection = Glossarist::ManagedConceptCollection.new
collection.load_from_files("path/to/glossarist-v2-dataset")

Writing a Glossarist model V2 to files

ruby
collection = Glossarist::ManagedConceptCollection.new
collection.load_from_files("path/to/glossarist-v2-dataset")
# ... Update the collection ...
collection.save_to_files("path/to/glossarist-v2-dataset")

To write with concepts and their localized concepts grouped into single files:

ruby
collection.save_grouped_concepts_to_files("path/to/glossarist-v2-dataset")

ManagedConceptCollection

This is a collection for managed concepts. It includes the Ruby Enumerable module.

ruby
collection = Glossarist::ManagedConceptCollection.new

ManagedConcept

Following fields are available for ManagedConcept:

FieldDescription
idString identifier for the concept
uuidUUID for the concept
relatedArray of RelatedConcept
statusEnum for the normative status of the term
datesArray of ConceptDate
localized_conceptsHash of localizations (language code → UUID)
domainsArray of ConceptReference — upper concepts
localizationsHash of localizations (language code → LocalizedConcept)
ruby
concept = Glossarist::ManagedConcept.new({
  "data" => {
    "id" => "123",
    "localized_concepts" => {
      "ara" => "<uuid>",
      "eng" => "<uuid>"
    },
    "localizations" => [...],
    "domains" => [
      { "concept_id" => "103", "ref_type" => "domain" },
    ],
  },
})

LocalizedConcept

Localizations of the term to different languages.

FieldDescription
idOptional identifier for cross-references
uuidUUID for the concept
designationsArray of Designations
domainURI reference to the subject area
relatedArray of per-language RelatedConcept
subjectSubject of the term
definitionArray of DetailedDefinition
non_verb_repArray of non-verbal representations
notesZero or more notes
examplesZero or more examples
language_codeISO-639 3-letter language code
scriptISO 15924 4-letter script code (optional)
entry_statusnotValid, valid, superseded, or retired
classificationpreferred, admitted, or deprecated

An open source project of Ribose