br_db 0.1.10 → 0.1.11

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: 7dd54dd60526af2f78f09d1f23caf6cf0d310b50e098977298ff616b49a3ede9
4
- data.tar.gz: 7a6dd6e32168b91faed65248f9531e4c2414a5c40d2dbf6640774f6e1347c0aa
3
+ metadata.gz: 2797923ff79f789a373c8e61927de2ce2250affca3c6e31ec3ca9255aa94b156
4
+ data.tar.gz: 89d651b3e1c87a3be3a3d8305228bc9459d1174264e4a5e0bc01d67ad60c8896
5
5
  SHA512:
6
- metadata.gz: 3cdbd69b0f47f9d0db2b9ad205de047c4cd9fb8822bfc2344e09c12ce3f23cf5667982b6fc597b3eb131c67faeed7a5848f01141f390bfc6009dac641489b86b
7
- data.tar.gz: b2feb4231b9d67353f9104fd4eb3caeaf320f5eaf98ecd94b8b51d6439d6051eb942251513e7e733b086c0829ee03c6f4c86b309650b1e4582f6c8fc323a43a0
6
+ metadata.gz: d30e38217c0d47d2d11feb94d644fbbaae7463efd0da21d854650bffc348e809e8abdcd7b53a5e381fce0f79e0109c19804dd60f5c7ad8ecd028097629540ab0
7
+ data.tar.gz: 371a0bd1c16356b7c003b147b75ce1683feac24cf3e15b99dbf8a8810ffb026eea8f992a2f45a56621bb7b267b4c077ce526f737715dcb61e86b0ad371ccf090
@@ -68,36 +68,34 @@ module BrDb
68
68
  end
69
69
 
70
70
  def import_zip_codes
71
- Rails.application.reloader.wrap do
72
- # The file name is log_logradouro_SC.txt or log_logradouro_SP.txt
73
- csv_file_path_regex = /log_logradouro_(\w\w).txt/
74
- path = DELIMITADO_FILE_PATH
75
- city_mapping = get_data_map("log_localidade.txt", 2, 8)
76
- neighborhood_mapping = get_data_map("log_bairro.txt", 3, 3)
77
-
78
- zip_codes = []
79
- # iterate over the csv files that match the regex pattern
80
- Dir.glob(path.join("**", "*.txt")).each do |file_path|
81
- next unless csv_file_path_regex.match?(file_path)
82
- CSV.foreach(file_path, liberal_parsing: true, col_sep: DELIMITER, headers: false, encoding: ENCODING, quote_char: QUOTE_CHARS.shift) do |row|
83
- street_name = row[8] + " " + row[5]
84
- zip_codes << {
85
- state_code: row[1],
86
- neighborhood_name: neighborhood_mapping[row[3]],
87
- street_name: street_name,
88
- city_name: city_mapping[row[2]][0],
89
- city_code: city_mapping[row[2]][1],
90
- street_additional_info: row[6],
91
- zip_code: row[7]
92
- }
93
- end
94
- if zip_codes.count % 1_000 == 0
95
- ZipCode.insert_all(zip_codes)
96
- zip_codes = []
97
- end
71
+ # The file name is log_logradouro_SC.txt or log_logradouro_SP.txt
72
+ csv_file_path_regex = /log_logradouro_(\w\w).txt/
73
+ path = DELIMITADO_FILE_PATH
74
+ city_mapping = get_data_map("log_localidade.txt", 2, 8)
75
+ neighborhood_mapping = get_data_map("log_bairro.txt", 3, 3)
76
+
77
+ zip_codes = []
78
+ # iterate over the csv files that match the regex pattern
79
+ Dir.glob(path.join("**", "*.txt")).each do |file_path|
80
+ next unless csv_file_path_regex.match?(file_path)
81
+ CSV.foreach(file_path, liberal_parsing: true, col_sep: DELIMITER, headers: false, encoding: ENCODING, quote_char: QUOTE_CHARS.shift) do |row|
82
+ street_name = row[8] + " " + row[5]
83
+ zip_codes << {
84
+ state_code: row[1],
85
+ neighborhood_name: neighborhood_mapping[row[3]][0],
86
+ street_name: street_name,
87
+ city_name: city_mapping[row[2]][0],
88
+ city_code: city_mapping[row[2]][1],
89
+ street_additional_info: row[6],
90
+ zip_code: row[7]
91
+ }
92
+ end
93
+ if zip_codes.count % 1_000 == 0
94
+ ZipCode.insert_all(zip_codes)
95
+ zip_codes = []
98
96
  end
99
- ZipCode.insert_all(zip_codes)
100
97
  end
98
+ ZipCode.insert_all(zip_codes)
101
99
  end
102
100
 
103
101
  def import_city_zip_codes
data/lib/br_db/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module BrDb
2
- VERSION = "0.1.10"
2
+ VERSION = "0.1.11"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: br_db
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ulisses Caon