diff --git a/lib/termium/cli.rb b/lib/termium/cli.rb index 6f5891a..6749ca9 100644 --- a/lib/termium/cli.rb +++ b/lib/termium/cli.rb @@ -53,7 +53,7 @@ def convert puts "Converting to Glossarist..." convert_options = {} if options[:date_accepted] - convert_options[:date_accepted] = Date.parse(options[:date_accepted]) + convert_options[:date_accepted] = Date.parse(options[:date_accepted]).iso8601 end glossarist_col = termium_extract.to_concept(convert_options) # pp glossarist_col.first diff --git a/lib/termium/core.rb b/lib/termium/core.rb index 4434f89..2213d7f 100644 --- a/lib/termium/core.rb +++ b/lib/termium/core.rb @@ -38,8 +38,8 @@ def concept_sources end # Deterministic v4 UUID by using the number string - def uuid - UUIDTools::UUID.md5_create(UUIDTools::UUID_DNS_NAMESPACE, identification_number).to_s + def uuid(str = identification_number) + UUIDTools::UUID.md5_create(UUIDTools::UUID_DNS_NAMESPACE, str).to_s end # TODO: Utilize "subject" in the Glossarist object: @@ -60,11 +60,15 @@ def to_concept(options = {}) concept.date_accepted = options[:date_accepted] end - language_module.map(&:to_concept).each do |localized_concept| + language_module.map do |lang_mod| + localized_concept = lang_mod.to_concept(options) + # TODO: This is needed to skip the empty french entries of 10031781 and 10031778 next if localized_concept.nil? localized_concept.id = identification_number + localized_concept.uuid = uuid("#{identification_number}-#{lang_mod.language}") + universal_entry.each do |entry| localized_concept.notes << entry.value end diff --git a/lib/termium/language_module.rb b/lib/termium/language_module.rb index 7470aa7..7b6c346 100644 --- a/lib/termium/language_module.rb +++ b/lib/termium/language_module.rb @@ -60,6 +60,7 @@ def to_h "definition" => [{ content: definition }], "notes" => notes, "examples" => examples, + "entry_status" => "valid", } src["domain"] = domain if domain @@ -67,11 +68,19 @@ def to_h src end - def to_concept + def to_concept(options = {}) x = to_h return nil unless x - Glossarist::LocalizedConcept.new(x) + Glossarist::LocalizedConcept.new(x).tap do |concept| + # Fill in register parameters + if options[:date_accepted] + puts options[:date_accepted].inspect + concept.date_accepted = options[:date_accepted] + end + + puts concept.inspect + end end end end