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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d53021361fb68730a701385ff2abe081177446dfed920d1a2f1cb487ecef69ce
4
- data.tar.gz: c7bdb7c8edec93a21d3f464b2b20a1cc415bdb61934a6623b29c9bc2e27f08b4
3
+ metadata.gz: ec698898f0b80daa9f028be2bda5cc04d106a5d397e8fb3b1ccb856e417cdd49
4
+ data.tar.gz: 13435298fb22243f8fd98bb02e9dc9717c104b0b2f948ac964295d2d0a0fa24d
5
5
  SHA512:
6
- metadata.gz: cb3c3d40bc9eadb66bcacfa4e081f888d16b8d5ee27cea456a8a656315805fb0b5cf4de78cf350eb9251566ba1a29c33dca0da37a66a5e3de42f532706b44662
7
- data.tar.gz: 864af5814cec3565681207b0b8c818f368acc36d411b2459a63a70271684de14a49613c9e0d7bf824b3185474dbcc68e52b013c718715a97b2955a3b252173af
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 do it some updates and I'll be happy if you want to help me
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
- @response_type = response_type
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
- @endereco = {
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
- @request = "#{BASE_URL}/#{cep_entry}/#{response_type}"
46
- params = JSON.parse RestClient.get(@request)
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
 
@@ -2,7 +2,7 @@ module CepBrasil::Random
2
2
  class << self
3
3
 
4
4
  def generate_formated
5
- @cep = rand(1111111..99999999).to_s
5
+ @cep = rand(00000000..19999100).to_s
6
6
  valid_cep = @cep[0..4] + '-' + @cep[5..7]
7
7
  end
8
8
 
@@ -1,3 +1,3 @@
1
1
  module CepBrasil
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cep_brasil
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - LucilioCampos