gmaps_geocoding 1.3.5 → 1.3.6

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
  SHA256:
3
- metadata.gz: 9e499b5f5ec59091e8311f8753371fe50fd21f526f3c631403a2e9b3e096711b
4
- data.tar.gz: 654d4c458ff5e4e7c1d736112a863e703eb75ee781854dee98ad7c23a4e84608
3
+ metadata.gz: 879f5c59fb86a9909999a0f8a9062a7485a139a4c5fc506e6872dddce6e5abdd
4
+ data.tar.gz: df9fe796aa6bebc8a0f2a34e1d89962e4a37df839efdb5795cc132b2cd2f233c
5
5
  SHA512:
6
- metadata.gz: fba533f9cc12db5bcd127140a63af9503f98c9a97a3c45df942cbf0e0df4b4dab5a585f8c5e164344f1796099a77ba487a4fa1e73df7cfdb1f8ec491b403228d
7
- data.tar.gz: 1e71af9cd0fa03f5fe3ec543ee4c7a8b74e3e0a9dc1db14699000ebcc963809be6550908341f18314342d3ccd7d8d7b6144b13ea8d04775426d0bf35a30fc488
6
+ metadata.gz: b28adb7b132fc86f5b07e830cfa486e121ac0beb39f34b43b0dcba27975630cf63506301759659433eec2020b411faf20560fe3845becc2f43b513ceec41eaa0
7
+ data.tar.gz: cd082faaf5fa289fe01ba16ec4be23f3b1e63bf62bcabeb5fdc68b1d85e8a5fc773edd56a6f1a685e77fdf62a0c92db42d899e1b5f2bc678875bbb497381efb9
data/.gitignore CHANGED
@@ -16,3 +16,4 @@ spec/reports
16
16
  test/tmp
17
17
  test/version_tmp
18
18
  tmp
19
+ .env
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in gmaps_geocoding.gemspec
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
  require 'rake/testtask'
3
5
  require 'rubocop/rake_task'
@@ -10,7 +12,7 @@ Rake::TestTask.new do |t|
10
12
  t.test_files = FileList['test/**/*_test.rb']
11
13
  t.verbose = true
12
14
  end
13
- task default: [:test, :rubocop]
15
+ task default: %i[test rubocop]
14
16
 
15
17
  RuboCop::RakeTask.new do |task|
16
18
  task.formatters = ['simple']
@@ -19,6 +21,6 @@ end
19
21
 
20
22
  desc 'Generate documentation'
21
23
  YARD::Rake::YardocTask.new do |t|
22
- t.files = %w(lib/**/*.rb - LICENSE.txt)
23
- t.options = %w(--main README.md --no-private)
24
+ t.files = %w[lib/**/*.rb - LICENSE.txt]
25
+ t.options = %w[--main README.md --no-private]
24
26
  end
@@ -1,10 +1,13 @@
1
1
  # coding: utf-8
2
+ # frozen_string_literal: true
3
+
2
4
  require 'English'
3
5
 
4
6
  lib = File.expand_path('../lib', __FILE__)
5
7
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
6
8
  require 'gmaps_geocoding/version'
7
9
 
10
+ # rubocop:disable Metrics/BlockLength
8
11
  Gem::Specification.new do |s|
9
12
  s.name = 'gmaps_geocoding'
10
13
  s.version = GmapsGeocoding::VERSION
@@ -36,4 +39,6 @@ Gem::Specification.new do |s|
36
39
  s.add_development_dependency 'test-unit', '~> 3.0'
37
40
  s.add_development_dependency 'rubocop', '~> 0.49', '>= 0.49.0'
38
41
  s.add_development_dependency 'coveralls', '~> 0'
42
+ s.add_development_dependency 'foreman'
39
43
  end
44
+ # rubocop:enable Metrics/BlockLength
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'logger'
2
4
  require 'ox'
3
5
  require 'oj'
@@ -18,7 +20,7 @@ module GmapsGeocoding
18
20
  @logger = opts.delete(:logger)
19
21
  unless @logger
20
22
  @logger = Logger.new(STDERR) do |l|
21
- l.progname = 'gmaps_geocoding'.freeze
23
+ l.progname = 'gmaps_geocoding'
22
24
  l.level = $DEBUG ? Logger::DEBUG : Logger::INFO
23
25
  end
24
26
  end
@@ -41,7 +43,7 @@ module GmapsGeocoding
41
43
  # result = api.location
42
44
  #
43
45
  def location
44
- fail 'Invalid configuration parameters check the Google Geocoding API documentation'.freeze unless @config.valid?
46
+ raise 'Invalid configuration parameters check the Google Geocoding API documentation' unless @config.valid?
45
47
  rest_client = retrieve_geocoding_data
46
48
  case @config.json_format?
47
49
  when true
@@ -76,9 +78,9 @@ module GmapsGeocoding
76
78
  # rubocop:disable Metrics/AbcSize
77
79
  def finest_latlng(data)
78
80
  result = retrieve_finest_location(data)
