br_db 0.1.5 → 0.1.7

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: e8fb531505805c373bbcbaabef95f99872853757cb98666c04cdc546579920b2
4
- data.tar.gz: c03197deb88f9ffd123bf53ea1a4ad050d451f6de76308818038d751cd0c8e6c
3
+ metadata.gz: 6942ad4fc50b159b7a566d5e168970754970a29fac7e2e0071198579dfdd94ab
4
+ data.tar.gz: d403ba0ead69338a899c9c1ffd84cfe1d7eedb02c0553a93feff7c825071e8ab
5
5
  SHA512:
6
- metadata.gz: bcb236a17e589635b5c708d907c3392ab5a0c0002d7c16ac7a1556f79eda8c50431dddcb848f292cfc43c74595751f64cc180f392beb83f2743e1a8de65f5a7e
7
- data.tar.gz: e1ba035099811611230ce45b173aa3f3ce6c7826a0d451386ab3c7efe55de90a9c04ea744a9bfbf905b0ff8308963316fb6509c2eb148b39841d0f9deafbeb9d
6
+ metadata.gz: 7d6c905025a37b26ef7947be4a68477c4879c3c14807751397872f3afcfc6d6208aaa6d2fe2b74f5fee580a534ea399ab4ac6f780e88736393fcbe3091c23ead
7
+ data.tar.gz: a8abe7cf404ff7ae324503c1271221a2dbca51162cda34389546b814bbd2a12fe453a9d93c01112fd1c6be2fd54ebad3ac720203a55d4ec4270eedbad225a2b3
@@ -74,9 +74,9 @@ module BrDb
74
74
  city_mapping = get_data_map("log_localidade.txt", 2, 8)
75
75
  neighborhood_mapping = get_data_map("log_bairro.txt", 3, 3)
76
76
 
77
+ zip_codes = []
77
78
  # iterate over the csv files that match the regex pattern
78
79
  Dir.glob(path.join("**", "*.txt")).each do |file_path|
79
- zip_codes = []
80
80
  next unless csv_file_path_regex.match?(file_path)
81
81
  CSV.foreach(file_path, liberal_parsing: true, col_sep: DELIMITER, headers: false, encoding: ENCODING, quote_char: QUOTE_CHARS.shift) do |row|
82
82
  street_name = row[8] + " " + row[5]
@@ -90,8 +90,12 @@ module BrDb
90
90
  zip_code: row[7]
91
91
  }
92
92
  end
93
- ZipCode.insert_all(zip_codes)
93
+ if zip_codes.count % 1000 == 0
94
+ ZipCode.insert_all(zip_codes)
95
+ zip_codes = []
96
+ end
94
97
  end
98
+ ZipCode.insert_all(zip_codes)
95
99
  end
96
100
 
97
101
  def import_city_zip_codes
@@ -1,6 +1,6 @@
1
1
  class CreateBrdbCountries < ActiveRecord::Migration[8.0]
2
2
  def change
3
- create_table :brdb_countries do |t|
3
+ create_table :br_db_countries do |t|
4
4
  t.string :name
5
5
  t.string :iso_2
6
6
  t.string :iso_3
@@ -1,6 +1,6 @@
1
1
  class CreateBrdbStates < ActiveRecord::Migration[8.0]
2
2
  def change
3
- create_table :brdb_states do |t|
3
+ create_table :br_db_states do |t|
4
4
  t.string :name
5
5
  t.string :code
6
6
 
@@ -1,6 +1,6 @@
1
1
  class CreateBrdbCities < ActiveRecord::Migration[8.0]
2
2
  def change
3
- create_table :brdb_cities do |t|
3
+ create_table :br_db_cities do |t|
4
4
  t.string :name
5
5
  t.string :code
6
6
  t.string :state_id, null: false
@@ -1,6 +1,6 @@
1
1
  class CreateBrdbZipCodes < ActiveRecord::Migration[8.0]
2
2
  def change
3
- create_table :brdb_zip_codes do |t|
3
+ create_table :br_db_zip_codes do |t|
4
4
  t.string :zip_code
5
5
  t.string :street_name
6
6
  t.string :street_additional_info
@@ -1,6 +1,6 @@
1
1
  class CreateBrdbCompanies < ActiveRecord::Migration[8.0]
2
2
  def change
3
- create_table :brdb_companies do |t|
3
+ create_table :br_db_companies do |t|
4
4
  t.string :cnpj
5
5
  t.string :name
6
6
  t.string :legal_name
@@ -1,6 +1,6 @@
1
1
  class CreateBrdbCnaes < ActiveRecord::Migration[8.0]
2
2
  def change
3
- create_table :brdb_cnaes do |t|
3
+ create_table :br_db_cnaes do |t|
4
4
  t.string :code
5
5
  t.string :description
6
6
 
data/lib/br_db/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module BrDb
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.7"
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.5
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ulisses Caon