geocord 0.0.2 → 0.0.3
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 +18 -3
- data/lib/geocord.rb +12 -0
- data/lib/geocord/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a853130b3c215ab3391d137fac0d0c8672a4017f
|
4
|
+
data.tar.gz: 86f93cca3df9ae0ef98ce00c0ab386e7acfa7432
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 220d44818821e336ebf416c6acb5c0e509bf4210653d4cfa8d2896351c4dcd3b7c9967a4d5593386bc896509cf835e7e7a348eaff574ea5b6f75aa7378cf009d
|
7
|
+
data.tar.gz: 53245be45d84f7ee60bcf722132202069ab0b4974c04b20314a74fc70eef74b276b2b0e8afca4a480d9f27b417feb53d686d7c82a918fabdfebdd0315f01ad5f
|
data/README.md
CHANGED
@@ -18,7 +18,7 @@ Futuras implementações:
|
|
18
18
|
Version
|
19
19
|
----
|
20
20
|
|
21
|
-
0.
|
21
|
+
0.0.2
|
22
22
|
|
23
23
|
Tech
|
24
24
|
-----------
|
@@ -36,10 +36,25 @@ bundle
|
|
36
36
|
Ou
|
37
37
|
|
38
38
|
$ gem install geocord
|
39
|
+
```
|
40
|
+
|
41
|
+
Examples
|
42
|
+
--------------
|
43
|
+
```sh
|
39
44
|
rails console
|
40
45
|
require 'geocord'
|
41
|
-
address = Geocord.process('
|
42
|
-
|
46
|
+
address = Geocord.process('pituba')
|
47
|
+
=> [{:endereco=>"Pituba - Rio Grande do Norte, Brazil", :latitude=>-5.983333, :longitude=>-35.4166669}, {:endereco=>"Pituba - Bahia, Brazil", :latitude=>-11.6775581, :longitude=>-42.7225256}, {:endereco=>"Pituba - Rio Grande do Norte, Brazil", :latitude=>-6.4960844, :longitude=>-35.0051338}, {:endereco=>"Pituba, Salvador - State of Bahia, Brazil", :latitude=>-13.0025439, :longitude=>-38.4566915}]
|
48
|
+
2.1.2 :012 > address.first[:endereco]
|
49
|
+
=> "Pituba - Rio Grande do Norte, Brazil"
|
50
|
+
address.each do |geo|
|
51
|
+
2.1.2 :005 > puts 'bahia ' if geo[:endereco].include?('Bahia')
|
52
|
+
2.1.2 :006?> end
|
53
|
+
bahia
|
54
|
+
bahia
|
55
|
+
|
56
|
+
Geocord.getCep('40015-040')
|
57
|
+
=> {:cep=>"40015040", :tipo=>nil, :logradouro=>"Frederico Castro Rebello", :bairro=>"Comércio", :cidade=>"Salvador", :estado=>"BA"}
|
43
58
|
```
|
44
59
|
|
45
60
|
License
|
data/lib/geocord.rb
CHANGED
@@ -5,6 +5,7 @@ require 'json'
|
|
5
5
|
|
6
6
|
module Geocord
|
7
7
|
GOOGLEAPIS = 'http://maps.googleapis.com/maps/api/geocode/json?address='
|
8
|
+
CEPAPIS = 'http://correiosapi.apphb.com/cep/'
|
8
9
|
class Cordinate
|
9
10
|
attr_accessor :latitude, :longitude
|
10
11
|
end
|
@@ -25,4 +26,15 @@ module Geocord
|
|
25
26
|
return cordinate
|
26
27
|
end
|
27
28
|
end
|
29
|
+
|
30
|
+
def self.getCep(cep)
|
31
|
+
cep = cep.delete('.').delete('-')
|
32
|
+
uri = URI.encode("#{CEPAPIS}#{cep}")
|
33
|
+
uri = URI.parse(uri)
|
34
|
+
conn = Faraday.new(:url => uri)
|
35
|
+
response = conn.get
|
36
|
+
data = JSON.parse(response.body)
|
37
|
+
return endereco = {:cep => data['cep'], :tipo => data['tipoLogradouro'], :logradouro => data['logradouro'], :bairro => data['bairro'], :cidade => data['cidade'], :estado => data['estado']}
|
38
|
+
end
|
39
|
+
|
28
40
|
end
|
data/lib/geocord/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geocord
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sidnei Pacheco
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|