google_maps_geocoder 1.0.0 → 1.0.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
  SHA256:
3
- metadata.gz: 5c568a9b578691865efa5fb3e960924c1d26eb1c6f041f6586897b56fb789ffd
4
- data.tar.gz: 88b05d3af710f1de4fda1377769f69d8f9b0d65a993ec4890dc5ee24998f2d7f
3
+ metadata.gz: a1b75a6d688d7ae2c78598419106c233c97b4e3d3670de878f91cdba8c12d920
4
+ data.tar.gz: 3df70e06f88e78962ca11daf667c2e03057de045883534d8c80eb52cc4119edd
5
5
  SHA512:
6
- metadata.gz: 688f7c22172faa20e5108120a680130a30accbf78a2597e0b2f4af2886e45af917d4c3358f115d7af9a073fea6f01e3e0e3e9cbc7172810ada348ca33597ffa6
7
- data.tar.gz: 206170d5705a87acd41d58a00e230962437d0369fc08ca7b29bb8e26eee09789a71b6ca21eb77dd20302338ed96e052dc271faeaa98090a58d4c4ee063f4ffc0
6
+ metadata.gz: 204f47f4a4b6ee052e21c2f8fb16664dfb0cd7ea69e65b52522842cd0514d68c452209ca17e0a639c7f1acdb2bf817346a700eee6a3667457cd7ab4c047379e9
7
+ data.tar.gz: e2d04e07a9d445f9795a7226be2327b0a29921923ca1471b8cdfa74b1436aca4db9a68315198d3dd228c87c62148e1eeb4d5983197bc8bfbff135dd6be4abd19
checksums.yaml.gz.sig CHANGED
Binary file
@@ -0,0 +1,14 @@
1
+ # These are supported funding model platforms
2
+
3
+ github: ivanoblomov
4
+ patreon: # Replace with a single Patreon username
5
+ open_collective: # Replace with a single Open Collective username
6
+ ko_fi: # Replace with a single Ko-fi username
7
+ tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8
+ community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9
+ liberapay: # Replace with a single Liberapay username
10
+ issuehunt: # Replace with a single IssueHunt username
11
+ lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
12
+ polar: # Replace with a single Polar username
13
+ buy_me_a_coffee: oblomov
14
+ custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
data/.rubocop.yml ADDED
@@ -0,0 +1,7 @@
1
+ require:
2
+ - rubocop-performance
3
+ - rubocop-rake
4
+ - rubocop-rspec
5
+
6
+ AllCops:
7
+ NewCops: enable
data/Gemfile CHANGED
@@ -5,10 +5,11 @@ gemspec
5
5
 
6
6
  gem 'inch', '~> 0.8'
7
7
  gem 'pry', '~> 0.14.1'
8
- gem 'rake', ['>= 12.3.3', '~> 13.0']
8
+ gem 'rake', '~> 13'
9
9
  gem 'rspec', '~> 3'
10
- gem 'rubocop', '< 1.63'
11
- gem 'rubocop-rake', '~> 0'
12
- gem 'rubocop-rspec', '~> 2'
10
+ gem 'rubocop', '< 1.68'
11
+ gem 'rubocop-performance', require: false
12
+ gem 'rubocop-rake', require: false
13
+ gem 'rubocop-rspec', require: false
13
14
  gem 'simplecov', '~> 0.18'
