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 +4 -4
- data/lib/codigo_postal.rb +2 -2
- data/test/test_codigo_postal.rb +3 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 658e9b35e21f110f4956c87016af752bed1e2ece7f1e319b41697c37c0d22f52
|
4
|
+
data.tar.gz: c0c26790305fa4e8290b5267f4c23e14a43b6de0bd95d7903369ced7810611a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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]}"
|
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
|
data/test/test_codigo_postal.rb
CHANGED
@@ -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
|
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.
|
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:
|
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.
|
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
|