pumi 0.20.1 → 0.21.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d857da41c2b8a128557b1873beff3d2683d794e551d59dfd61965a9d8b3bc5e5
4
- data.tar.gz: 3d78f6d138a40503ffe9bddeaafb3b7e04c0261f167b9ba10d7c65ceea103a09
3
+ metadata.gz: fec870afd721f5e9497b0d95e07fa4f8e7763dbc0d1d731d2e8c5cd9b73f8bbf
4
+ data.tar.gz: f5177a9d88aad3fec18cb5dc689fe703d8fadebc7b299333a53987f45f56d09a
5
5
  SHA512:
6
- metadata.gz: 24cd42c794943e7bdf7ae09fe04977f58e08e93e99823a93a3e7356f4c9988e106e37cb6526438c24a9b44c6057dd63ed9f9dcb40f8f08a171e617319c6d5943
7
- data.tar.gz: '0107993da6bad77d3233bd4b37f32cdb040d4ddf0327606edb11d1eee8cb1c818c1d0743e76dea1fb6a319cd4a6f03f459c39a964109791c8dfb48ab5406bf0d'
6
+ metadata.gz: 516e0b65a0ec6f3dc1fd85994e8006bb73f7512057e0830493289c993fcba1a36b99f986568680e95b80c4623ba79ea37adfc66111918b1da6deef0407babbeb
7
+ data.tar.gz: 2d03b95d0ab96fb4626d508eb549600243c916b4f3504c452f225d976fb21d073fffb6db7c8f78b27885c9e435186255ea72308cde798bd277c8e307122a9415
@@ -8,7 +8,7 @@ jobs:
8
8
  runs-on: ubuntu-latest
9
9
 
10
10
  steps:
11
- - uses: actions/checkout@v3
11
+ - uses: actions/checkout@v4
12
12
 
13
13
  - name: Set up Ruby
14
14
  uses: ruby/setup-ruby@v1
@@ -16,7 +16,7 @@ jobs:
16
16
  bump-minor-pre-major: true
17
17
  version-file: "lib/pumi/version.rb"
18
18
 
19
- - uses: actions/checkout@v3
19
+ - uses: actions/checkout@v4
20
20
  if: ${{ steps.release.outputs.release_created }}
21
21
 
22
22
  - uses: ruby/setup-ruby@v1
@@ -9,7 +9,7 @@ jobs:
9
9
  runs-on: ubuntu-latest
10
10
 
11
11
  steps:
12
- - uses: actions/checkout@v3
12
+ - uses: actions/checkout@v4
13
13
 
14
14
  - name: Setup Ruby
15
15
  uses: ruby/setup-ruby@v1
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
@@ -3194,8 +3194,8 @@ villages:
3194
3194
  en: Village
3195
3195
  '01060207':
3196
3196
  name:
3197
- km: កន្ទួត
3198
- latin: Kantuot
3197
+ km: ភ្នំកន្ទួត
3198
+ latin: Phnom Kantuot
3199
3199
  administrative_unit:
3200
3200
  km: ភូមិ
3201
3201
  latin: Phum
@@ -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
- write_location(row)
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 write_location(row)
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
@@ -1,3 +1,3 @@
1
1
  module Pumi
2
- VERSION = "0.20.1".freeze
2
+ VERSION = "0.21.0".freeze
3
3
  end
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.1
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-08-02 00:00:00.000000000 Z
11
+ date: 2023-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler