Module: Unlocodes

Defined in:
lib/unlocodes.rb,
lib/unlocodes/data.rb,
lib/unlocodes/entry.rb,
lib/unlocodes/version.rb,
lib/unlocodes/registry.rb,
lib/unlocodes/coordinates.rb,
lib/unlocodes/data/fetcher.rb

Overview

Bundled UN/LOCODE dataset.

locode.jsonld is populated by rake unlocode:fetch and is the source loaded by Unlocodes::Registry.load_default.

Defined Under Namespace

Modules: Data Classes: Coordinates, Entry, Registry

Constant Summary collapse

SOURCE_TAG_PATH =
File.expand_path('unlocodes/data/SOURCE_TAG', __dir__)
VERSION =
'0.3.0'

Class Method Summary collapse

Class Method Details

.data_tagString?

The upstream UNCEFACT vocabulary tag bundled with this gem version (e.g. "2025-1"). Read from lib/unlocodes/data/SOURCE_TAG at runtime. Pure function over a known file location — does not touch any registry.

Returns:

  • (String, nil)


29
30
31
32
33
34
35
# File 'lib/unlocodes.rb', line 29

def self.data_tag
  return @data_tag if defined?(@data_tag)

  @data_tag = File.read(SOURCE_TAG_PATH, encoding: 'UTF-8').strip
rescue Errno::ENOENT
  nil
end