Class: Glossarist::SchemaMigration::V0ToV1

Inherits:
Object
  • Object
show all
Defined in:
lib/glossarist/schema_migration/v0_to_v1.rb

Constant Summary collapse

ENTRY_STATUS_MAP =
{
  "Standard" => "valid",
  "Confirmed" => "valid",
  "Proposed" => "draft",
}.freeze
LANG_CODES =
Glossarist::LANG_CODES
IEV_PATTERN =
/\{\{([^,}]+),\s*IEV:([^}]+)\}\}/
URN_PATTERN =
/\{urn:iso:std:iso:(\d+):([^,}]+),([^}]+)\}/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(concept_hash, from_version: "0", to_version: SchemaMigration::CURRENT_SCHEMA_VERSION, ref_maps: {}) ⇒ V0ToV1

Returns a new instance of V0ToV1.



19
20
21
22
23
24
25
26
# File 'lib/glossarist/schema_migration/v0_to_v1.rb', line 19

def initialize(concept_hash, from_version: "0",
                         to_version: SchemaMigration::CURRENT_SCHEMA_VERSION,
                         ref_maps: {})
  @concept = concept_hash
  @from_version = from_version
  @to_version = to_version
  @ref_maps = ref_maps
end

Instance Attribute Details

#from_versionObject (readonly)

Returns the value of attribute from_version.



17
18
19
# File 'lib/glossarist/schema_migration/v0_to_v1.rb', line 17

def from_version
  @from_version
end

#to_versionObject (readonly)

Returns the value of attribute to_version.



17
18
19
# File 'lib/glossarist/schema_migration/v0_to_v1.rb', line 17

def to_version
  @to_version
end

Instance Method Details

#migrateObject



28
29
30
31
32
33
34
35
36
# File 'lib/glossarist/schema_migration/v0_to_v1.rb', line 28

def migrate
  case [from_version, to_version]
  when ["0", "1"] then migrate_v0_to_v1
  else
    raise Errors::Base,
          "Unsupported migration: #{from_version} -> #{to_version}"
  end
  @concept
end