unlocodes 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.adoc +0 -2
- data/lib/unlocodes/version.rb +1 -1
- data/lib/unlocodes.rb +2 -77
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bdcf7832aa82394b568ce5aee3abc73c0ab626de0ad659370d2059a46ff51618
|
|
4
|
+
data.tar.gz: 90d0bd46c6568c49495a28c9fb384b157d84cc51d11b1f122de73c9152a5f29f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: aa8bde8252d008a32300ddea75681b8422fcbb5c042d861083b5836df04e5c1d30bb7e5ba8235d109bad6f043893f22441e51e8f8fb8cc936f0f980ef5732674
|
|
7
|
+
data.tar.gz: c19720ecc1157143488cd397f7fec4aeb956b136f0fb73e1ab58e722258ca190b55603428d64943e98da3cc61e57053f5fb5c3c647e0589dd9f475c274c38f13
|
data/README.adoc
CHANGED
|
@@ -75,8 +75,6 @@ registry = Unlocodes::Registry.load_file('path/to/custom.jsonld')
|
|
|
75
75
|
registry = Unlocodes::Registry.from_entries([Unlocodes::Entry.new(code: 'CNSHA', ...)])
|
|
76
76
|
----
|
|
77
77
|
|
|
78
|
-
NOTE: The module-level shortcuts `Unlocodes.find(...)`, `Unlocodes.where(...)`, etc. still work as of 0.2.0 but emit a deprecation warning and will be removed in 0.3.0. Migrate to holding your own `Registry` instance.
|
|
79
|
-
|
|
80
78
|
=== What's in an Entry
|
|
81
79
|
|
|
82
80
|
Each `Unlocodes::Entry` exposes the fields the JSON-LD vocabulary populates:
|
data/lib/unlocodes/version.rb
CHANGED
data/lib/unlocodes.rb
CHANGED
|
@@ -12,28 +12,19 @@ require_relative 'unlocodes/version'
|
|
|
12
12
|
# https://opensource.unicc.org/un/unece/uncefact/vocab-locode and distributed
|
|
13
13
|
# by this gem as a bundled, offline JSON-LD representation.
|
|
14
14
|
#
|
|
15
|
-
# Each caller
|
|
15
|
+
# Each caller constructs and holds its own {Unlocodes::Registry}:
|
|
16
16
|
#
|
|
17
17
|
# registry = Unlocodes::Registry.load_default
|
|
18
18
|
# registry.find('CNSHA')
|
|
19
19
|
#
|
|
20
|
-
# The module-level `Unlocodes.find` / `Unlocodes.where` / etc. shortcuts are
|
|
21
|
-
# deprecated since 0.2.0 (they rely on a process-wide singleton). They still
|
|
22
|
-
# work today but emit a `Kernel#warn` deprecation and will be removed in
|
|
23
|
-
# 0.3.0.
|
|
24
|
-
#
|
|
25
20
|
# Which edition is bundled? See {.data_tag} (read from
|
|
26
21
|
# `lib/unlocodes/data/SOURCE_TAG`).
|
|
27
22
|
module Unlocodes
|
|
28
|
-
DEPRECATION_SUGGESTION = 'Use Unlocodes::Registry.load_default instead ' \
|
|
29
|
-
'(or construct from a custom data source). ' \
|
|
30
|
-
'Removal targeted for 0.3.0.'
|
|
31
|
-
|
|
32
23
|
SOURCE_TAG_PATH = File.expand_path('unlocodes/data/SOURCE_TAG', __dir__)
|
|
33
24
|
|
|
34
25
|
# The upstream UNCEFACT vocabulary tag bundled with this gem version
|
|
35
26
|
# (e.g. "2025-1"). Read from `lib/unlocodes/data/SOURCE_TAG` at runtime.
|
|
36
|
-
# Pure function over a known file location — does not touch
|
|
27
|
+
# Pure function over a known file location — does not touch any registry.
|
|
37
28
|
# @return [String, nil]
|
|
38
29
|
def self.data_tag
|
|
39
30
|
return @data_tag if defined?(@data_tag)
|
|
@@ -43,72 +34,6 @@ module Unlocodes
|
|
|
43
34
|
nil
|
|
44
35
|
end
|
|
45
36
|
|
|
46
|
-
class << self
|
|
47
|
-
# @deprecated Use `Unlocodes::Registry.load_default` and hold the
|
|
48
|
-
# instance yourself. Removal targeted for 0.3.0.
|
|
49
|
-
def registry
|
|
50
|
-
warn "Unlocodes.registry is deprecated. #{DEPRECATION_SUGGESTION}", category: :deprecated, uplevel: 1
|
|
51
|
-
default_registry
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
# @deprecated Tests that swap the global registry should construct a
|
|
55
|
-
# `Unlocodes::Registry` directly and inject it. Removal targeted for 0.3.0.
|
|
56
|
-
def reset_registry!
|
|
57
|
-
warn "Unlocodes.reset_registry! is deprecated. #{DEPRECATION_SUGGESTION}", category: :deprecated, uplevel: 1
|
|
58
|
-
@registry = nil
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
# @deprecated Forwarded to the global registry; construct your own and
|
|
62
|
-
# call `registry.find(code)`. Removal targeted for 0.3.0.
|
|
63
|
-
def find(code)
|
|
64
|
-
warn "Unlocodes.find is deprecated. #{DEPRECATION_SUGGESTION}", category: :deprecated, uplevel: 1
|
|
65
|
-
default_registry.find(code)
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
# @deprecated Construct your own registry and call `registry.where(filters)`.
|
|
69
|
-
# Removal targeted for 0.3.0.
|
|
70
|
-
def where(filters)
|
|
71
|
-
warn "Unlocodes.where is deprecated. #{DEPRECATION_SUGGESTION}", category: :deprecated, uplevel: 1
|
|
72
|
-
default_registry.where(filters)
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
# @deprecated Construct your own registry and call `registry.each`.
|
|
76
|
-
# Removal targeted for 0.3.0.
|
|
77
|
-
def each(&)
|
|
78
|
-
warn "Unlocodes.each is deprecated. #{DEPRECATION_SUGGESTION}", category: :deprecated, uplevel: 1
|
|
79
|
-
default_registry.each(&)
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
# @deprecated Construct your own registry and call `registry.size`.
|
|
83
|
-
# Removal targeted for 0.3.0.
|
|
84
|
-
def size
|
|
85
|
-
warn "Unlocodes.size is deprecated. #{DEPRECATION_SUGGESTION}", category: :deprecated, uplevel: 1
|
|
86
|
-
default_registry.size
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
# @deprecated Construct your own registry and call `registry.count`.
|
|
90
|
-
# Removal targeted for 0.3.0.
|
|
91
|
-
def count
|
|
92
|
-
warn "Unlocodes.count is deprecated. #{DEPRECATION_SUGGESTION}", category: :deprecated, uplevel: 1
|
|
93
|
-
default_registry.count
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
# @deprecated Construct your own registry and call `registry.countries`.
|
|
97
|
-
# Removal targeted for 0.3.0.
|
|
98
|
-
def countries
|
|
99
|
-
warn "Unlocodes.countries is deprecated. #{DEPRECATION_SUGGESTION}", category: :deprecated, uplevel: 1
|
|
100
|
-
default_registry.countries
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
private
|
|
104
|
-
|
|
105
|
-
# Internal memoised default registry. Used by the deprecated module-level
|
|
106
|
-
# shortcuts. Direct callers should construct their own Registry instead.
|
|
107
|
-
def default_registry
|
|
108
|
-
@default_registry ||= Registry.load_default
|
|
109
|
-
end
|
|
110
|
-
end
|
|
111
|
-
|
|
112
37
|
autoload :Coordinates, 'unlocodes/coordinates'
|
|
113
38
|
autoload :Entry, 'unlocodes/entry'
|
|
114
39
|
autoload :Registry, 'unlocodes/registry'
|