br_db 0.1.0 → 0.1.2
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 +4 -4
- data/README.md +7 -17
- data/app/controllers/{brdb → br_db}/application_controller.rb +1 -1
- data/app/controllers/{brdb → br_db}/import_cities_controller.rb +1 -1
- data/app/controllers/{brdb → br_db}/import_companies_controller.rb +1 -1
- data/app/controllers/{brdb → br_db}/import_countries_controller.rb +1 -1
- data/app/controllers/{brdb → br_db}/import_states_controller.rb +1 -1
- data/app/controllers/{brdb → br_db}/import_zip_codes_controller.rb +1 -1
- data/app/helpers/{brdb → br_db}/application_helper.rb +1 -1
- data/app/jobs/{brdb → br_db}/application_job.rb +1 -1
- data/app/jobs/{brdb → br_db}/load_cities_job.rb +1 -1
- data/app/jobs/{brdb → br_db}/load_companies_job.rb +7 -3
- data/app/jobs/{brdb → br_db}/load_countries_job.rb +1 -1
- data/app/jobs/{brdb → br_db}/load_states_job.rb +1 -1
- data/app/jobs/{brdb → br_db}/load_zip_codes_job.rb +1 -1
- data/app/mailers/{brdb → br_db}/application_mailer.rb +1 -1
- data/app/models/{brdb → br_db}/application_record.rb +1 -1
- data/app/models/{brdb → br_db}/city.rb +1 -1
- data/app/models/{brdb → br_db}/cnae.rb +1 -1
- data/app/models/{brdb → br_db}/company.rb +1 -1
- data/app/models/{brdb → br_db}/country.rb +1 -1
- data/app/models/{brdb → br_db}/state.rb +1 -1
- data/app/models/{brdb → br_db}/zip_code.rb +1 -1
- data/app/views/layouts/{brdb → br_db}/application.html.erb +2 -2
- data/config/routes.rb +1 -1
- data/lib/{brdb → br_db}/engine.rb +2 -2
- data/lib/br_db/version.rb +3 -0
- data/lib/br_db.rb +6 -0
- data/lib/tasks/{brdb_tasks.rake → br_db_tasks.rake} +1 -1
- metadata +64 -42
- data/app/helpers/brdb/import_companies_helper.rb +0 -4
- data/app/helpers/brdb/import_countries_helper.rb +0 -4
- data/app/helpers/brdb/import_states_helper.rb +0 -4
- data/app/helpers/brdb/import_zip_codes_helper.rb +0 -4
- data/app/helpers/brdb/imports_helper.rb +0 -4
- data/lib/brdb/version.rb +0 -3
- data/lib/brdb.rb +0 -6
- /data/app/assets/stylesheets/{brdb → br_db}/application.css +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86073e96ef5b18fa6da7c666333fe552ba54bcd57f262ed6b77b27aa216811a4
|
4
|
+
data.tar.gz: 51de206549c1d95578eb37e07e11cd2faa783014b45f4553d894c3035287ef27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fae57a3eb87e1acab65cbaf0b33f25c211044228c774aff850af89864ced35850eb1c6019b05252cc94d80f085f2ae4c81f0241a5a9e08c0aaa6598cfdc457db
|
7
|
+
data.tar.gz: 5efb7cdbd44042f62dd11d8b1844eeff461ed87052423660247afa17cb57450be026abd34e919d3b42aa24cf1219d74108991d76cca2fd533f702d30008c34f7
|
data/README.md
CHANGED
@@ -1,21 +1,15 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
4
|
-
# Currently importing:
|
5
|
-
|
6
|
-
- [x] ZipCodes (you'll need to buy a key from the [Brazilian Correios](https://www.correios.com.br/educacao-e-cultura/filatelia/compre-seu-selo-aqui/compre-seu-selo-aqui))
|
7
|
-
- [x] Cities
|
8
|
-
- [x] States
|
9
|
-
- [ ] Company Data - (WIP - Importing data from dados.gov.br)
|
1
|
+
# BrDb
|
2
|
+
Downloads and loads Brazilian data into your Ruby on Rails app
|
10
3
|
|
11
4
|
## Usage
|
12
|
-
|
5
|
+
|
6
|
+
We'll have usage instructions in the future
|
13
7
|
|
14
8
|
## Installation
|
15
9
|
Add this line to your application's Gemfile:
|
16
10
|
|
17
11
|
```ruby
|
18
|
-
gem "
|
12
|
+
gem "br_db"
|
19
13
|
```
|
20
14
|
|
21
15
|
And then execute:
|
@@ -25,16 +19,12 @@ $ bundle
|
|
25
19
|
|
26
20
|
Or install it yourself as:
|
27
21
|
```bash
|
28
|
-
$ gem install
|
22
|
+
$ gem install br_db
|
29
23
|
```
|
30
24
|
|
31
25
|
## Contributing
|
32
|
-
Fork, open a PR.
|
33
|
-
|
34
26
|
|
35
|
-
|
36
|
-
- [ ] Finish up company data import
|
37
|
-
- [ ] Add tests
|
27
|
+
Fork the repo, open a PR.
|
38
28
|
|
39
29
|
## License
|
40
30
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -3,12 +3,12 @@ require "down"
|
|
3
3
|
require "csv"
|
4
4
|
require "fileutils"
|
5
5
|
|
6
|
-
module
|
6
|
+
module BrDb
|
7
7
|
class LoadCompaniesJob < ApplicationJob
|
8
8
|
queue_as :default
|
9
9
|
|
10
10
|
BASE_URL = "https://arquivos.receitafederal.gov.br/dados/cnpj/dados_abertos_cnpj/"
|
11
|
-
RESOURCES = [ "Cnaes"
|
11
|
+
RESOURCES = [ "Cnaes" ] # TODO: enable "Estabelecimentos" again
|
12
12
|
DELIMITER = ";"
|
13
13
|
ENCODING = "iso-8859-1:utf-8"
|
14
14
|
QUOTE_CHARS = %w[" | ~ ^ & *]
|
@@ -27,7 +27,7 @@ module Brdb
|
|
27
27
|
def load(prefix)
|
28
28
|
case prefix
|
29
29
|
when "Cnaes"
|
30
|
-
|
30
|
+
load_cnaes
|
31
31
|
when "Estabelecimentos"
|
32
32
|
load_companies
|
33
33
|
end
|
@@ -35,6 +35,7 @@ module Brdb
|
|
35
35
|
|
36
36
|
def download_files(prefix)
|
37
37
|
urls = get_urls(prefix.titleize)
|
38
|
+
puts "Found the following URLs: #{urls}"
|
38
39
|
urls.each_with_index do |url, i|
|
39
40
|
destination = FileUtils.makedirs(Rails.root.join("tmp", prefix))
|
40
41
|
tmp_file_path = destination.join(prefix) + "/#{i}.zip"
|
@@ -129,6 +130,9 @@ module Brdb
|
|
129
130
|
html = resp.body
|
130
131
|
doc = Nokogiri::HTML(html)
|
131
132
|
href = doc.css("tr")[-2].css("a").first["href"]
|
133
|
+
if href.starts_with?("temp")
|
134
|
+
href = doc.css("tr")[-3].css("a").first["href"]
|
135
|
+
end
|
132
136
|
BASE_URL + href
|
133
137
|
end
|
134
138
|
|
@@ -1,13 +1,13 @@
|
|
1
1
|
<!DOCTYPE html>
|
2
2
|
<html>
|
3
3
|
<head>
|
4
|
-
<title>
|
4
|
+
<title>Br db</title>
|
5
5
|
<%= csrf_meta_tags %>
|
6
6
|
<%= csp_meta_tag %>
|
7
7
|
|
8
8
|
<%= yield :head %>
|
9
9
|
|
10
|
-
<%= stylesheet_link_tag "
|
10
|
+
<%= stylesheet_link_tag "br_db/application", media: "all" %>
|
11
11
|
</head>
|
12
12
|
<body>
|
13
13
|
|
data/config/routes.rb
CHANGED
data/lib/br_db.rb
ADDED
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: br_db
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Ulisses Caon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
@@ -16,15 +16,43 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 8.0.
|
19
|
+
version: 8.0.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 8.0.
|
27
|
-
|
26
|
+
version: 8.0.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: down
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.22.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.22.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: httparty
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
description: Download and import Brazilian data into your Ruby on Rails app
|
28
56
|
email:
|
29
57
|
- ulissescaon@gmail.com
|
30
58
|
executables: []
|
@@ -34,34 +62,29 @@ files:
|
|
34
62
|
- MIT-LICENSE
|
35
63
|
- README.md
|
36
64
|
- Rakefile
|
37
|
-
- app/assets/stylesheets/
|
38
|
-
- app/controllers/
|
39
|
-
- app/controllers/
|
40
|
-
- app/controllers/
|
41
|
-
- app/controllers/
|
42
|
-
- app/controllers/
|
43
|
-
- app/controllers/
|
44
|
-
- app/helpers/
|
45
|
-
- app/
|
46
|
-
- app/
|
47
|
-
- app/
|
48
|
-
- app/
|
49
|
-
- app/
|
50
|
-
- app/jobs/
|
51
|
-
- app/
|
52
|
-
- app/
|
53
|
-
- app/
|
54
|
-
- app/
|
55
|
-
- app/
|
56
|
-
- app/
|
57
|
-
- app/models/
|
58
|
-
- app/models/
|
59
|
-
- app/
|
60
|
-
- app/models/brdb/company.rb
|
61
|
-
- app/models/brdb/country.rb
|
62
|
-
- app/models/brdb/state.rb
|
63
|
-
- app/models/brdb/zip_code.rb
|
64
|
-
- app/views/layouts/brdb/application.html.erb
|
65
|
+
- app/assets/stylesheets/br_db/application.css
|
66
|
+
- app/controllers/br_db/application_controller.rb
|
67
|
+
- app/controllers/br_db/import_cities_controller.rb
|
68
|
+
- app/controllers/br_db/import_companies_controller.rb
|
69
|
+
- app/controllers/br_db/import_countries_controller.rb
|
70
|
+
- app/controllers/br_db/import_states_controller.rb
|
71
|
+
- app/controllers/br_db/import_zip_codes_controller.rb
|
72
|
+
- app/helpers/br_db/application_helper.rb
|
73
|
+
- app/jobs/br_db/application_job.rb
|
74
|
+
- app/jobs/br_db/load_cities_job.rb
|
75
|
+
- app/jobs/br_db/load_companies_job.rb
|
76
|
+
- app/jobs/br_db/load_countries_job.rb
|
77
|
+
- app/jobs/br_db/load_states_job.rb
|
78
|
+
- app/jobs/br_db/load_zip_codes_job.rb
|
79
|
+
- app/mailers/br_db/application_mailer.rb
|
80
|
+
- app/models/br_db/application_record.rb
|
81
|
+
- app/models/br_db/city.rb
|
82
|
+
- app/models/br_db/cnae.rb
|
83
|
+
- app/models/br_db/company.rb
|
84
|
+
- app/models/br_db/country.rb
|
85
|
+
- app/models/br_db/state.rb
|
86
|
+
- app/models/br_db/zip_code.rb
|
87
|
+
- app/views/layouts/br_db/application.html.erb
|
65
88
|
- config/routes.rb
|
66
89
|
- db/migrate/20241209190243_create_brdb_countries.rb
|
67
90
|
- db/migrate/20241209190300_create_brdb_states.rb
|
@@ -69,17 +92,16 @@ files:
|
|
69
92
|
- db/migrate/20241209202503_create_brdb_zip_codes.rb
|
70
93
|
- db/migrate/20241210125732_create_brdb_companies.rb
|
71
94
|
- db/migrate/20241210130730_create_brdb_cnaes.rb
|
72
|
-
- lib/
|
73
|
-
- lib/
|
74
|
-
- lib/
|
75
|
-
- lib/tasks/
|
76
|
-
homepage: https://github.com/caonUlisses/
|
95
|
+
- lib/br_db.rb
|
96
|
+
- lib/br_db/engine.rb
|
97
|
+
- lib/br_db/version.rb
|
98
|
+
- lib/tasks/br_db_tasks.rake
|
99
|
+
homepage: https://github.com/caonUlisses/br_db
|
77
100
|
licenses:
|
78
101
|
- MIT
|
79
102
|
metadata:
|
80
|
-
homepage_uri: https://github.com/caonUlisses/
|
81
|
-
source_code_uri: https://github.com/caonUlisses/
|
82
|
-
changelog_uri: https://github.com/caonUlisses/brdb
|
103
|
+
homepage_uri: https://github.com/caonUlisses/br_db
|
104
|
+
source_code_uri: https://github.com/caonUlisses/br_db
|
83
105
|
post_install_message:
|
84
106
|
rdoc_options: []
|
85
107
|
require_paths:
|
@@ -98,5 +120,5 @@ requirements: []
|
|
98
120
|
rubygems_version: 3.5.22
|
99
121
|
signing_key:
|
100
122
|
specification_version: 4
|
101
|
-
summary: A
|
123
|
+
summary: A Rails engine to download and load Brazilian data
|
102
124
|
test_files: []
|
data/lib/brdb/version.rb
DELETED
data/lib/brdb.rb
DELETED
File without changes
|