79
- return [result['ROOFTOP'][:lng], result['ROOFTOP'][:lat]] if result.include?('ROOFTOP'.freeze)
80
- return [result['RANGE_INTERPOLATED'][:lng], result['RANGE_INTERPOLATED'][:lat]] if result.include?('RANGE_INTERPOLATED'.freeze)
81
- return [result['GEOMETRIC_CENTER'][:lng], result['GEOMETRIC_CENTER'][:lat]] if result.include?('GEOMETRIC_CENTER'.freeze)
81
+ return [result['ROOFTOP'][:lng], result['ROOFTOP'][:lat]] if result.include?('ROOFTOP')
82
+ return [result['RANGE_INTERPOLATED'][:lng], result['RANGE_INTERPOLATED'][:lat]] if result.include?('RANGE_INTERPOLATED')
83
+ return [result['GEOMETRIC_CENTER'][:lng], result['GEOMETRIC_CENTER'][:lat]] if result.include?('GEOMETRIC_CENTER')
82
84
  [result['APPROXIMATE'][:lng], result['APPROXIMATE'][:lat]]
83
85
  rescue
84
86
  [0.0, 0.0].freeze
@@ -119,10 +121,10 @@ module GmapsGeocoding
119
121
  def xml_to_hash(xml_str)
120
122
  xml = Ox.parse(xml_str)
121
123
  r = xml_node_to_ruby(xml)
122
- if r.include?('GeocodeResponse'.freeze)
124
+ if r.include?('GeocodeResponse')
123
125
  r['GeocodeResponse']
124
126
  else
125
- { status: 'UNKNOWN_ERROR'.freeze }
127
+ { status: 'UNKNOWN_ERROR' }
126
128
  end
127
129
  end
128
130
 
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Gmaps geocoding module
2
4
  module GmapsGeocoding
3
5
  # Configuration valid keys
4
- VALID_KEYS = [:url, :output, :key, :address, :latlng, :components, :sensor, :bounds, :language, :region, :place_id, :result_type, :location_type].freeze
6
+ VALID_KEYS = %i[url output key address latlng components sensor bounds language region place_id result_type location_type].freeze
5
7
 
6
8
  # Valid query parameters
7
- VALID_QUERY_PARAMS = VALID_KEYS - [:url, :output].freeze
9
+ VALID_QUERY_PARAMS = VALID_KEYS - %i[url output].freeze
8
10
 
9
11
  # Configuration class for GmapsGeocoding API.
10
12
  class Config
@@ -13,9 +15,9 @@ module GmapsGeocoding
13
15
 
14
16
  # Default configuration values
15
17
  DEFAULT_CONFIG = {
16
- url: 'https://maps.googleapis.com/maps/api/geocode'.freeze,
17
- output: 'json'.freeze,
18
- sensor: 'false'.freeze
18
+ url: 'https://maps.googleapis.com/maps/api/geocode',
19
+ output: 'json',
20
+ sensor: 'false'
19
21
  }.freeze
20
22
 
21
23
  def initialize(opts = {})
@@ -38,14 +40,14 @@ module GmapsGeocoding
38
40
  #
39
41
  # @return [true, false] Return _true_ or _false_
40
42
  def json_format?
41
- 'json'.freeze.eql?(output)
43
+ 'json'.eql?(output)
42
44
  end
43
45
 
44
46
  # Check if the output format of the query is set to _xml_
45
47
  #
46
48
  # @return [true, false] Return _true_ or _false_
47
49
  def xml_format?
48
- 'xml'.freeze.eql?(output)
50
+ 'xml'.eql?(output)
49
51
  end
50
52
 
51
53
  private
@@ -63,7 +65,7 @@ module GmapsGeocoding
63
65
  #
64
66
  # According to the specifications: {https://developers.google.com/maps/documentation/geocoding/#GeocodingResponses}
65
67
  def output_param_valid?
66
- %w(json xml).include?(output)
68
+ %w[json xml].include?(output)
67
69
  end
68
70
  end
69
71
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module GmapsGeocoding
2
- VERSION = '1.3.5'.freeze
4
+ VERSION = '1.3.6'
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'gmaps_geocoding/api'
2
4
  require_relative 'gmaps_geocoding/config'
3
5
  require_relative 'gmaps_geocoding/version'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  require_relative '../lib/gmaps_geocoding'
3
4
  require_relative 'test_helper'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative '../lib/gmaps_geocoding'
2
4
  require_relative 'test_helper'
3
5
 
@@ -16,7 +18,7 @@ class GmapsGeocodingConfigTest < Test::Unit::TestCase
16
18
  config = GmapsGeocoding::Config.new
17
19
  assert_not_nil config
18
20
 
19
- assert_equal true, config.url.size > 0
21
+ assert_equal true, config.url.size.positive?
20
22
  assert_equal 'json', config.output
21
23
  assert_nil config.address
22
24
  end
data/test/test_helper.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'simplecov'
2
4
  require 'coveralls'
3
5
 
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: 1.3.5
4
+ version: 1.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Kakesa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-04 00:00:00.000000000 Z
11
+ date: 2023-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -240,6 +240,20 @@ dependencies:
240
240
  - - "~>"
241
241
  - !ruby/object:Gem::Version
242
242
  version: '0'
243
+ - !ruby/object:Gem::Dependency
244
+ name: foreman
245
+ requirement: !ruby/object:Gem::Requirement
246
+ requirements:
247
+ - - ">="
248
+ - !ruby/object:Gem::Version
249
+ version: '0'
250
+ type: :development
251
+ prerelease: false
252
+ version_requirements: !ruby/object:Gem::Requirement
253
+ requirements:
254
+ - - ">="
255
+ - !ruby/object:Gem::Version
256
+ version: '0'
243
257
  description: |2
244
258
  A simple Ruby gem for Google Maps Geocoding API.
245
259
  This gem returns a Ruby Hash object of the result.