google_maps_geocoder 0.7.5 → 0.7.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: 199a0d174e4d20c3ae3729e928ba4beef461e48aaa173c1e143a23125a2a2ecb
4
- data.tar.gz: 2cec3def39626191c9e2bf7bbf4db038f76f1004b2ace817a92a338e4cb1f89f
3
+ metadata.gz: 7d1c18f4c5759710bc9a36455a4de0a150fabb851e31beae9fe6cf396b3ad2cc
4
+ data.tar.gz: 86d5a31c87200f7fdf715270fbf39ead51eb7d6056d1eeb3670612868c4af02a
5
5
  SHA512:
6
- metadata.gz: 1d97c1f39d866b8fe92c81302bc91ace6ef06a35edda54836ec10a858784a37bb72a840182687f81437a307f29df2c04cbf072c263f12532fe4c20b23f694467
7
- data.tar.gz: 7a8c93b2a0a2dde27abb7678b0a413b1360b2bf855b9cb97176d616e7528b132984f462f3d0d1ee60bf86f0132bd5f7666a81991aea36d28d45ec8a8ae942f61
6
+ metadata.gz: 0ba27450bb6a1dab482a8906a0bbe4bc280e7da8ac07c2406c142b74c224fe9b046678796bc5cc0a5416fb27b890983d2b98cc82bd596193a81fce595fe04d06
7
+ data.tar.gz: 7dc496cac0dbe11303773d45f0119be03c34574d85dd1f0be418dbe2a15da2769ee683b80a751e1527192902b3c8056f75a2b133c203ae1cb50b9c82ddd73286
checksums.yaml.gz.sig CHANGED
Binary file
@@ -1,34 +1,68 @@
1
1
  # How to contribute
2
2
 
3
- ## **New to open-source?**
3
+ ## Background
4
4
 
