codigo_postal 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d29b9410fcafd6fdd062a01bc0c75dba793485e4ea6207b785ed0d66ca8fba64
4
- data.tar.gz: 847ec9e1977583f0313c0c07a5435b07c62e99afe42afb19730671417e89d9a1
3
+ metadata.gz: 658e9b35e21f110f4956c87016af752bed1e2ece7f1e319b41697c37c0d22f52
4
+ data.tar.gz: c0c26790305fa4e8290b5267f4c23e14a43b6de0bd95d7903369ced7810611a2
5
5
  SHA512:
6
- metadata.gz: 358099ecb11d4d87b04e59c80abeedfc244827f387506c1d44234cc959bf0a17ffc56bd6d263b369a344835e99f82232ac37406ddfcdc198a57cdf93579abead
7
- data.tar.gz: 5d541f5d847cf286fdebbc5feb90fb4ec2197134a5a47f52365e5b0da06abc399cacd9ecc79b5d3fec256ac95f147e36ab2dc7662fc4177c26487b7b8353fc0e
6
+ metadata.gz: 8c09400332fd46a8e092eb82100b72ee341e426b0782e2680ecc1b06c6a2b202f0cefff24d28f3ead731fca30d1ed234b4a19400a7d6dfbfc80e624747c9ff18
7
+ data.tar.gz: f6b3a185f564cd4b1b8e3cb406c89d7321b088eb6d5c08f9e36aeb8c13deca8bb9041824047b3bb8891e6108813dbe410f9cfcc1055091ad4f2dc74b0b711183
data/lib/codigo_postal.rb CHANGED
@@ -36,7 +36,7 @@ class CodigoPostal
36
36
  def initialize(cep)
37
37
  cep_fields = match_cep cep.to_s.strip
38
38
  if !cep_fields.nil?
39
- @cep_digits = "#{cep_fields[0]}#{cep_fields[1]}#{cep_fields[2]}".to_i
39
+ @cep_digits = "#{cep_fields[0].rjust(2, '0')}#{cep_fields[1]}#{cep_fields[2]}"
40
40
  @cep_formatted = "#{cep_fields[0].rjust(2, '0')}#{cep_fields[1]}-#{cep_fields[2]}"
41
41
  state = find_state_by_cep
42
42
  @state_code = state[:code]
@@ -47,7 +47,7 @@ class CodigoPostal
47
47
  def find_state_by_cep
48
48
  @cep_digits
49
49
  CEP_RANGES.sort_by { |range| range[:range_end] }.each do |cep_range|
50
- return cep_range if @cep_digits <= cep_range[:range_end]
50
+ return cep_range if @cep_digits.to_i <= cep_range[:range_end]
51
51
  end
52
52
  nil
53
53
  end
@@ -62,21 +62,21 @@ end
62
62
  rio_pardo = CodigoPostal.new('13.720-000')
63
63
  assert_equal 'SP', rio_pardo.state_code
64
64
  assert_equal '13720-000', rio_pardo.cep_formatted
65
- assert_equal 13720000, rio_pardo.cep_digits
65
+ assert_equal '13720000', rio_pardo.cep_digits
66
66
  end
67
67
 
68
68
  def test_floripa
69
69
  floripa = CodigoPostal.new('88.063-500')
70
70
  assert_equal 'SC', floripa.state_code
71
71
  assert_equal '88063-500', floripa.cep_formatted
72
- assert_equal 88063500, floripa.cep_digits
72
+ assert_equal '88063500', floripa.cep_digits
73
73
  end
74
74
 
75
75
  def test_catedral
76
76
  catedral = CodigoPostal.new(1001000)
77
77
  assert_equal 'SP', catedral.state_code
78
78
  assert_equal '01001-000', catedral.cep_formatted
79
- assert_equal 1001000, catedral.cep_digits
79
+ assert_equal '01001000', catedral.cep_digits
80
80
  end
81
81
 
82
82
  def test_ibirapuera
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codigo_postal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felipe Mesquita
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-28 00:00:00.000000000 Z
11
+ date: 2024-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -52,7 +52,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
52
52
  - !ruby/object:Gem::Version
53
53
  version: '0'
54
54
  requirements: []
55
- rubygems_version: 3.4.13
55
+ rubygems_version: 3.4.10
56
56
  signing_key:
57
57
  specification_version: 4
58
58
  summary: An offline gem to find Brazilian states by postal code