cep-aberto 0.1.4 → 3.0.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 +5 -5
- data/.gitignore +0 -0
- data/LICENSE +0 -0
- data/README.md +6 -8
- data/cep-aberto.gemspec +3 -3
- data/lib/cep-aberto.rb +2 -0
- data/lib/cep_aberto/cep.rb +7 -7
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5720768e1992643533c1cef61bfe05934ae924e5a9a1a77628a668b01f262f00
|
4
|
+
data.tar.gz: 2988ce3066d321e380022e7fe01f2d23177600f359620ed0a803f3493884f085
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77ab0558a4b9a1e157e716092e68416f8334572c9deda70f1a39d8f977304dbaa2f266e350801ef0e54fce2004ba137c1c49332927bb389db9606107dbe12503
|
7
|
+
data.tar.gz: c0b7c76d1fb5fee723ec4c131e6e707bbdaa6f12d072e32595df19ed0a7095466e958a40b1ce00112383a1f3e9a0697db9a7125194620a475dd35dc12a5f910b
|
data/.gitignore
CHANGED
File without changes
|
data/LICENSE
CHANGED
File without changes
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# cep-aberto
|
2
|
-
Ruby Connector for the CEP ABERTO API (www.cepaberto.com)
|
2
|
+
Ruby Connector for the CEP ABERTO API v3 (www.cepaberto.com)
|
3
3
|
|
4
4
|
## Installation
|
5
5
|
Include cep-aberto in Gemfile:
|
@@ -29,15 +29,13 @@ CepAberto::Cep::find("01001000", "1234567890abcdef01234567890abcde")
|
|
29
29
|
This method return a hash with the full address for the zipcode:
|
30
30
|
```ruby
|
31
31
|
=> {"altitude"=>760.0,
|
32
|
-
"bairro"=>"Sé",
|
33
32
|
"cep"=>"01001000",
|
34
33
|
"latitude"=>"-23.5479099981",
|
35
34
|
"longitude"=>"-46.636",
|
36
|
-
"logradouro"=>"
|
37
|
-
"
|
38
|
-
"ddd"=>11,
|
39
|
-
"
|
40
|
-
"estado"=>"SP"}
|
35
|
+
"logradouro"=>"Pra\u00E7a da S\u00E9",
|
36
|
+
"bairro"=>"S\u00E9",
|
37
|
+
"cidade"=>{"ddd"=>11, "ibge"=>"3550308", "nome"=>"S\u00E3o Paulo"},
|
38
|
+
"estado"=>{"sigla"=>"SP"}}
|
41
39
|
```
|
42
40
|
|
43
41
|
### List cities
|
@@ -79,4 +77,4 @@ And the result is:
|
|
79
77
|
|
80
78
|
## Thanks
|
81
79
|
|
82
|
-
Thanks to [CEP Aberto](http://
|
80
|
+
Thanks to [CEP Aberto](http://cepaberto.com)
|
data/cep-aberto.gemspec
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'cep-aberto'
|
3
|
-
s.version = '0.
|
4
|
-
s.date = '
|
5
|
-
s.summary = "Ruby Connector for the CEP ABERTO API (www.cepaberto.com). A token is required to use this gem."
|
3
|
+
s.version = '3.0.0'
|
4
|
+
s.date = '2018-07-16'
|
5
|
+
s.summary = "Ruby Connector for the CEP ABERTO API v3 (www.cepaberto.com). A token is required to use this gem."
|
6
6
|
s.description = s.summary
|
7
7
|
s.authors = ["Jefferson Felix"]
|
8
8
|
s.email = 'jsfelix@gmail.com'
|
data/lib/cep-aberto.rb
CHANGED
data/lib/cep_aberto/cep.rb
CHANGED
@@ -9,8 +9,8 @@ module CepAberto
|
|
9
9
|
require "uri"
|
10
10
|
require "json"
|
11
11
|
|
12
|
-
# CEP Aberto API (
|
13
|
-
@domain = "http://www.cepaberto.com/api/
|
12
|
+
# CEP Aberto API (v3)
|
13
|
+
@domain = "http://www.cepaberto.com/api/v3/"
|
14
14
|
|
15
15
|
# Find an address from a zipcode using the CEP Aberto API. <br />
|
16
16
|
# Params:
|
@@ -19,13 +19,13 @@ module CepAberto
|
|
19
19
|
# Returns a hash with the full address
|
20
20
|
def Cep::find(cep, token)
|
21
21
|
validate_cep(cep)
|
22
|
-
uri = URI("#{@domain}
|
22
|
+
uri = URI("#{@domain}cep")
|
23
23
|
params = {'cep' => cep}
|
24
24
|
address = request_cep(uri, params, token)
|
25
25
|
if(address["logradouro"].is_a?String)
|
26
26
|
address["logradouro"] = address["logradouro"].split(",")[0]
|
27
27
|
end
|
28
|
-
|
28
|
+
address
|
29
29
|
end
|
30
30
|
|
31
31
|
# Returns a list of cities from a given state, including their districts. <br />
|
@@ -34,14 +34,14 @@ module CepAberto
|
|
34
34
|
# +token+:: the user authorization token
|
35
35
|
# Returns an array with all cities from the state
|
36
36
|
def Cep::cities_with_districts(state, token)
|
37
|
-
uri = URI("#{@domain}cities
|
37
|
+
uri = URI("#{@domain}cities")
|
38
38
|
params = {'estado' => state}
|
39
39
|
all_cities = request_cep(uri, params, token)
|
40
40
|
cities_arr = Array.new
|
41
41
|
all_cities.each do |c|
|
42
42
|
cities_arr.push(c["nome"])
|
43
43
|
end
|
44
|
-
|
44
|
+
cities_arr
|
45
45
|
end
|
46
46
|
|
47
47
|
# Returns a list of cities from a given state. This method excludes districts. <br />
|
@@ -55,7 +55,7 @@ module CepAberto
|
|
55
55
|
all_cities.each do |c|
|
56
56
|
cities_arr.push(c) unless c.end_with?(')')
|
57
57
|
end
|
58
|
-
|
58
|
+
cities_arr
|
59
59
|
end
|
60
60
|
|
61
61
|
private
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cep-aberto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jefferson Felix
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description: Ruby Connector for the CEP ABERTO API (www.cepaberto.com). A token
|
14
|
-
required to use this gem.
|
13
|
+
description: Ruby Connector for the CEP ABERTO API v3 (www.cepaberto.com). A token
|
14
|
+
is required to use this gem.
|
15
15
|
email: jsfelix@gmail.com
|
16
16
|
executables: []
|
17
17
|
extensions: []
|
@@ -43,9 +43,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
43
43
|
version: '0'
|
44
44
|
requirements: []
|
45
45
|
rubyforge_project:
|
46
|
-
rubygems_version: 2.
|
46
|
+
rubygems_version: 2.7.7
|
47
47
|
signing_key:
|
48
48
|
specification_version: 4
|
49
|
-
summary: Ruby Connector for the CEP ABERTO API (www.cepaberto.com). A token is
|
50
|
-
to use this gem.
|
49
|
+
summary: Ruby Connector for the CEP ABERTO API v3 (www.cepaberto.com). A token is
|
50
|
+
required to use this gem.
|
51
51
|
test_files: []
|