5
- Try your hand at one of the small tasks ideal for new or casual contributors that are [up-for-grabs](https://github.com/ivanoblomov/google_maps_geocoder/issues?q=is%3Aissue+is%3Aopen+label%3Aup-for-grabs). Welcome to the community!
5
+ ### Branches and pull requests
6
6
 
7
- ## **Did you find a bug?**
7
+ To make a contribution:
8
8
 
9
- 1. **Ensure the bug was not already reported** by searching on GitHub under [Issues](https://github.com/ivanoblomov/google_maps_geocoder/issues).
9
+ 1. create a new branch for a given set of logical changes
10
10
 
11
- 2. If you're unable to find an open issue addressing the problem, [open a new one](https://github.com/ivanoblomov/google_maps_geocoder/issues/new). Be sure to include:
12
- 1. a **title and clear description**
13
- 2. as much **relevant information** as possible
14
- 3. a **code sample** or an **executable test case** demonstrating the expected behavior that is not occurring.
11
+ 2. open a pull request for the main branch
15
12
 
16
- ## **Did you write a patch that fixes a bug or adds a new feature?**
13
+ 3. request a review
14
+ 1. click Reviewers from the main tab of the PR
15
+ 2. select one or more contributors
17
16
 
18
- 1. **Add specs** that either *reproduce the bug* or *cover the new feature*. In the former's case, *make sure it fails without the fix!*
17
+ 4. wait for feedback
19
18
 
20
- 2. **Confirm your last build passes** on your GitHub branch or PR.
19
+ For more information, see GitHub's documentation on [creating branches](https://help.github.com/articles/creating-and-deleting-branches-within-your-repository) and [pull requests](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests).
20
+
21
+ ### How we handle proposals
22
+
23
+ We use GitHub to track proposed changes via its [issue tracker](https://github.com/FoveaCentral/google_maps_geocoder/issues) and [pull requests](https://github.com/FoveaCentral/google_maps_geocoder/pulls). Specific changes are proposed using those mechanisms. Issues are assigned to an individual, who works it, and then marks it complete. If there are questions or objections, the conversation area of that issue or pull request is used to resolve it.
21
24
 
22
- 3. **Update the inline documentation.** Format it with [YARD](http://www.rubydoc.info/gems/yard/file/docs/GettingStarted.md). For example, see [`GoogleMapsGeocoder.new`](https://github.com/ivanoblomov/google_maps_geocoder/blob/github-templates/lib/google_maps_geocoder/google_maps_geocoder.rb#L43-L50).
25
+ ### Two-person review
23
26
 
24
- 4. [Open a pull request](https://github.com/ivanoblomov/google_maps_geocoder/compare) with the patch or feature. Follow the template's directions.
27
+ Our policy is that at least 50% of all proposed modifications will be reviewed before release by a person other than the author, to determine if it is a worthwhile modification and free of known issues which would argue against its inclusion.
25
28
 
26
- ## Developer Certificate of Origin (DCO)
29
+ We achieve this by splitting proposals into two kinds:
30
+
31
+ 1. Low-risk modifications. These modifications are being proposed by people authorized to commit directly, pass all tests, and are unlikely to have problems. These include documentation/text updates and/or updates to existing gems (especially minor updates) where no risks (such as a security risk) have been identified. The project lead can decide whenther any particular modification is low-risk.
32
+
33
+ 2. Other modifications. These other modifications need to be reviewed by someone else or the project lead can decide to accept the modification. Typically this is done by creating a branch and a pull request so that it can be reviewed before accepting it.
34
+
35
+ ### Developer Certificate of Origin (DCO)
27
36
 
28
37
  All contributions (including pull requests) must agree to the [Developer Certificate of Origin (DCO) version 1.1](https://developercertificate.org). This is a developer's certification that he or she has the right to submit the patch for inclusion into the project.
29
38
 
30
39
  Simply submitting a contribution implies this agreement, however, please include a `Signed-off-by` tag in the PR (this tag is a conventional way to confirm that you agree to the DCO).
31
40
 
32
- It's not practical to fix old contributions in git, so if one is forgotten, do not try to fix them. We presume that if someone sometimes used a DCO, a commit without a DCO is an accident and the DCO still applies.
41
+ It's not practical to fix old contributions in git, so if one is forgotten, do not try to fix them. We presume that if someone sometimes used a DCO, a commit without a DCO is an accident and the DCO still applies.
42
+
43
+ ## Types of contributions
44
+
45
+ ### **New to open-source?**
46
+
47
+ Try your hand at one of the small tasks ideal for new or casual contributors that are [up-for-grabs](https://github.com/FoveaCentral/google_maps_geocoder/issues?q=is%3Aissue+is%3Aopen+label%3Aup-for-grabs). Welcome to the community!
48
+
49
+ ### **Did you find a bug?**
50
+
51
+ 1. **Ensure the bug was not already reported** by searching on GitHub under [Issues](https://github.com/FoveaCentral/google_maps_geocoder/issues).
52
+
53
+ 2. If you're unable to find an open issue addressing the problem, [open a new one](https://github.com/FoveaCentral/google_maps_geocoder/issues/new/choose). Be sure to include:
54
+ 1. a **title and clear description**
55
+ 2. as much **relevant information** as possible
56
+ 3. a **code sample** or an **executable test case** demonstrating the expected behavior that is not occurring.
57
+
58
+ ### **Did you write a patch that fixes a bug or adds a new feature?**
59
+
60
+ 1. **Add specs** that either *reproduce the bug* or *cover the new feature*. In the former's case, *make sure it fails without the fix!*
61
+
62
+ 2. **Confirm your last build passes** on your GitHub branch or PR.
63
+
64
+ 3. **Update the inline documentation.** Format it with [YARD](https://www.rubydoc.info/gems/yard/file/docs/GettingStarted.md). For example, see [`GoogleMapsGeocoder.new`](../lib/google_maps_geocoder/google_maps_geocoder.rb).
65
+
66
+ 4. [Open a pull request](https://github.com/FoveaCentral/google_maps_geocoder/compare) with the patch or feature. Follow the template's directions.
33
67
 
34
68
  ## Thanks for contributing!
@@ -1,9 +1,9 @@
1
- Closes: #
1
+ # Closes: #
2
2
 
3
- # Goal
3
+ ## Goal
4
4
  What problem does this pull request solve? This should be close to the goal of the issue this pull request addresses.
5
5
 
6
- # Approach
6
+ ## Approach
7
7
  1. **Describe, in numbered steps, the approach you chose** to solve the above problem.
8
8
  1. This will help code reviewers get oriented quickly.
9
9
  2. It will also document for future maintainers exactly what changed (and why) when this PR was merged.
@@ -9,9 +9,10 @@ jobs:
9
9
  test:
10
10
  environment: staging
11
11
  runs-on: ubuntu-latest
12
+ name: Ruby ${{ matrix.ruby-version }}
12
13
  strategy:
13
14
  matrix:
14
- ruby-version: [2.5, 2.6, 2.7, 3.0]
15
+ ruby-version: [2.5, 2.6, 2.7, '3.0']
15
16
  steps:
16
17
  - name: Checkout code
17
18
  uses: actions/checkout@v2
@@ -19,15 +20,21 @@ jobs:
19
20
  uses: ruby/setup-ruby@v1
20
21
  with:
21
22
  ruby-version: ${{ matrix.ruby-version }}
22
- - name: Install dependencies
23
- run: bundle install
23
+ bundler-cache: true # 'bundle install' and cache
24
24
  - name: Run tests
25
25
  env:
26
26
  GOOGLE_MAPS_API_KEY: ${{ secrets.GOOGLE_MAPS_API_KEY }}
27
27
  run: bundle exec rake
28
- - name: Coveralls
28
+ - name: Send Code Climate coverage
29
+ uses: aktions/codeclimate-test-reporter@v1
30
+ with:
31
+ codeclimate-test-reporter-id: ${{ secrets.CC_TEST_REPORTER_ID }}
32
+ command: after-build --coverage-input-type lcov
33
+ - name: Send Coveralls coverage
29
34
  uses: coverallsapp/github-action@master
30
35
  with:
31
36
  github-token: ${{ secrets.GITHUB_TOKEN }}
32
- - name: Rubocop
33
- run: bundle ex rubocop
37
+ - name: Run RuboCop
38
+ run: bundle exec rubocop
39
+ - name: Run Inch
40
+ run: bundle exec inch --pedantic
data/Gemfile CHANGED
@@ -1,4 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source 'http://rubygems.org'
3
+ source 'https://rubygems.org'
4
4
  gemspec
5
+
6
+ gem 'inch', '~> 0.8'
7
+ gem 'pry', '~> 0.14.1'
8
+ gem 'rake', ['>= 12.3.3', '~> 13.0']
9
+ gem 'rspec', '~> 3'
10
+ gem 'rubocop', '< 1.24'
11
+ gem 'rubocop-rake', '~> 0'
12
+ gem 'rubocop-rspec', '~> 2'
13
+ gem 'simplecov', '~> 0.18'
14
+ gem 'simplecov-lcov', '~> 0.8'
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011-2017 Roderick Monje
1
+ Copyright (c) 2011-2021 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
@@ -1,9 +1,8 @@
1
1
  # GoogleMapsGeocoder
2
2
 
3
- ![Build status](https://github.com/ivanoblomov/google_maps_geocoder/workflows/test/badge.svg)
4
- [![Code Climate](https://codeclimate.com/github/ivanoblomov/google_maps_geocoder.svg)](https://codeclimate.com/github/ivanoblomov/google_maps_geocoder)
5
- [![Coverage Status](https://coveralls.io/repos/github/ivanoblomov/google_maps_geocoder/badge.svg?branch=master)](https://coveralls.io/github/ivanoblomov/google_maps_geocoder?branch=master)
6
- [![Inline docs](https://inch-ci.org/github/Ivanoblomov/google_maps_geocoder.svg?branch=master)](https://inch-ci.org/github/Ivanoblomov/google_maps_geocoder)
3
+ [![Build status](https://github.com/FoveaCentral/google_maps_geocoder/workflows/test/badge.svg)](https://github.com/FoveaCentral/google_maps_geocoder/actions/workflows/test.yml)
4
+ [![Code Climate](https://codeclimate.com/github/FoveaCentral/google_maps_geocoder.svg)](https://codeclimate.com/github/FoveaCentral/google_maps_geocoder)
5
+ [![Coverage Status](https://coveralls.io/repos/github/FoveaCentral/google_maps_geocoder/badge.svg?branch=master)](https://coveralls.io/github/FoveaCentral/google_maps_geocoder?branch=master)
7
6
  [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/92/badge)](https://bestpractices.coreinfrastructure.org/projects/92)
8
7
  [![Gem Version](https://badge.fury.io/rb/google_maps_geocoder.svg)](https://rubygems.org/gems/google_maps_geocoder)
9
8
 
@@ -29,6 +28,15 @@ A simple Plain Old Ruby Object wrapper for geocoding with Google Maps.
29
28
  require './lib/google_maps_geocoder/google_maps_geocoder'
30
29
  ```
31
30
 
31
+ ### Security note
32
+
33
+ `GoogleMapsGeocoder` is cryptographically signed. To insure the gem you install hasn’t been tampered with, add my public key as a trusted certificate and then install:
34
+
35
+ ```sh
36
+ gem cert --add <(curl -Ls https://raw.github.com/FoveaCentral/google_maps_geocoder/master/certs/ivanoblomov.pem)
37
+ gem install google_maps_geocoder -P HighSecurity
38
+ ```
39
+
32
40
  ## Ready to Go in One Step
33
41
 
34
42
  ```ruby
@@ -98,7 +106,7 @@ For compatibility with [Geocoder](https://github.com/alexreisner/geocoder), the
98
106
 
99
107
  Complete RDoc documentation is available at [RubyDoc.info](https://www.rubydoc.info/gems/google_maps_geocoder).
100
108
 
101
- ## [Contributing to GoogleMapsGeocoder](https://github.com/ivanoblomov/google_maps_geocoder/blob/master/.github/CONTRIBUTING.md)
109
+ ## [Contributing to GoogleMapsGeocoder](.github/CONTRIBUTING.md)
102
110
 
103
111
  ## Cheers!
104
112
 
@@ -106,4 +114,4 @@ Complete RDoc documentation is available at [RubyDoc.info](https://www.rubydoc.i
106
114
 
107
115
  ## Copyright
108
116
 
109
- Copyright © 2011-2021 Roderick Monje. See [LICENSE.txt](https://github.com/ivanoblomov/google_maps_geocoder/blob/master/LICENSE.txt) for further details.
117
+ Copyright © 2011-2021 Roderick Monje. See [LICENSE.txt](LICENSE.txt) for further details.
data/SECURITY.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Supported Versions
4
4
 
5
- [Dependabot](https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/about-dependabot-version-updates) automatically [patches known vulnerabilities](https://github.com/ivanoblomov/google_maps_geocoder/pulls?q=is%3Apr+is%3Aclosed+author%3Aapp%2Fdependabot).
5
+ [Dependabot](https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/about-dependabot-version-updates) automatically [patches known vulnerabilities](https://github.com/FoveaCentral/google_maps_geocoder/pulls?q=is%3Apr+is%3Aclosed+author%3Aapp%2Fdependabot).
6
6
 
7
7
  | Version | Supported |
8
8
  | ------- | ------------------ |
@@ -11,6 +11,6 @@
11
11
 
12
12
  ## Reporting a Vulnerability
13
13
 
14
- 1. To report a security vulnerability, [open an issue](https://github.com/ivanoblomov/google_maps_geocoder/issues/new/choose).
14
+ 1. To report a security vulnerability, [open an issue](https://github.com/FoveaCentral/google_maps_geocoder/issues/new/choose).
15
15
  2. Updates are made within 48 hours.
16
16
  3. If the vulnerability is accepted, we'll try to patch it within a week.
@@ -9,28 +9,15 @@ Gem::Specification.new do |s|
9
9
  s.description = 'Geocode a location without worrying about parsing Google '\
10
10
  "Maps' response. GoogleMapsGeocoder wraps it in a plain-old "\
11
11
  'Ruby object.'
12
- s.homepage = 'https://github.com/ivanoblomov/google_maps_geocoder'
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
16
  s.signing_key = File.expand_path('~/.ssh/gem-private_key.pem') if $PROGRAM_NAME =~ /gem\z/
17
17
 
18
- s.add_development_dependency 'codeclimate-test-reporter', '~> 1'
19
- s.add_development_dependency 'rake', '>= 12.3.3', '~> 13.0'
20
- s.add_development_dependency 'rspec', '~> 3'
21
- s.add_development_dependency 'rubocop', '< 1.23'
22
- s.add_development_dependency 'rubocop-rake', '~> 0'
23
- s.add_development_dependency 'rubocop-rspec', '~> 2'
24
- s.add_development_dependency 'simplecov', '~> 0.18'
25
- s.add_development_dependency 'simplecov-lcov', '~> 0.8'
26
-
27
- s.add_runtime_dependency 'activesupport', '>= 4.1.11', '< 7.0'
28
18
  s.add_runtime_dependency 'rack', '>= 2.1.4', '< 2.3.0'
29
19
 
30
- s.files = `git ls-files`.split "\n"
31
- s.test_files = `git ls-files -- {test,spec,features}/*`.split "\n"
32
- s.executables = `git ls-files -- bin/*`.split("\n")
33
- .map { |f| File.basename f }
20
+ s.files = `git ls-files`.split "\n"
34
21
  s.require_paths = ['lib']
35
22
  s.required_ruby_version = '>= 2.5'
36
23
  end
@@ -2,7 +2,7 @@
2
2
  # SPDX-License-Identifier: MIT
3
3
  # frozen_string_literal: true
4
4
 
5
- require 'active_support'
5
+ require 'json'
6
6
  require 'logger'
7
7
  require 'net/http'
8
8
  require 'rack'
@@ -14,16 +14,19 @@ require 'rack'
14
14
  # chez_barack.formatted_address
15
15
  # => "1600 Pennsylvania Avenue Northwest, President's Park,
16
16
  # Washington, DC 20500, USA"
17
+ # rubocop:disable Metrics/ClassLength
17
18
  class GoogleMapsGeocoder
18
19
  GOOGLE_ADDRESS_SEGMENTS = %i[
19
20
  city country_long_name country_short_name county lat lng postal_code
20
21
  state_long_name state_short_name
21
22
  ].freeze
23
+ private_constant :GOOGLE_ADDRESS_SEGMENTS
22
24
  GOOGLE_MAPS_API = 'https://maps.googleapis.com/maps/api/geocode/json'
23
-
25
+ private_constant :GOOGLE_MAPS_API
24
26
  ALL_ADDRESS_SEGMENTS = (
25
27
  GOOGLE_ADDRESS_SEGMENTS + %i[formatted_address formatted_street_address]
26
28
  ).freeze
29
+ private_constant :ALL_ADDRESS_SEGMENTS
27
30
 
28
31
  # Returns the complete formatted address with standardized abbreviations.
29
32
  #
@@ -71,7 +74,7 @@ class GoogleMapsGeocoder
71
74
  @json = address.is_a?(String) ? google_maps_response(address) : address
72
75
  status = @json && @json['status']
73
76
  raise RuntimeError if status == 'OVER_QUERY_LIMIT'
74
- raise GeocodingError, @json if @json.blank? || status != 'OK'
77
+ raise GeocodingError, @json if !@json || @json.empty? || status != 'OK'
75
78
 
76
79
  set_attributes_from_json
77
80
  Logger.new($stderr).info('GoogleMapsGeocoder') do
@@ -139,7 +142,7 @@ class GoogleMapsGeocoder
139
142
  def google_maps_response(address)
140
143
  uri = URI.parse google_maps_request(address)
141
144
  response = http(uri).request(Net::HTTP::Get.new(uri.request_uri))
142
- ActiveSupport::JSON.decode response.body
145
+ JSON.parse response.body
143
146
  end
144
147
 
145
148
  def http(uri)
@@ -208,3 +211,4 @@ class GoogleMapsGeocoder
208
211
  end
209
212
  end
210
213
  end
214
+ # rubocop:enable Metrics/ClassLength
@@ -2,5 +2,6 @@
2
2
 
3
3
  # A simple PORO wrapper for geocoding with Google Maps.
4
4
  class GoogleMapsGeocoder
5
- VERSION = '0.7.5' unless defined?(GoogleMapsGeocoder::VERSION)
5
+ # This gem's version.
6
+ VERSION = '0.7.6' unless defined?(GoogleMapsGeocoder::VERSION)
6
7
  end
@@ -4,74 +4,70 @@
4
4
 
5
5
  require "#{File.dirname(__FILE__)}/../spec_helper"
6
6
  # rubocop:disable Metrics/BlockLength
7
- describe GoogleMapsGeocoder do
8
- before(:all) do
9
- # rubocop:disable Lint/RedundantCopDisableDirective, Style/RedundantBegin
10
- begin
11
- @exact_match = GoogleMapsGeocoder.new('White House')
12
- rescue SocketError
13
- @no_network = true
14
- rescue RuntimeError
15
- @query_limit = true
16
- end
17
- # rubocop:enable Lint/RedundantCopDisableDirective, Style/RedundantBegin
18
- end
19
-
20
- before(:each) do
21
- pending 'waiting for a network connection' if @no_network
22
- pending 'waiting for query limit to pass' if @query_limit
23
- end
24
-
7
+ RSpec.describe GoogleMapsGeocoder do
25
8
  describe '#new' do
26
9
  context 'with "White House"' do
27
- subject { @exact_match }
10
+ subject(:geocoder) do
11
+ GoogleMapsGeocoder.new('White House')
12
+ rescue SocketError
13
+ pending 'waiting for a network connection'
14
+ rescue GoogleMapsGeocoder::GeocodingError
15
+ pending 'waiting for query limit to pass'
16
+ end
28
17
 
29
18
  it { should be_exact_match }
30
19
 
31
20
  context 'address' do
32
21
  it do
33
- expect(subject.formatted_street_address)
22
+ expect(geocoder.formatted_street_address)
34
23
  .to eq '1600 Pennsylvania Avenue Northwest'
35
24
  end
36
- it { expect(subject.city).to eq 'Washington' }
37
- it { expect(subject.state_long_name).to eq 'District of Columbia' }
38
- it { expect(subject.state_short_name).to eq 'DC' }
39
- it { expect(subject.postal_code).to eq '20500' }
40
- it { expect(subject.country_short_name).to eq 'US' }
41
- it { expect(subject.country_long_name).to eq 'United States' }
25
+ it { expect(geocoder.city).to eq 'Washington' }
26
+ it { expect(geocoder.state_long_name).to eq 'District of Columbia' }
27
+ it { expect(geocoder.state_short_name).to eq 'DC' }
28
+ it { expect(geocoder.postal_code).to eq '20500' }
29
+ it { expect(geocoder.country_short_name).to eq 'US' }
30
+ it { expect(geocoder.country_long_name).to eq 'United States' }
42
31
  it do
43
- expect(subject.formatted_address)
32
+ expect(geocoder.formatted_address)
44
33
  .to match(/1600 Pennsylvania Avenue NW, Washington, DC 20500, USA/)
45
34
  end
46
35
  end
36
+
47
37
  context 'coordinates' do
48
- it { expect(subject.lat).to be_within(0.005).of(38.8976633) }
49
- it { expect(subject.lng).to be_within(0.005).of(-77.0365739) }
38
+ it { expect(geocoder.lat).to be_within(0.005).of(38.8976633) }
39
+ it { expect(geocoder.lng).to be_within(0.005).of(-77.0365739) }
50
40
  end
41
+
51
42
  context 'Geocoder API' do
52
- it { expect(subject.address).to eq subject.formatted_address }
53
- it { expect(subject.coordinates).to eq [subject.lat, subject.lng] }
54
- it { expect(subject.country).to eq subject.country_long_name }
55
- it { expect(subject.country_code).to eq subject.country_short_name }
56
- it { expect(subject.latitude).to eq subject.lat }
57
- it { expect(subject.longitude).to eq subject.lng }
58
- it { expect(subject.state).to eq subject.state_long_name }
59
- it { expect(subject.state_code).to eq subject.state_short_name }
43
+ it { expect(geocoder.address).to eq subject.formatted_address }
44
+ it { expect(geocoder.coordinates).to eq [subject.lat, subject.lng] }
45
+ it { expect(geocoder.country).to eq subject.country_long_name }
46
+ it { expect(geocoder.country_code).to eq subject.country_short_name }
47
+ it { expect(geocoder.latitude).to eq subject.lat }
48
+ it { expect(geocoder.longitude).to eq subject.lng }
49
+ it { expect(geocoder.state).to eq subject.state_long_name }
50
+ it { expect(geocoder.state_code).to eq subject.state_short_name }
60
51
  end
61
52
  end
53
+
62
54
  context 'when API key is invalid' do
63
- before do
64
- @key = ENV['GOOGLE_MAPS_API_KEY']
55
+ around do |example|
56
+ original_key = ENV['GOOGLE_MAPS_API_KEY']
65
57
  ENV['GOOGLE_MAPS_API_KEY'] = 'invalid_key'
58
+ example.run
59
+ ENV['GOOGLE_MAPS_API_KEY'] = original_key
66
60
  end
67
61
 
68
- after { ENV['GOOGLE_MAPS_API_KEY'] = @key }
69
-
70
- subject { GoogleMapsGeocoder.new('nowhere that comes to mind') }
62
+ subject(:geocoder) do
63
+ GoogleMapsGeocoder.new('nowhere that comes to mind')
64
+ rescue SocketError
65
+ pending 'waiting for a network connection'
66
+ end
71
67
 
72
68
  it do
73
- expect { subject }.to raise_error GoogleMapsGeocoder::GeocodingError,
74
- 'REQUEST_DENIED'
69
+ expect { geocoder }.to raise_error GoogleMapsGeocoder::GeocodingError,
70
+ 'REQUEST_DENIED'
75
71
  end
76
72
  end
77
73
  end
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'pry'
3
4
  require 'simplecov'
4
5
  require 'rubygems'
5
6
  require 'bundler'
@@ -13,3 +14,14 @@ end
13
14
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
15
  $LOAD_PATH.unshift(File.dirname(__FILE__))
15
16
  require 'google_maps_geocoder/google_maps_geocoder'
17
+ # silence output
18
+ RSpec.configure do |config|
19
+ config.before(:example) do
20
+ quiet_logger = Logger.new(IO::NULL)
21
+ allow(Logger).to receive(:new).and_return(quiet_logger)
22
+ end
23
+
24
+ config.after(:example) do
25
+ allow(Logger).to receive(:new).and_call_original
26
+ end
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: 0.7.5
4
+ version: 0.7.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roderick Monje
@@ -34,146 +34,8 @@ cert_chain:
34
34
  G5iWAeYsmSjJxz7iOZOsx+vPCwMy7j6nWF2CDbaxioGR/hIqNbVBveCCRyjyunD3
35
35
  kvv576EuULmQcLpOKwB3RlxAG7j8JJl4ueqjF+rz7x1lBqEU
36
36
  -----END CERTIFICATE-----
37
- date: 2021-11-15 00:00:00.000000000 Z
37
+ date: 2021-12-08 00:00:00.000000000 Z
38
38
  dependencies:
39
- - !ruby/object:Gem::Dependency
40
- name: codeclimate-test-reporter
41
- requirement: !ruby/object:Gem::Requirement
42
- requirements:
43
- - - "~>"
44
- - !ruby/object:Gem::Version
45
- version: '1'
46
- type: :development
47
- prerelease: false
48
- version_requirements: !ruby/object:Gem::Requirement
49
- requirements:
50
- - - "~>"
51
- - !ruby/object:Gem::Version
52
- version: '1'
53
- - !ruby/object:Gem::Dependency
54
- name: rake
55
- requirement: !ruby/object:Gem::Requirement
56
- requirements:
57
- - - ">="
58
- - !ruby/object:Gem::Version
59
- version: 12.3.3
60
- - - "~>"
61
- - !ruby/object:Gem::Version
62
- version: '13.0'
63
- type: :development
64
- prerelease: false
65
- version_requirements: !ruby/object:Gem::Requirement
66
- requirements:
67
- - - ">="
68
- - !ruby/object:Gem::Version
69
- version: 12.3.3
70
- - - "~>"
71
- - !ruby/object:Gem::Version
72
- version: '13.0'
73
- - !ruby/object:Gem::Dependency
74
- name: rspec
75
- requirement: !ruby/object:Gem::Requirement
76
- requirements:
77
- - - "~>"
78
- - !ruby/object:Gem::Version
79
- version: '3'
80
- type: :development
81
- prerelease: false
82
- version_requirements: !ruby/object:Gem::Requirement
83
- requirements:
84
- - - "~>"
85
- - !ruby/object:Gem::Version
86
- version: '3'
87
- - !ruby/object:Gem::Dependency
88
- name: rubocop
89
- requirement: !ruby/object:Gem::Requirement
90
- requirements:
91
- - - "<"
92
- - !ruby/object:Gem::Version
93
- version: '1.23'
94
- type: :development
95
- prerelease: false
96
- version_requirements: !ruby/object:Gem::Requirement
97
- requirements:
98
- - - "<"
99
- - !ruby/object:Gem::Version
100
- version: '1.23'
101
- - !ruby/object:Gem::Dependency
102
- name: rubocop-rake
103
- requirement: !ruby/object:Gem::Requirement
104
- requirements:
105
- - - "~>"
106
- - !ruby/object:Gem::Version
107
- version: '0'
108
- type: :development
109
- prerelease: false
110
- version_requirements: !ruby/object:Gem::Requirement
111
- requirements:
112
- - - "~>"
113
- - !ruby/object:Gem::Version
114
- version: '0'
115
- - !ruby/object:Gem::Dependency
116
- name: rubocop-rspec
117
- requirement: !ruby/object:Gem::Requirement
118
- requirements:
119
- - - "~>"
120
- - !ruby/object:Gem::Version
121
- version: '2'
122
- type: :development
123
- prerelease: false
124
- version_requirements: !ruby/object:Gem::Requirement
125
- requirements:
126
- - - "~>"
127
- - !ruby/object:Gem::Version
128
- version: '2'
129
- - !ruby/object:Gem::Dependency
130
- name: simplecov
131
- requirement: !ruby/object:Gem::Requirement
132
- requirements:
133
- - - "~>"
134
- - !ruby/object:Gem::Version
135
- version: '0.18'
136
- type: :development
137
- prerelease: false
138
- version_requirements: !ruby/object:Gem::Requirement
139
- requirements:
140
- - - "~>"
141
- - !ruby/object:Gem::Version
142
- version: '0.18'
143
- - !ruby/object:Gem::Dependency
144
- name: simplecov-lcov
145
- requirement: !ruby/object:Gem::Requirement
146
- requirements:
147
- - - "~>"
148
- - !ruby/object:Gem::Version
149
- version: '0.8'
150
- type: :development
151
- prerelease: false
152
- version_requirements: !ruby/object:Gem::Requirement
153
- requirements:
154
- - - "~>"
155
- - !ruby/object:Gem::Version
156
- version: '0.8'
157
- - !ruby/object:Gem::Dependency
158
- name: activesupport
159
- requirement: !ruby/object:Gem::Requirement
160
- requirements:
161
- - - ">="
162
- - !ruby/object:Gem::Version
163
- version: 4.1.11
164
- - - "<"
165
- - !ruby/object:Gem::Version
166
- version: '7.0'
167
- type: :runtime
168
- prerelease: false
169
- version_requirements: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - ">="
172
- - !ruby/object:Gem::Version
173
- version: 4.1.11
174
- - - "<"
175
- - !ruby/object:Gem::Version
176
- version: '7.0'
177
39
  - !ruby/object:Gem::Dependency
178
40
  name: rack
179
41
  requirement: !ruby/object:Gem::Requirement
@@ -208,7 +70,6 @@ files:
208
70
  - ".github/ISSUE_TEMPLATE/task.md"
209
71
  - ".github/PULL_REQUEST_TEMPLATE.md"
210
72
  - ".github/dependabot.yml"
211
- - ".github/workflows/publish.yml"
212
73
  - ".github/workflows/test.yml"
213
74
  - ".gitignore"
214
75
  - ".simplecov"
@@ -224,7 +85,7 @@ files:
224
85
  - lib/google_maps_geocoder/version.rb
225
86
  - spec/lib/google_maps_geocoder_spec.rb
226
87
  - spec/spec_helper.rb
227
- homepage: https://github.com/ivanoblomov/google_maps_geocoder
88
+ homepage: https://github.com/FoveaCentral/google_maps_geocoder
228
89
  licenses:
229
90
  - MIT
230
91
  metadata: {}
@@ -243,10 +104,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
243
104
  - !ruby/object:Gem::Version
244
105
  version: '0'
245
106
  requirements: []
246
- rubygems_version: 3.1.4
107
+ rubygems_version: 3.1.6
247
108
  signing_key:
248
109
  specification_version: 4
249
110
  summary: A simple PORO wrapper for geocoding with Google Maps.
250
- test_files:
251
- - spec/lib/google_maps_geocoder_spec.rb
252
- - spec/spec_helper.rb
111
+ test_files: []
metadata.gz.sig CHANGED
Binary file
@@ -1,24 +0,0 @@
1
- name: publish
2
- on:
3
- workflow_dispatch:
4
- jobs:
5
- build:
6
- name: Build + Publish
7
- runs-on: ubuntu-latest
8
- steps:
9
- - uses: actions/checkout@v2
10
- - name: Set up Ruby 2.7
11
- uses: ruby/setup-ruby@v1
12
- with:
13
- ruby-version: 2.7
14
- - run: bundle install
15
- - name: Publish to RubyGems
16
- env:
17
- GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_API_KEY}}"
18
- run: |
19
- mkdir -p $HOME/.gem
20
- touch $HOME/.gem/credentials
21
- chmod 0600 $HOME/.gem/credentials
22
- printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
23
- gem build *.gemspec
24
- gem push *.gem