gmaps_geocoding 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e0eb2ba63ab2f125d3002741bcb198fe93d5f880
4
- data.tar.gz: df00924a0a27c88b2976db2f03d09611aa8b6190
3
+ metadata.gz: 57722991dd7d3928d47cac69f2551e04a7a563d6
4
+ data.tar.gz: ac94b52d5d0f2e33816b64ac7e25c916e00eb502
5
5
  SHA512:
6
- metadata.gz: 79a5ff100b66ecb148e30babe4a8003e09746603a225ffcdb0b0bae4481e23171d76f7e3336503922ccf69e26d041df618b387f4f76ba27e3686dcf57a13e1d2
7
- data.tar.gz: 1bcb5295f1e08aac1a9778b998cddadb1f2c3c4cc191e92ba28848b06f3267cb41c86105a371307cc215544bbc3add7ec99740620edb589f00ca62b94d9b90b3
6
+ metadata.gz: a9c6d51376ae4bb6969c7a4f85e69f624194b3b6a497f7267fc68a7a908c3e122370f068a6693ebd5015e8db602b56b37d8f6debc85cbcde31c8bfffc5b4a429
7
+ data.tar.gz: 767a0276c82863de68110a33aa05c87302d12f36bb230193873983044d133bfc31fa23aac138676673667d63683af035211fdc0f75d47a09eec27e3d5b76d57a
data/Rakefile CHANGED
@@ -31,7 +31,7 @@ end
31
31
 
32
32
  desc 'Generate documentation'
33
33
  YARD::Rake::YardocTask.new do |t|
34
- t.files = ['lib/**/*.rb', '-', 'LICENSE.txt']
34
+ t.files = ['lib/**/*.rb', '-', 'LICENSE.txt']
35
35
  t.options = ['--main', 'README.md', '--no-private']
36
36
  end
37
37
 