14
15
  gem 'simplecov-lcov', '~> 0.8'
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011-2022 Roderick Monje
1
+ Copyright (c) 2011-2024 Roderick Monje
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -108,10 +108,6 @@ Complete RDoc documentation is available at [RubyDoc.info](https://www.rubydoc.i
108
108
 
109
109
  ## [Contributing to GoogleMapsGeocoder](.github/CONTRIBUTING.md)
110
110
 
111
- ## Cheers!
112
-
113
- <a href="https://www.buymeacoffee.com/oblomov" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-green.png" alt="Buy Me A Coffee" height="41" width="174" ></a>
114
-
115
111
  ## Copyright
116
112
 
117
113
  Copyright © 2011-2024 Roderick Monje. See [LICENSE.txt](LICENSE.txt) for further details.
data/SECURITY.md CHANGED
@@ -6,8 +6,8 @@
6
6
 
7
7
  | Version | Supported |
8
8
  | ------- | ------------------ |
9
- | 1.0.0 | :white_check_mark: |
10
- | < 1.0.0 | :x: |
9
+ | 1.0.1 | :white_check_mark: |
10
+ | < 1.0.1 | :x: |
11
11
 
12
12
  ## Reporting a Vulnerability
13
13
 
@@ -6,18 +6,19 @@ Gem::Specification.new do |s|
6
6
  s.version = GoogleMapsGeocoder::VERSION.dup
7
7
  s.licenses = ['MIT']
8
8
  s.summary = 'A simple PORO wrapper for geocoding with Google Maps.'
9
- s.description = 'Geocode a location without worrying about parsing Google '\
10
- "Maps' response. GoogleMapsGeocoder wraps it in a plain-old "\
9
+ s.description = 'Geocode a location without worrying about parsing Google ' \
10
+ "Maps' response. GoogleMapsGeocoder wraps it in a plain-old " \
11
11
  'Ruby object.'
12
12
  s.homepage = 'https://github.com/FoveaCentral/google_maps_geocoder'
13
13
  s.authors = ['Roderick Monje']
14
14
  s.cert_chain = ['certs/ivanoblomov.pem']
15
15
  s.email = 'rod@foveacentral.com'
16
- s.signing_key = File.expand_path('~/.ssh/gem-private_key.pem') if $PROGRAM_NAME =~ /gem\z/
16
+ s.signing_key = File.expand_path('~/.ssh/gem-private_key.pem') if $PROGRAM_NAME.end_with?('gem')
17
17
 
18
- s.add_runtime_dependency 'rack', '>= 2.1.4', '< 3.1.0'
18
+ s.add_dependency 'rack', '>= 2.1.4', '< 3.2.0'
19
19
 
20
20
  s.files = `git ls-files`.split "\n"
21
21
  s.require_paths = ['lib']
22
22
  s.required_ruby_version = '>= 3.0'
23
+ s.metadata['rubygems_mfa_required'] = 'true'
23
24
  end
@@ -128,15 +128,15 @@ class GoogleMapsGeocoder
128
128
  if (message = @json['error_message'])
129
129
  Logger.new($stderr).error(message)
130
130
  end
131
- super @json
131
+ super(@json)
132
132
  end
133
133
  end
134
134
 
135
135
  private
136
136
 
137
137
  def google_maps_request(address)
138
- "#{GOOGLE_MAPS_API}?address=#{Rack::Utils.escape address}"\
139
- "&key=#{ENV['GOOGLE_MAPS_API_KEY']}"
138
+ "#{GOOGLE_MAPS_API}?address=#{Rack::Utils.escape address}" \
139
+ "&key=#{ENV.fetch('GOOGLE_MAPS_API_KEY', nil)}"
140
140
  end
141
141
 
142
142
  def google_maps_response(address)
@@ -181,8 +181,8 @@ class GoogleMapsGeocoder
181
181
  end
182
182
 
183
183
  def parse_formatted_street_address
184
- "#{parse_address_component_type('street_number')} "\
185
- "#{parse_address_component_type('route')}"
184
+ "#{parse_address_component_type('street_number')} " \
185
+ "#{parse_address_component_type('route')}"
186
186
  end
187
187
 
188
188
  def parse_lat
@@ -207,7 +207,7 @@ class GoogleMapsGeocoder
207
207
 
208
208
  def set_attributes_from_json
209
209
  ALL_ADDRESS_SEGMENTS.each do |segment|
210
- instance_variable_set :"@#{segment}", send("parse_#{segment}")
210
+ instance_variable_set :"@#{segment}", send(:"parse_#{segment}")
211
211
  end
212
212
  end
213
213
  end
@@ -3,5 +3,5 @@
3
3
  # A simple PORO wrapper for geocoding with Google Maps.
4
4
  class GoogleMapsGeocoder
5
5
  # This gem's version.
6
- VERSION = '1.0.0' unless defined?(GoogleMapsGeocoder::VERSION)
6
+ VERSION = '1.0.1' unless defined?(GoogleMapsGeocoder::VERSION)
7
7
  end
@@ -6,68 +6,113 @@ require "#{File.dirname(__FILE__)}/../spec_helper"
6
6
  # rubocop:disable Metrics/BlockLength
7
7
  RSpec.describe GoogleMapsGeocoder do
8
8
  describe '#new' do
9
- context 'with "White House"' do
10
- subject(:geocoder) do
11
- GoogleMapsGeocoder.new('White House')
12
- rescue SocketError
13
- pending 'waiting for a network connection'
14
- rescue GoogleMapsGeocoder::GeocodingError => e
15
- raise if e.json['status'] == 'REQUEST_DENIED'
9
+ context 'when API key is valid' do
10
+ # rubocop:disable RSpec/NestedGroups
11
+ context 'with "White House"' do
12
+ subject(:geocoder) do
13
+ described_class.new('White House')
14
+ rescue SocketError
15
+ pending 'waiting for a network connection'
16
+ rescue GoogleMapsGeocoder::GeocodingError => e
17
+ raise if e.json['status'] == 'REQUEST_DENIED'
16
18
 
17
- pending 'waiting for query limit to pass'
18
- end
19
+ pending 'waiting for query limit to pass'
20
+ end
19
21
 
20
- it { should be_partial_match }
21
- it { should_not be_exact_match }
22
+ it { is_expected.to be_partial_match }
23
+ it { is_expected.not_to be_exact_match }
22
24
 
23
- context 'address' do
24
- it do
25
- expect(geocoder.formatted_street_address)
26
- .to eq '1600 Pennsylvania Avenue Northwest'
25
+ describe '#formatted_street_address' do
26
+ it { expect(geocoder.formatted_street_address).to eq '1600 Pennsylvania Avenue Northwest' }
27
27
  end
28
- it { expect(geocoder.city).to eq 'Washington' }
29
- it { expect(geocoder.state_long_name).to eq 'District of Columbia' }
30
- it { expect(geocoder.state_short_name).to eq 'DC' }
31
- it { expect(geocoder.postal_code).to eq '20500' }
32
- it { expect(geocoder.country_short_name).to eq 'US' }
33
- it { expect(geocoder.country_long_name).to eq 'United States' }
34
- it do
35
- expect(geocoder.formatted_address)
36
- .to match(/1600 Pennsylvania Avenue NW, Washington, DC 20500, USA/)
28
+
29
+ describe '#city' do
30
+ it { expect(geocoder.city).to eq 'Washington' }
37
31
  end
38
- end
39
32
 
40
- context 'coordinates' do
41
- it { expect(geocoder.lat).to be_within(0.005).of(38.8976633) }
42
- it { expect(geocoder.lng).to be_within(0.005).of(-77.0365739) }
43
- end
33
+ describe '#state_long_name' do
34
+ it { expect(geocoder.state_long_name).to eq 'District of Columbia' }
35
+ end
36
+
37
+ describe '#state_short_name' do
38
+ it { expect(geocoder.state_short_name).to eq 'DC' }
39
+ end
40
+
41
+ describe '#postal_code' do
42
+ it { expect(geocoder.postal_code).to eq '20500' }
43
+ end
44
+
45
+ describe '#country_short_name' do
46
+ it { expect(geocoder.country_short_name).to eq 'US' }
47
+ end
48
+
49
+ describe '#country_long_name' do
50
+ it { expect(geocoder.country_long_name).to eq 'United States' }
51
+ end
52
+
53
+ describe '#formatted_address' do
54
+ it { expect(geocoder.formatted_address).to match(/1600 Pennsylvania Avenue NW, Washington, DC 20500, USA/) }
55
+ end
56
+
57
+ describe '#lat' do
58
+ it { expect(geocoder.lat).to be_within(0.005).of(38.8976633) }
59
+ end
44
60
 
45
- context 'Geocoder API' do
46
- it { expect(geocoder.address).to eq subject.formatted_address }
47
- it { expect(geocoder.coordinates).to eq [subject.lat, subject.lng] }
48
- it { expect(geocoder.country).to eq subject.country_long_name }
49
- it { expect(geocoder.country_code).to eq subject.country_short_name }
50
- it { expect(geocoder.latitude).to eq subject.lat }
51
- it { expect(geocoder.longitude).to eq subject.lng }
52
- it { expect(geocoder.state).to eq subject.state_long_name }
53
- it { expect(geocoder.state_code).to eq subject.state_short_name }
61
+ describe '#lng' do
62
+ it { expect(geocoder.lng).to be_within(0.005).of(-77.0365739) }
63
+ end
64
+
65
+ context 'when using Geocoder API' do
66
+ describe '#address' do
67
+ it { expect(geocoder.address).to eq geocoder.formatted_address }
68
+ end
69
+
70
+ describe '#coordinates' do
71
+ it { expect(geocoder.coordinates).to eq [geocoder.lat, geocoder.lng] }
72
+ end
73
+
74
+ describe '#country' do
75
+ it { expect(geocoder.country).to eq geocoder.country_long_name }
76
+ end
77
+
78
+ describe '#country_code' do
79
+ it { expect(geocoder.country_code).to eq geocoder.country_short_name }
80
+ end
81
+
82
+ describe '#latitude' do
83
+ it { expect(geocoder.latitude).to eq geocoder.lat }
84
+ end
85
+
86
+ describe '#longitude' do
87
+ it { expect(geocoder.longitude).to eq geocoder.lng }
88
+ end
89
+
90
+ describe '#state' do
91
+ it { expect(geocoder.state).to eq geocoder.state_long_name }
92
+ end
93
+
94
+ describe '#state_code' do
95
+ it { expect(geocoder.state_code).to eq geocoder.state_short_name }
96
+ end
97
+ end
54
98
  end
99
+ # rubocop:enable RSpec/NestedGroups
55
100
  end
56
101
 
57
102
  context 'when API key is invalid' do
103
+ subject(:geocoder) do
104
+ described_class.new('nowhere that comes to mind')
105
+ rescue SocketError
106
+ pending 'waiting for a network connection'
107
+ end
108
+
58
109
  around do |example|
59
- original_key = ENV['GOOGLE_MAPS_API_KEY']
110
+ original_key = ENV.fetch('GOOGLE_MAPS_API_KEY', nil)
60
111
  ENV['GOOGLE_MAPS_API_KEY'] = 'invalid_key'
61
112
  example.run
62
113
  ENV['GOOGLE_MAPS_API_KEY'] = original_key
63
114
  end
64
115
 
65
- subject(:geocoder) do
66
- GoogleMapsGeocoder.new('nowhere that comes to mind')
67
- rescue SocketError
68
- pending 'waiting for a network connection'
69
- end
70
-
71
116
  it { expect { geocoder }.to raise_error GoogleMapsGeocoder::GeocodingError }
72
117
  end
73
118
  end
data/spec/spec_helper.rb CHANGED
@@ -16,12 +16,12 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
16
16
  require 'google_maps_geocoder/google_maps_geocoder'
17
17
  # silence output
18
18
  RSpec.configure do |config|
19
- config.before(:example) do
19
+ config.before do
20
20
  quiet_logger = Logger.new(IO::NULL)
21
21
  allow(Logger).to receive(:new).and_return(quiet_logger)
22
22
  end
23
23
 
24
- config.after(:example) do
24
+ config.after do
25
25
  allow(Logger).to receive(:new).and_call_original
26
26
  end
27
27
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google_maps_geocoder
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roderick Monje
@@ -35,7 +35,7 @@ cert_chain:
35
35
  UNicoJ8NJMgduyTPvZBJtvUPddQr1yAL66/l+CFewbGb/1DbqfSvA2atfUobhDrG
36
36
  zYKOF/ofPEZhX7sqLK5GzDW4x1QDHAgr1YIdttVxhHADOxF4EVSJCHH0RGw=
37
37
  -----END CERTIFICATE-----
38
- date: 2024-03-29 00:00:00.000000000 Z
38
+ date: 2024-10-31 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: rack
@@ -46,7 +46,7 @@ dependencies:
46
46
  version: 2.1.4
47
47
  - - "<"
48
48
  - !ruby/object:Gem::Version
49
- version: 3.1.0
49
+ version: 3.2.0
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
@@ -56,7 +56,7 @@ dependencies:
56
56
  version: 2.1.4
57
57
  - - "<"
58
58
  - !ruby/object:Gem::Version
59
- version: 3.1.0
59
+ version: 3.2.0
60
60
  description: Geocode a location without worrying about parsing Google Maps' response.
61
61
  GoogleMapsGeocoder wraps it in a plain-old Ruby object.
62
62
  email: rod@foveacentral.com
@@ -66,6 +66,7 @@ extra_rdoc_files: []
66
66
  files:
67
67
  - ".document"
68
68
  - ".github/CONTRIBUTING.md"
69
+ - ".github/FUNDING.yml"
69
70
  - ".github/ISSUE_TEMPLATE/bug-report.md"
70
71
  - ".github/ISSUE_TEMPLATE/feature_request.md"
71
72
  - ".github/ISSUE_TEMPLATE/task.md"
@@ -73,6 +74,7 @@ files:
73
74
  - ".github/dependabot.yml"
74
75
  - ".github/workflows/test.yml"
75
76
  - ".gitignore"
77
+ - ".rubocop.yml"
76
78
  - ".simplecov"
77
79
  - CODE_OF_CONDUCT.md
78
80
  - Gemfile
@@ -89,7 +91,8 @@ files:
89
91
  homepage: https://github.com/FoveaCentral/google_maps_geocoder
90
92
  licenses:
91
93
  - MIT
92
- metadata: {}
94
+ metadata:
95
+ rubygems_mfa_required: 'true'
93
96
  post_install_message:
94
97
  rdoc_options: []
95
98
  require_paths:
metadata.gz.sig CHANGED
Binary file