pumi 0.20.1 → 0.20.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/pumi/data_source/ncdd.rb +25 -8
- data/lib/pumi/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dda968916deb1a189cdc8d34c36ffba69bd9c431779c09c19b0ce74e51077323
|
4
|
+
data.tar.gz: af0b679d64b9e8cccc4bfe05a70d6f4efdcc58948f7e6284d9c31c5e59fc43fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8764e9cbf4dec86829e938b2563cdc330df382f07d8128bb91105c27f87b8915542779f516aba9f0f56ffaa33c4f0ed7fe8b87e59dab1efabe9e285337fc5963
|
7
|
+
data.tar.gz: e8e93348ebec41b96b552d1256e0668ee3e29a4952cf24bb18d4022e506174710ba5644761f4c1df34261c799ad0ff56e5da8e9a8b7f8a53aa91b1b45c195d22
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [0.20.2](https://github.com/dwilkie/pumi/compare/v0.20.1...v0.20.2) (2023-08-08)
|
4
|
+
|
5
|
+
|
6
|
+
### Bug Fixes
|
7
|
+
|
8
|
+
* NCDD parser ([fa41129](https://github.com/dwilkie/pumi/commit/fa411290c1c120150efdca01a8335ad3ae67add1))
|
9
|
+
|
3
10
|
## [0.20.1](https://github.com/dwilkie/pumi/compare/v0.20.0...v0.20.1) (2023-08-02)
|
4
11
|
|
5
12
|
|
@@ -27,6 +27,14 @@ module Pumi
|
|
27
27
|
"ភូមិ" => AdministrativeUnit.new(en: "Village", km: "ភូមិ", latin: "Phum", code_length: 8, group: "villages")
|
28
28
|
}.freeze
|
29
29
|
|
30
|
+
attr_accessor :existing_data
|
31
|
+
|
32
|
+
def initialize(data_files: default_data_files)
|
33
|
+
@existing_data = data_files.each_with_object({}) do |data_file, result|
|
34
|
+
result[data_file.type] = data_file.read
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
30
38
|
def load_data!(source_dir: "tmp", output_dir: "data")
|
31
39
|
source_files(source_dir).each do |file|
|
32
40
|
parse_source_file(file)
|
@@ -37,6 +45,10 @@ module Pumi
|
|
37
45
|
|
38
46
|
private
|
39
47
|
|
48
|
+
def data
|
49
|
+
@data ||= {}
|
50
|
+
end
|
51
|
+
|
40
52
|
def parse_source_file(file)
|
41
53
|
CSV.read(file, headers: CSV_HEADERS).each do |csv_row|
|
42
54
|
row = build_row(csv_row)
|
@@ -44,14 +56,10 @@ module Pumi
|
|
44
56
|
next unless row.code
|
45
57
|
next if row.administrative_unit.code_length != row.code.length
|
46
58
|
|
47
|
-
|
59
|
+
add_data(row)
|
48
60
|
end
|
49
61
|
end
|
50
62
|
|
51
|
-
def data
|
52
|
-
@data ||= {}
|
53
|
-
end
|
54
|
-
|
55
63
|
def build_row(row)
|
56
64
|
Row.new(
|
57
65
|
code: parse_location_code(row),
|
@@ -69,9 +77,10 @@ module Pumi
|
|
69
77
|
code
|
70
78
|
end
|
71
79
|
|
72
|
-
def
|
80
|
+
def add_data(row)
|
73
81
|
data[row.administrative_unit.group] ||= {}
|
74
|
-
data[row.administrative_unit.group][row.code] = {
|
82
|
+
data[row.administrative_unit.group][row.code] = existing_data.dig(row.administrative_unit.group, row.code) || {}
|
83
|
+
data[row.administrative_unit.group][row.code].merge!(
|
75
84
|
"name" => {
|
76
85
|
"km" => row.name_km,
|
77
86
|
"latin" => row.name_latin
|
@@ -81,7 +90,7 @@ module Pumi
|
|
81
90
|
"latin" => row.administrative_unit.latin,
|
82
91
|
"en" => row.administrative_unit.en
|
83
92
|
}
|
84
|
-
|
93
|
+
)
|
85
94
|
end
|
86
95
|
|
87
96
|
def source_files(source_dir)
|
@@ -95,6 +104,14 @@ module Pumi
|
|
95
104
|
DataFile.new(data_group).write(data.fetch(data_group), data_directory: output_dir)
|
96
105
|
end
|
97
106
|
end
|
107
|
+
|
108
|
+
def default_data_files
|
109
|
+
[
|
110
|
+
DataFile.new(:districts),
|
111
|
+
DataFile.new(:communes),
|
112
|
+
DataFile.new(:villages)
|
113
|
+
]
|
114
|
+
end
|
98
115
|
end
|
99
116
|
end
|
100
117
|
end
|
data/lib/pumi/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pumi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.20.
|
4
|
+
version: 0.20.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Wilkie
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-08-
|
11
|
+
date: 2023-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|