geocord 0.0.1 → 0.0.2

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
  SHA1:
3
- metadata.gz: d5dacdf2590b99fcdcb806bec6288bb195129119
4
- data.tar.gz: 7096a49ca4fe1c7fd318d2a2317ce8ed8c386038
3
+ metadata.gz: 3fc4940e4a14bd3518281922cae53fac1d1eea40
4
+ data.tar.gz: 43d2d119373934e2152c423571976a333dcad125
5
5
  SHA512:
6
- metadata.gz: 53080932ff3cdcfe078b2968fc81b253864271118f1185565d61b6aefa577c39d72251723f4051b970e61f8b1fc71735d19f73967e6db382fd0afceca72860a9
7
- data.tar.gz: bb1374a4a22b11ba6e62cd8d2db681a462bfe0e25969f789e9d2d0b148a28431ef890ce37259cc3b84eb2abf6c4d7c9df840bd69ff8137eee2f44d21d72ded31
6
+ metadata.gz: a3089ff0000a8cbfceb3bee2b907853a5c4c861801776e2b2f612373a30668f7d300301a54e9086407ee5d126925beaeec3db4fd5fa8800c945998e717594181
7
+ data.tar.gz: b483cfdfce9ecc6e3f4eafdc0375a5689298fc82d24d93ee705ea23dafc8610d42c62122abcfe4da215b3b249d77524b07e11317bf2f50f9f08ca27e41f0c874
data/README.md CHANGED
@@ -1,29 +1,56 @@
1
- # Geocord
1
+ GeoCord
2
+ =========
2
3
 
3
- TODO: Write a gem description
4
+ Gem para retornar a latitude e Longitude de acordo com o endereço.
5
+
6
+ - Facil utilização.
7
+ - Versão de teste.
8
+ - Contribua.
4
9
 
5
- ## Installation
10
+ Futuras implementações:
6
11
 
7
- Add this line to your application's Gemfile:
12
+ - Retornar todas as geolocalizações encontradas em um array.
13
+ - Retornar endereço de latitude e longitude
14
+ - Evoluir testes.
15
+ > Contribua...
8
16
 
9
- gem 'geocord'
10
17
 
11
- And then execute:
18
+ Version
19
+ ----
12
20
 
13
- $ bundle
21
+ 0.1
14
22
 
15
- Or install it yourself as:
23
+ Tech
24
+ -----------
16
25
 
17
- $ gem install geocord
26
+ GoogleAPI
18
27
 
19
- ## Usage
28
+ Installation
29
+ --------------
20
30
 
21
- TODO: Write usage instructions here
31
+ ```sh
32
+ gem 'geocord'
22
33
 
23
- ## Contributing
34
+ bundle
35
+
36
+ Ou
37
+
38
+ $ gem install geocord
39
+ rails console
40
+ require 'geocord'
41
+ address = Geocord.process('Rua Adolfo Gordo, Brasil')
42
+ address.latitude => -5.8219534
43
+ ```
44
+
45
+ License
46
+ ----
47
+
48
+ MIT
49
+
50
+ **Free Software, Hell Yeah!**
51
+
52
+
53
+ Contributors
54
+ --------------
55
+ [Sidnei Pacheco](https://github.com/sidneip)
24
56
 
25
- 1. Fork it ( https://github.com/[my-github-username]/geocord/fork )
26
- 2. Create your feature branch (`git checkout -b my-new-feature`)
27
- 3. Commit your changes (`git commit -am 'Add some feature'`)
28
- 4. Push to the branch (`git push origin my-new-feature`)
29
- 5. Create a new Pull Request
@@ -4,22 +4,24 @@ require 'uri'
4
4
  require 'json'
5
5
 
6
6
  module Geocord
7
+ GOOGLEAPIS = 'http://maps.googleapis.com/maps/api/geocode/json?address='
7
8
  class Cordinate
8
9
  attr_accessor :latitude, :longitude
9
10
  end
10
11
 
11
12
  def self.process(address)
12
- uri = URI.encode("http://maps.googleapis.com/maps/api/geocode/json?address=#{address}&sensor=false")
13
+ uri = URI.encode("#{GOOGLEAPIS}#{address}&sensor=false")
13
14
  uri = URI.parse(uri)
14
15
  conn = Faraday.new(:url => uri)
15
16
  response = conn.get
16
17
  data = JSON.parse(response.body)
17
18
  if data['results'].size < 1
18
- return "Cordinates not found"
19
+ return nil
19
20
  else
20
- cordinate = Cordinate.new
21
- cordinate.latitude = data['results'][0]['geometry']['location']['lat']
22
- cordinate.longitude = data['results'][0]['geometry']['location']['lng']
21
+ cordinate = Array.new
22
+ data['results'].each_with_index do |cord, index|
23
+ cordinate[index] = {:endereco => cord['formatted_address'], :latitude => cord['geometry']['location']['lat'], :longitude => cord['geometry']['location']['lng']}
24
+ end
23
25
  return cordinate
24
26
  end
25
27
  end
@@ -1,3 +1,3 @@
1
1
  module Geocord
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
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.1
4
+ version: 0.0.2
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-09-17 00:00:00.000000000 Z
11
+ date: 2014-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler