pumi 0.20.1 → 0.21.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build.yml +1 -1
- data/.github/workflows/release.yml +1 -1
- data/.github/workflows/update_data.yml +1 -1
- data/CHANGELOG.md +14 -0
- data/data/villages.yml +2 -2
- 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: fec870afd721f5e9497b0d95e07fa4f8e7763dbc0d1d731d2e8c5cd9b73f8bbf
|
4
|
+
data.tar.gz: f5177a9d88aad3fec18cb5dc689fe703d8fadebc7b299333a53987f45f56d09a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 516e0b65a0ec6f3dc1fd85994e8006bb73f7512057e0830493289c993fcba1a36b99f986568680e95b80c4623ba79ea37adfc66111918b1da6deef0407babbeb
|
7
|
+
data.tar.gz: 2d03b95d0ab96fb4626d508eb549600243c916b4f3504c452f225d976fb21d073fffb6db7c8f78b27885c9e435186255ea72308cde798bd277c8e307122a9415
|
data/.github/workflows/build.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [0.21.0](https://github.com/dwilkie/pumi/compare/v0.20.2...v0.21.0) (2023-10-06)
|
4
|
+
|
5
|
+
|
6
|
+
### Features
|
7
|
+
|
8
|
+
* Update data ([7876bbf](https://github.com/dwilkie/pumi/commit/7876bbfc7ce1ff8ee45819ea5e20a3302cf0cf85))
|
9
|
+
|
10
|
+
## [0.20.2](https://github.com/dwilkie/pumi/compare/v0.20.1...v0.20.2) (2023-08-08)
|
11
|
+
|
12
|
+
|
13
|
+
### Bug Fixes
|
14
|
+
|
15
|
+
* NCDD parser ([fa41129](https://github.com/dwilkie/pumi/commit/fa411290c1c120150efdca01a8335ad3ae67add1))
|
16
|
+
|
3
17
|
## [0.20.1](https://github.com/dwilkie/pumi/compare/v0.20.0...v0.20.1) (2023-08-02)
|
4
18
|
|
5
19
|
|
data/data/villages.yml
CHANGED
@@ -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.
|
4
|
+
version: 0.21.0
|
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-
|
11
|
+
date: 2023-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|