via_cep 0.2.4 → 0.2.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/via_cep.rb +1 -0
- data/lib/via_cep/errors/invalid_state_format.rb +11 -0
- data/lib/via_cep/search_by_zipcode.rb +7 -3
- data/lib/via_cep/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90b732c4ac01dc31ba7527b70c3b9fae38fa52b2
|
4
|
+
data.tar.gz: 96a08bd42aa9172fea057472c08b5d207ffdabd7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75192cd19005764d836e21109c9532ffd665d9b820a9a33fb56beac876472703787d3907363b11ed676bd8321432cf7ae5f9f543384f7255d9bed1ba4424e84c
|
7
|
+
data.tar.gz: b9bb07c8bdb56ecbc493cecfaaa87e4c446a67888761c0bca84fb02a052c9ffef476e492eed519ff58403583ee2653224fecced106eede9fc7a3b583e766ddf0
|
data/lib/via_cep.rb
CHANGED
@@ -7,15 +7,19 @@ module ViaCep
|
|
7
7
|
street = ViaCep::Utils.parameterize(street)
|
8
8
|
|
9
9
|
if state.size != 2
|
10
|
-
raise
|
10
|
+
raise ViaCep::Errors::InvalidStateFormat
|
11
11
|
end
|
12
12
|
|
13
|
-
@response = HTTParty.get("#{base_url}/#{state}/#{city}/#{street}/json")
|
13
|
+
@response = HTTParty.get("#{base_url}/#{state}/#{city}/#{street}/json")
|
14
|
+
|
15
|
+
if @response.include?('Bad Request')
|
16
|
+
raise ViaCep::Errors::ZipcodeNotFound
|
17
|
+
end
|
14
18
|
end
|
15
19
|
|
16
20
|
ViaCep::METHODS.each do |method_name, response_method_name|
|
17
21
|
define_method(method_name) do
|
18
|
-
@response[response_method_name]
|
22
|
+
@response.first[response_method_name]
|
19
23
|
end
|
20
24
|
end
|
21
25
|
|
data/lib/via_cep/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: via_cep
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.4
|
4
|
+
version: 0.2.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcelo Barreto
|
@@ -130,6 +130,7 @@ files:
|
|
130
130
|
- bin/zipcode
|
131
131
|
- lib/via_cep.rb
|
132
132
|
- lib/via_cep/address.rb
|
133
|
+
- lib/via_cep/errors/invalid_state_format.rb
|
133
134
|
- lib/via_cep/errors/invalid_zipcode_format.rb
|
134
135
|
- lib/via_cep/errors/zipcode_not_found.rb
|
135
136
|
- lib/via_cep/methods.rb
|