@@ -4,21 +4,21 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'gmaps_geocoding/version'
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = 'gmaps_geocoding'
8
- s.version = GmapsGeocoding::VERSION
9
- s.authors = ['Christian Kakesa']
10
- s.email = ['christian.kakesa@gmail.com']
11
- s.description = %q{
7
+ s.name = 'gmaps_geocoding'
8
+ s.version = GmapsGeocoding::VERSION
9
+ s.authors = ['Christian Kakesa']
10
+ s.email = ['christian.kakesa@gmail.com']
11
+ s.description = %q{
12
12
  A simple Ruby gem for Google Maps Geocoding API.
13
13
  This gem return a Ruby Hash object of the result.
14
14
  }
15
- s.summary = %q{Use Google Geocoding API from Ruby.}
16
- s.homepage = 'https://github.com/fenicks/gmaps_geocoding'
17
- s.license = 'MIT'
15
+ s.summary = %q{Use Google Geocoding API from Ruby.}
16
+ s.homepage = 'https://github.com/fenicks/gmaps_geocoding'
17
+ s.license = 'MIT'
18
18
 
19
- s.files = `git ls-files`.split($/)
20
- s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
21
- s.test_files = s.files.grep(%r{^(test|spec|features)/})
19
+ s.files = `git ls-files`.split($/)
20
+ s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
21
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
22
22
  s.require_paths = ['lib']
23
23
 
24
24
  s.add_runtime_dependency 'rest-client', '~> 1.6.7'
@@ -68,9 +68,14 @@ module GmapsGeocoding
68
68
  def get_finest_latlng(data_result)
69
69
  tmp_result = {}
70
70
  data = data_result
71
- data.each do |d|
72
- tmp_result["#{d['geometry']['location_type']}"] = {lng: d['geometry']['location']['lng'].to_f,
73
- lat: d['geometry']['location']['lat'].to_f}
71
+ if data.kind_of?(Array)
72
+ data.each do |d|
73
+ tmp_result["#{d['geometry']['location_type']}"] = {lng: d['geometry']['location']['lng'].to_f,
74
+ lat: d['geometry']['location']['lat'].to_f}
75
+ end
76
+ else
77
+ tmp_result["#{data['geometry']['location_type']}"] = {lng: data['geometry']['location']['lng'].to_f,
78
+ lat: data['geometry']['location']['lat'].to_f}
74
79
  end
75
80
  if tmp_result.include?('ROOFTOP')
76
81
  [tmp_result['ROOFTOP'][:lng], tmp_result['ROOFTOP'][:lat]]
@@ -86,13 +91,13 @@ module GmapsGeocoding
86
91
  private
87
92
  def build_url_query
88
93
  query = {}
89
- query[:address] = @config.address if @config.address
90
- query[:latlng] = @config.latlng if @config.latlng
94
+ query[:address] = @config.address if @config.address
95
+ query[:latlng] = @config.latlng if @config.latlng
91
96
  query[:components] = @config.components if @config.components
92
- query[:sensor] = @config.sensor if @config.sensor
93
- query[:bounds] = @config.bounds if @config.bounds
94
- query[:language] = @config.language if @config.language
95
- query[:region] = @config.region if @config.region
97
+ query[:sensor] = @config.sensor if @config.sensor
98
+ query[:bounds] = @config.bounds if @config.bounds
99
+ query[:language] = @config.language if @config.language
100
+ query[:region] = @config.region if @config.region
96
101
  url = "#{@config.url}/#{@config.output}"
97
102
  {url: url, query: query}
98
103
  end
@@ -5,15 +5,15 @@ module GmapsGeocoding
5
5
  class Config
6
6
  def initialize(opts = {})
7
7
  @options = {url: 'https://maps.googleapis.com/maps/api/geocode'}
8
- @options[:output] = ENV['GOOGLE_MAPS_GEOCODING_OUTPUT'] || opts[:output] || 'json'
9
- @options[:address] = ENV['GOOGLE_MAPS_GEOCODING_ADDRESS'] || opts[:address] || ''
10
- @options[:latlng] = ENV['GOOGLE_MAPS_GEOCODING_LATLNG'] || opts[:latlng] || ''
8
+ @options[:output] = ENV['GOOGLE_MAPS_GEOCODING_OUTPUT'] || opts[:output] || 'json'
9
+ @options[:address] = ENV['GOOGLE_MAPS_GEOCODING_ADDRESS'] || opts[:address] || ''
10
+ @options[:latlng] = ENV['GOOGLE_MAPS_GEOCODING_LATLNG'] || opts[:latlng] || ''
11
11
  @options[:components] = ENV['GOOGLE_MAPS_GEOCODING_COMPONENTS'] || opts[:components] || ''
12
- @options[:sensor] = ENV['GOOGLE_MAPS_GEOCODING_SENSOR'] || opts[:sensor] || 'false'
13
- @options[:bounds] = ENV['GOOGLE_MAPS_GEOCODING_BOUNDS'] || opts[:bounds] || ''
14
- @options[:language] = ENV['GOOGLE_MAPS_GEOCODING_LANGUAGE'] || opts[:language] || ''
15
- @options[:region] = ENV['GOOGLE_MAPS_GEOCODING_REGION'] || opts[:region] || ''
16
- @options.merge!(opts).reject!{|_, v| v.to_s.length == 0 }
12
+ @options[:sensor] = ENV['GOOGLE_MAPS_GEOCODING_SENSOR'] || opts[:sensor] || 'false'
13
+ @options[:bounds] = ENV['GOOGLE_MAPS_GEOCODING_BOUNDS'] || opts[:bounds] || ''
14
+ @options[:language] = ENV['GOOGLE_MAPS_GEOCODING_LANGUAGE'] || opts[:language] || ''
15
+ @options[:region] = ENV['GOOGLE_MAPS_GEOCODING_REGION'] || opts[:region] || ''
16
+ @options.merge!(opts).reject! { |_, v| v.to_s.length == 0 }
17
17
  end
18
18
 
19
19
  # URL of the Google Maps Geocoding Service
@@ -46,6 +46,7 @@ module GmapsGeocoding
46
46
  def latlng
47
47
  @options[:latlng]
48
48
  end
49
+
49
50
  # A component filter for which you wish to obtain a geocode
50
51
  #
51
52
  # {https://developers.google.com/maps/documentation/geocoding/#ComponentFiltering}
@@ -1,3 +1,3 @@
1
1
  module GmapsGeocoding
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -16,7 +16,7 @@ class GmapsGeocodingTest < Test::Unit::TestCase
16
16
  assert_equal true, config.valid?
17
17
  end
18
18
 
19
- def test_config_latlng_set
19
+ def test_config_latlng_set
20
20
  config = GmapsGeocoding::Config.new({latlng: '40.714224,-73.961452'})
21
21
  assert_not_nil config
22
22
  assert_equal true, config.valid?
@@ -43,7 +43,7 @@ class GmapsGeocodingTest < Test::Unit::TestCase
43
43
  assert_kind_of Hash, result_location
44
44
  assert_include result_location, 'results'
45
45
 
46
- result_latlng = api.get_finest_latlng(result_location['results'])
46
+ result_latlng = api.get_finest_latlng(result_location['results'])
47
47
  assert_not_nil result_latlng
48
48
  assert_instance_of Array, result_latlng
49
49
  end
@@ -58,7 +58,7 @@ class GmapsGeocodingTest < Test::Unit::TestCase
58
58
  assert_kind_of Hash, result_location
59
59
  assert_include result_location, 'result'
60
60
 
61
- result_latlng = api.get_finest_latlng(result_location['result'])
61
+ result_latlng = api.get_finest_latlng(result_location['result'])
62
62
  assert_not_nil result_latlng
63
63
  assert_instance_of Array, result_latlng
64
64
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gmaps_geocoding
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Kakesa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-03 00:00:00.000000000 Z
11
+ date: 2013-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client