cep_brasil 0.1.0 → 0.1.1
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 +3 -1
- data/lib/cep_brasil/address/gerar_endereco.rb +11 -6
- data/lib/cep_brasil/random/random.rb +1 -1
- data/lib/cep_brasil/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec698898f0b80daa9f028be2bda5cc04d106a5d397e8fb3b1ccb856e417cdd49
|
4
|
+
data.tar.gz: 13435298fb22243f8fd98bb02e9dc9717c104b0b2f948ac964295d2d0a0fa24d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31bf0c342cbda7ea79928bd88690cb45fc36b0978dd84c6312147a44237501cba8e063c0a1fcd97cfd27b60eee656038e707f407c338945bfec5dc31132e4610
|
7
|
+
data.tar.gz: 99b778536717e34ed1e303c5fa66d26e7b92db049f9fc186f86a48142b8b0c8d3668bc645ed261fd62487c7fae700b733c6201cf8c7942fbff3ebffeb40e9722
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# CepBrasil
|
2
2
|
|
3
|
-
This gem was created to make my applications tests more easy. I will
|
3
|
+
This gem was created to make my applications tests more easy. I will update soon and I'll be happy if you want to help me
|
4
4
|
|
5
5
|
|
6
6
|
## Installation
|
@@ -39,6 +39,8 @@ endereco = CepBrasil::Address::Generate.new('01001001', 'json') #=> "Object"
|
|
39
39
|
endereco.cep #=> "010050-101"
|
40
40
|
endereco.logradouro #=> "Praça da Sé"
|
41
41
|
|
42
|
+
## The random generates not necessarily generates a valid cep, it´s good to use for a tests
|
43
|
+
## The Address object with valid cep build a valid address
|
42
44
|
|
43
45
|
```
|
44
46
|
|
@@ -10,8 +10,7 @@ module CepBrasil
|
|
10
10
|
attr_reader :localidade, :uf, :unidade, :ibge, :gia, :endereco
|
11
11
|
|
12
12
|
def initialize(cep_entry, response_type)
|
13
|
-
|
14
|
-
@cep_entry = cep_entry
|
13
|
+
cep_entry = normalize cep_entry
|
15
14
|
params = connect cep_entry, response_type
|
16
15
|
@cep = params['cep']
|
17
16
|
@logradouro ||= params['logradouro']
|
@@ -26,7 +25,7 @@ module CepBrasil
|
|
26
25
|
end
|
27
26
|
|
28
27
|
def full_address
|
29
|
-
|
28
|
+
endereco = {
|
30
29
|
cep: @cep,
|
31
30
|
logradouro: @logradouro,
|
32
31
|
complemento: @complemento,
|
@@ -39,11 +38,17 @@ module CepBrasil
|
|
39
38
|
}
|
40
39
|
end
|
41
40
|
|
42
|
-
private
|
43
41
|
|
42
|
+
private
|
43
|
+
|
44
44
|
def connect(cep_entry, response_type)
|
45
|
-
|
46
|
-
params =
|
45
|
+
request = "#{BASE_URL}/#{cep_entry}/#{response_type}"
|
46
|
+
params = RestClient.get(request)
|
47
|
+
JSON.parse(params)
|
48
|
+
end
|
49
|
+
|
50
|
+
def normalize(cep)
|
51
|
+
normalcep = cep.gsub('-', '')
|
47
52
|
end
|
48
53
|
|
49
54
|
|
data/lib/cep_brasil/version.rb
CHANGED