ko_region_code_mapper 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ko_region_code_mapper.rb +6 -2
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5ee74e2a09336b67853401c3e518db4a1685bf8cdf740a9e06d135856ecf553b
4
- data.tar.gz: 12c7a61802e0fa166c829eed005cf60cc01398737a4f4e16345f8e99bc357d44
3
+ metadata.gz: 5345df7c3d00a5d4d137caa822efee23654c333d57fa89c7dd32a29ebf57d7b0
4
+ data.tar.gz: ef7eda44cc3ad71fd553e93f020c5cb91b1fb421d22277611019d7273db0233e
5
5
  SHA512:
6
- metadata.gz: '091181051d01abf870ffff0e9e17b2fdf7b74af51299ce416406bc2a12d6e4301000e7793c21788d86ebcee90b92ee43eb634c44b0c4d139f3a9938f2d403740'
7
- data.tar.gz: 1501a7d42998f5913c86209fef2821f25cbcb68cff13fd42c2880b55ba505b099381ab5046c7f2f6ac391ed257fb4bfd0ada7bce029893e952ddf8c59b2fb734
6
+ metadata.gz: f01a45f372330702b57acbd542a6a658c9220f8e1070234e7ea47342ec0162c905e5501cdcc07367dbba9293dbf274ac9f2ed5968e858ee0c71ade525f3d225c
7
+ data.tar.gz: 7ec1c93810e3e060065a142e5a5334d427c295dc808e9379dc70d3f43642727bca4d02736ab35b126e82b9fb12e147c721c4e97e7a039460f4fd291a6d1c5580
@@ -20,11 +20,11 @@ class KoRegionCodeMapper
20
20
 
21
21
  def initialize(opts = { filename: FILE_NAME, include_header: true, index_mapping: DATA_INDEX })
22
22
  if opts != nil && (opts[:filename].empty? || opts[:include_header].nil? || opts[:index_mapping].empty?)
23
- raise ArgumentError.new("[ERROR] Check opts parameter. It should include appropriate 'filename', 'include_header', 'index_mapping'.(given: #{opts})")
23
+ raise ArgumentError.new("Check opts parameter. It should include appropriate 'filename', 'include_header', 'index_mapping'.(given: #{opts})")
24
24
  end
25
25
 
26
26
  if opts[:index_mapping].class != Hash
27
- raise ArgumentError.new("[ERROR] Check opts[:index_mapping]. It should be hash consist of (key, value) presenting (attribute_name, index of column in table)")
27
+ raise ArgumentError.new("Check opts[:index_mapping]. It should be hash consist of (key, value) presenting (attribute_name, index of column in table)")
28
28
  end
29
29
 
30
30
  @index_map = opts[:index_mapping] || DATA_INDEX
@@ -35,11 +35,15 @@ class KoRegionCodeMapper
35
35
  end
36
36
 
37
37
  def find_sigungu_code_by_hcode(hcode)
38
+ raise ArgumentError.new("The required parameter hcode cannot be nil or empty string.") if hcode.nil? || hcode.empty?
38
39
  row = find_by_hcode(hcode).first
40
+ return nil if row.nil?
41
+
39
42
  row[@index_map[:hcategory]]&.slice(0..4)
40
43
  end
41
44
 
42
45
  def find_hcodes_by_sigungu_code(sigungu_code)
46
+ raise ArgumentError.new("The required parameter sigungu_code cannot be nil or empty string.") if sigungu_code.nil? || sigungu_code.empty?
43
47
  row = find_by_sigungu_code(sigungu_code)
44
48
  row.map { |d| d[@index_map[:hcode]].to_s }
45
49
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ko_region_code_mapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aree Oh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-25 00:00:00.000000000 Z
11
+ date: 2019-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: csv