google_maps_geocoder 1.0.1 → 1.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
  SHA256:
3
- metadata.gz: a1b75a6d688d7ae2c78598419106c233c97b4e3d3670de878f91cdba8c12d920
4
- data.tar.gz: 3df70e06f88e78962ca11daf667c2e03057de045883534d8c80eb52cc4119edd
3
+ metadata.gz: 04d445c8366e6292e9ec6648c7481d2dc7f3552591042d700d561fced7c14173
4
+ data.tar.gz: 14653cc8574c36ee32aacb19f5134396143966f2f57baa13bb60be48c01da5eb
5
5
  SHA512:
6
- metadata.gz: 204f47f4a4b6ee052e21c2f8fb16664dfb0cd7ea69e65b52522842cd0514d68c452209ca17e0a639c7f1acdb2bf817346a700eee6a3667457cd7ab4c047379e9
7
- data.tar.gz: e2d04e07a9d445f9795a7226be2327b0a29921923ca1471b8cdfa74b1436aca4db9a68315198d3dd228c87c62148e1eeb4d5983197bc8bfbff135dd6be4abd19
6
+ metadata.gz: 15e9e5ca1822fdb62de2a8092f9e7bf9929dd75531fa1de73579ffa2c9266c246f9ba04b9dbdc69c8f9cb959e473b029fd30c6de0120ef5a46c55e414cb0f9f2
7
+ data.tar.gz: 746640c71ad9e4dd518c5196d66b32236f31456e42ac010e037b477b730fa24c562f996b011b377a148c5382f4f50bb875d4b402dcebb02c86bed7e9f7b679a5
checksums.yaml.gz.sig CHANGED
Binary file
@@ -14,7 +14,7 @@ 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
+ # rubocop:disable-next Metrics/ClassLength
18
18
  class GoogleMapsGeocoder
19
19
  GOOGLE_ADDRESS_SEGMENTS = %i[
20
20
  city country_long_name country_short_name county lat lng postal_code
@@ -28,7 +28,7 @@ class GoogleMapsGeocoder
28
28
  ).freeze
29
29
  private_constant :ALL_ADDRESS_SEGMENTS
30
30
 
31
- # Returns the complete formatted address with standardized abbreviations.
31
+ # The complete formatted address with standardized abbreviations.
32
32
  #
33
33
  # @return [String] the complete formatted address
34
34
  # @example
@@ -37,52 +37,134 @@ class GoogleMapsGeocoder
37
37
  # Washington, DC 20500, USA"
38
38
  attr_reader :formatted_address
39
39
 
40
- # Returns the formatted street address with standardized abbreviations.
40
+ # The formatted street address with standardized abbreviations.
41
41
  #
42
42
  # @return [String] the formatted street address
43
43
  # @example
44
44
  # chez_barack.formatted_street_address
45
45
  # => "1600 Pennsylvania Avenue Northwest"
46
46
  attr_reader :formatted_street_address
47
- # Self-explanatory
47
+
48
+ # The address' city.
49
+ #
50
+ # @return [String] city
51
+ # @example
52
+ # chez_barack.city
53
+ # => "Washington"
54
+ # :attr_reader: city
55
+
56
+ # The address' country as a full string.
57
+ #
58
+ # @return [String] country
59
+ # @example
60
+ # chez_barack.country_long_name
61
+ # => "United States"
62
+ # :attr_reader: country_long_name
63
+
64
+ # The address' country as an abbreviated string.
65
+ #
66
+ # @return [String] country
67
+ # @example
68
+ # chez_barack.country_short_name
69
+ # => "US"
70
+ # :attr_reader: country_short_name
71
+
72
+ # The address' county.
73
+ #
74
+ # @return [String] county
75
+ # @example
76
+ # chez_barack.county
77
+ # => nil
78
+ # :attr_reader: county
79
+
80
+ # The address' latitude as a float.
81
+ #
82
+ # @return [Float] latitude
83
+ # @example
84
+ # chez_barack.lat
85
+ # => 38.8976763
86
+ # :attr_reader: lat
87
+
88
+ # The address' longitude as a float.
89
+ #
90
+ # @return [Float] longitude
91
+ # @example
92
+ # chez_barack.lng
93
+ # => -77.0365298
94
+ # :attr_reader: lng
95
+
96
+ # The address' postal code.
97
+ #
98
+ # @return [String] postal code
99
+ # @example
100
+ # chez_barack.postal_code
101
+ # => "20500"
102
+ # :attr_reader: postal_code
103
+
104
+ # The address' state as a full string.
105
+ #
106
+ # @return [String] state
107
+ # @example
108
+ # chez_barack.state_long_name
109
+ # => "District of Columbia"
110
+ # :attr_reader: state_long_name
111
+
112
+ # The address' state as an abbreviated string.
113
+ #
114
+ # @return [String] state
115
+ # @example
116
+ # chez_barack.state_short_name
117
+ # => "DC"
118
+ # :attr_reader: state_short_name
48
119
  attr_reader(*GOOGLE_ADDRESS_SEGMENTS)
49
120
 
50
- # Returns the formatted address as a comma-delimited string.
121
+ # The formatted address as a comma-delimited string.
122
+ # @return [String] the complete formatted address
51
123
  alias address formatted_address
52
- # Returns the address' country as a full string.
124
+ # The address' country as a full string.
125
+ # @return [String] country
53
126
  alias country country_long_name
54
- # Returns the address' country as an abbreviated string.
127
+ # The address' country as an abbreviated string.
128
+ # @return [String] country
55
129
  alias country_code country_short_name
56
- # Returns the address' latitude as a float.
130
+ # The address' latitude as a float.
131
+ # @return [Float] latitude
57
132
  alias latitude lat
58
- # Returns the address' longitude as a float.
133
+ # The address' longitude as a float.
134
+ # @return [Float] longitude
59
135
  alias longitude lng
60
- # Returns the address' state as a full string.
136
+ # The address' state as a full string.
137
+ # @return [String] state
61
138
  alias state state_long_name
62
- # Returns the address' state as an abbreviated string.
139
+ # The address' state as an abbreviated string.
140
+ # @return [String] state
63
141
  alias state_code state_short_name
64
142
 
65
143
  # Geocodes the specified address and wraps the results in a GoogleMapsGeocoder
66
144
  # object.
67
145
  #
68
- # @param address [String] a geocodable address
146
+ # @param [String] address a geocodable address
147
+ # @param [Logger] logger a standard Logger, defaults to standard error
69
148
  # @return [GoogleMapsGeocoder] the Google Maps result for the specified
70
149
  # address
71
150
  # @example
72
151
  # chez_barack = GoogleMapsGeocoder.new '1600 Pennsylvania DC'
73
- def initialize(address)
152
+ def initialize(address, logger: Logger.new($stderr))
74
153
  @json = address.is_a?(String) ? google_maps_response(address) : address
75
154
  status = @json && @json['status']
76
155
  raise RuntimeError if status == 'OVER_QUERY_LIMIT'
77
- raise GeocodingError, @json if !@json || @json.empty? || status != 'OK'
156
+ raise GeocodingError.new(@json, logger:) if !@json || @json.empty? || status != 'OK'
78
157
 
79
158
  set_attributes_from_json
80
- Logger.new($stderr).info('GoogleMapsGeocoder') do
81
- "Geocoded \"#{address}\" => \"#{formatted_address}\""
82
- end
159
+ logger.info('GoogleMapsGeocoder') { "Geocoded \"#{address}\" => \"#{formatted_address}\"" }
83
160
  end
84
161
 
85
162
  # Returns the address' coordinates as an array of floats.
163
+ #
164
+ # @return [Array] the latitude and longitude in an array
165
+ # @example
166
+ # chez_barack.coordinates
167
+ # => [38.8975862, -77.0366871]
86
168
  def coordinates
87
169
  [lat, lng]
88
170
  end
@@ -108,7 +190,7 @@ class GoogleMapsGeocoder
108
190
  end
109
191
 
110
192
  # A geocoding error returned by Google Maps.
111
- class GeocodingError < StandardError
193
+ class GeocodingError < RuntimeError
112
194
  # Returns the complete JSON response from Google Maps as a Hash.
113
195
  #
114
196
  # @return [Hash] Google Maps' JSON response
@@ -121,12 +203,13 @@ class GoogleMapsGeocoder
121
203
 
122
204
  # Initialize a GeocodingError wrapping the JSON returned by Google Maps.
123
205
  #
124
- # @param json [Hash] Google Maps' JSON response
206
+ # @param [Hash] json Google Maps' JSON response
207
+ # @param [Logger] logger a standard Logger
125
208
  # @return [GeocodingError] the geocoding error
126
- def initialize(json = {})
209
+ def initialize(json = {}, logger:)
127
210
  @json = json
128
211
  if (message = @json['error_message'])
129
- Logger.new($stderr).error(message)
212
+ logger.error "GeocodingError.new: #{message}"
130
213
  end
131
214
  super(@json)
132
215
  end
@@ -211,4 +294,3 @@ class GoogleMapsGeocoder
211
294
  end
212
295
  end
213
296
  end
214
- # rubocop:enable Metrics/ClassLength
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,41 +1,40 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google_maps_geocoder
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roderick Monje
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain:
11
10
  - |
12
11
  -----BEGIN CERTIFICATE-----
13
12
  MIIEeDCCAuCgAwIBAgIBATANBgkqhkiG9w0BAQsFADBBMQwwCgYDVQQDDANyb2Qx
14
13
  HDAaBgoJkiaJk/IsZAEZFgxmb3ZlYWNlbnRyYWwxEzARBgoJkiaJk/IsZAEZFgNj
15
- b20wHhcNMjQwMzI5MjIzNDUxWhcNMjUwMzI5MjIzNDUxWjBBMQwwCgYDVQQDDANy
14
+ b20wHhcNMjYxMTE2MjIxOTEyWhcNMjcxMTE2MjIxOTEyWjBBMQwwCgYDVQQDDANy
16
15
  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
- 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
- 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
- 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
- 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
- f4AzxKPmxsYbtgJHiu38gYb2IMh5JE5B0dUQ5pnQJbdTNtHI9YWoVpyIhIj/aOwN
22
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
37
36
  -----END CERTIFICATE-----
38
- date: 2024-10-31 00:00:00.000000000 Z
37
+ date: 1980-01-02 00:00:00.000000000 Z
39
38
  dependencies:
40
39
  - !ruby/object:Gem::Dependency
41
40
  name: rack
@@ -43,20 +42,14 @@ dependencies:
43
42
  requirements:
44
43
  - - ">="
45
44
  - !ruby/object:Gem::Version
46
- version: 2.1.4
47
- - - "<"
48
- - !ruby/object:Gem::Version
49
- version: 3.2.0
45
+ version: '0'
50
46
  type: :runtime
51
47
  prerelease: false
52
48
  version_requirements: !ruby/object:Gem::Requirement
53
49
  requirements:
54
50
  - - ">="
55
51
  - !ruby/object:Gem::Version
56
- version: 2.1.4
57
- - - "<"
58
- - !ruby/object:Gem::Version
59
- version: 3.2.0
52
+ version: '0'
60
53
  description: Geocode a location without worrying about parsing Google Maps' response.
61
54
  GoogleMapsGeocoder wraps it in a plain-old Ruby object.
62
55
  email: rod@foveacentral.com
@@ -64,36 +57,12 @@ executables: []
64
57
  extensions: []
65
58
  extra_rdoc_files: []
66
59
  files:
67
- - ".document"
68
- - ".github/CONTRIBUTING.md"
69
- - ".github/FUNDING.yml"
70
- - ".github/ISSUE_TEMPLATE/bug-report.md"
71
- - ".github/ISSUE_TEMPLATE/feature_request.md"
72
- - ".github/ISSUE_TEMPLATE/task.md"
73
- - ".github/PULL_REQUEST_TEMPLATE.md"
74
- - ".github/dependabot.yml"
75
- - ".github/workflows/test.yml"
76
- - ".gitignore"
77
- - ".rubocop.yml"
78
- - ".simplecov"
79
- - CODE_OF_CONDUCT.md
80
- - Gemfile
81
- - LICENSE.txt
82
- - README.md
83
- - Rakefile
84
- - SECURITY.md
85
- - certs/ivanoblomov.pem
86
- - google_maps_geocoder.gemspec
87
- - lib/google_maps_geocoder/google_maps_geocoder.rb
88
- - lib/google_maps_geocoder/version.rb
89
- - spec/lib/google_maps_geocoder_spec.rb
90
- - spec/spec_helper.rb
60
+ - lib/google_maps_geocoder.rb
91
61
  homepage: https://github.com/FoveaCentral/google_maps_geocoder
92
62
  licenses:
93
63
  - MIT
94
64
  metadata:
95
65
  rubygems_mfa_required: 'true'
96
- post_install_message:
97
66
  rdoc_options: []
98
67
  require_paths:
99
68
  - lib
@@ -101,15 +70,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
101
70
  requirements:
102
71
  - - ">="
103
72
  - !ruby/object:Gem::Version
104
- version: '3.0'
73
+ version: '3.1'
105
74
  required_rubygems_version: !ruby/object:Gem::Requirement
106
75
  requirements:
107
76
  - - ">="
108
77
  - !ruby/object:Gem::Version
109
78
  version: '0'
110
79
  requirements: []
111
- rubygems_version: 3.5.6
112
- signing_key:
80
+ rubygems_version: 4.0.6
113
81
  specification_version: 4
114
82
  summary: A simple PORO wrapper for geocoding with Google Maps.
115
83
  test_files: []
metadata.gz.sig CHANGED
Binary file
data/.document DELETED
@@ -1,3 +0,0 @@
1
- lib/**/*.rb
2
- LICENSE.txt
3
- README.md
@@ -1,68 +0,0 @@
1
- # How to contribute
2
-
3
- ## Background
4
-
5
- ### Branches and pull requests
6
-
7
- To make a contribution:
8
-
9
- 1. create a new branch for a given set of logical changes
10
-
11
- 2. open a pull request for the main branch
12
-
13
- 3. request a review
14
- 1. click Reviewers from the main tab of the PR
15
- 2. select one or more contributors
16
-
17
- 4. wait for feedback
18
-
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.
24
-
25
- ### Two-person review
26
-
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.
28
-
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)
36
-
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.
38
-
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).
40
-
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.
67
-
68
- ## Thanks for contributing!
data/.github/FUNDING.yml DELETED
@@ -1,14 +0,0 @@
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']
@@ -1,23 +0,0 @@
1
- ---
2
- name: Bug report
3
- about: Create a report to help us improve
4
- labels: 'bug'
5
- ---
6
-
7
- # Description
8
-
9
- Provide as much background as you need to get the implementer up to speed on the problem to be solved. This can also include screenshots and links to other issues or pull requests.
10
-
11
- # Steps to Reproduce
12
-
13
- Don't forget to point out the difference between what *should* happen and what *does* happen. Here's an example:
14
-
15
- 1. Try geocoding "1600 Pennsylvania Ave":
16
- ```ruby
17
- white_house = GoogleMapsGeocoder.new('1600 Pennsylvania Ave')
18
- ```
19
- 2. The formatted address doesn't match the White House:
20
- ```ruby
21
- white_house.formatted_address
22
- => "1600 Pennsylvania Ave, Charleston, WV 25302, USA"
23
- ```
@@ -1,17 +0,0 @@
1
- ---
2
- name: Feature request
3
- about: Suggest an idea for this project
4
- labels: 'feature'
5
- ---
6
-
7
- # Goal
8
- Explain this issue's purpose. Focus on the problem that needs to be solved and *not* a particular solution. For example: "Make it easier for users to reset their passwords."
9
-
10
- # Description
11
- 1. Provide as much background as you need to familiarize the implementer with the problem to be solved.
12
- 2. Include:
13
- * screenshots
14
- * links to other issues or pull requests
15
-
16
- # Success Criteria
17
- How would a stakeholder test whether the feature was completed successfully?
@@ -1,21 +0,0 @@
1
- ---
2
- name: Task
3
- about: Define a task to complete
4
- title: ''
5
- labels: 'task'
6
- assignees: ''
7
-
8
- ---
9
- # Task
10
-
11
- ## Goal
12
-
13
- Explain the goal of this task.
14
-
15
- ## Description
16
-
17
- Provide whatever background the assignee would need to complete the task. This can include screenshots or links to other issues or pull requests.
18
-
19
- ## Success Criteria
20
-
21
- How can stakeholders tell whether the task was completed successfully or not?
@@ -1,35 +0,0 @@
1
- # Closes: #
2
-
3
- ## Goal
4
- What problem does this pull request solve? This should be close to the goal of the issue this pull request addresses.
5
-
6
- ## Approach
7
- 1. **Describe, in numbered steps, the approach you chose** to solve the above problem.
8
- 1. This will help code reviewers get oriented quickly.
9
- 2. It will also document for future maintainers exactly what changed (and why) when this PR was merged.
10
- 2. **Add specs** that either *reproduce the bug* or *cover the new feature*. In the former's case, *make sure it fails without the fix!*
11
- 3. Document any new public methods using standard RDoc syntax, or update the existing RDoc for any modified public methods. As an example, see the RDoc for `GoogleMapsGeocoder.new`:
12
-
13
- ```ruby
14
- # Geocodes the specified address and wraps the results in a GoogleMapsGeocoder
15
- # object.
16
- #
17
- # @param address [String] a geocodable address
18
- # @return [GoogleMapsGeocoder] the Google Maps result for the specified
19
- # address
20
- # @example
21
- # chez_barack = GoogleMapsGeocoder.new '1600 Pennsylvania DC'
22
- def initialize(address)
23
- @json = address.is_a?(String) ? google_maps_response(address) : address
24
- status = @json && @json['status']
25
- raise RuntimeError if status == 'OVER_QUERY_LIMIT'
26
- raise GeocodingError, @json if @json.blank? || status != 'OK'
27
-
28
- set_attributes_from_json
29
- Logger.new($stderr).info('GoogleMapsGeocoder') do
30
- "Geocoded \"#{address}\" => \"#{formatted_address}\""
31
- end
32
- end
33
- ```
34
-
35
- Signed-off-by: YOUR NAME <YOUR.EMAIL@EXAMPLE.COM>
@@ -1,15 +0,0 @@
1
- # To get started with Dependabot version updates, you'll need to specify which
2
- # package ecosystems to update and where the package manifests are located.
3
- # Please see the documentation for all configuration options:
4
- # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5
-
6
- version: 2
7
- updates:
8
- - package-ecosystem: "bundler" # See documentation for possible values
9
- directory: "/" # Location of package manifests
10
- schedule:
11
- interval: "daily"
12
- - package-ecosystem: "github-actions"
13
- directory: "/"
14
- schedule:
15
- interval: "weekly"
@@ -1,40 +0,0 @@
1
- # Download the latest Ruby patch versions, install dependencies, and run tests.
2
- name: test
3
- on:
4
- push:
5
- paths-ignore:
6
- - '**.md'
7
- - '**.txt'
8
- jobs:
9
- test:
10
- environment: staging
11
- runs-on: ubuntu-latest
12
- name: Ruby ${{ matrix.ruby-version }}
13
- strategy:
14
- matrix:
15
- ruby-version: ['3.0', 3.1, 3.2, 3.3]
16
- steps:
17
- - name: Checkout code
18
- uses: actions/checkout@v4
19
- - name: Set up Ruby ${{ matrix.ruby-version }}
20
- uses: ruby/setup-ruby@v1
21
- with:
22
- ruby-version: ${{ matrix.ruby-version }}
23
- bundler-cache: true # 'bundle install' and cache
24
- - name: Run tests
25
- env:
26
- GOOGLE_MAPS_API_KEY: ${{ secrets.GOOGLE_MAPS_API_KEY }}
27
- run: bundle exec rake
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
34
- uses: coverallsapp/github-action@master
35
- with:
36
- github-token: ${{ secrets.GITHUB_TOKEN }}
37
- - name: Run RuboCop
38
- run: bundle exec rubocop
39
- - name: Run Inch
40
- run: bundle exec inch --pedantic
data/.gitignore DELETED
@@ -1,6 +0,0 @@
1
- *.gem
2
- .DS_Store
3
- coverage
4
- doc
5
- Gemfile.lock
6
- tmp
data/.rubocop.yml DELETED
@@ -1,7 +0,0 @@
1
- require:
2
- - rubocop-performance
3
- - rubocop-rake
4
- - rubocop-rspec
5
-
6
- AllCops:
7
- NewCops: enable
data/.simplecov DELETED
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'simplecov-lcov'
4
-
5
- SimpleCov::Formatter::LcovFormatter.config do |c|
6
- c.report_with_single_file = true
7
- c.single_report_path = 'coverage/lcov.info'
8
- end
9
- SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new(
10
- [
11
- SimpleCov::Formatter::HTMLFormatter,
12
- SimpleCov::Formatter::LcovFormatter
13
- ]
14
- )
15
- SimpleCov.start
data/CODE_OF_CONDUCT.md DELETED
@@ -1,10 +0,0 @@
1
- # The Ruby Community Conduct Guideline
2
-
3
- We have picked the following conduct guideline based on an early proposed draft of the PostgreSQL CoC, for Ruby developers community for safe, productive collaboration. Each Ruby related community (conference etc.) may pick their own Code of Conduct.
4
-
5
- This document provides community guidelines for a safe, respectful, productive, and collaborative place for any person who is willing to contribute to the Ruby community. It applies to all “collaborative space”, which is defined as community communications channels (such as mailing lists, submitted patches, commit comments, etc.).
6
-
7
- * Participants will be tolerant of opposing views.
8
- * Participants must ensure that their language and actions are free of personal attacks and disparaging personal remarks.
9
- * When interpreting the words and actions of others, participants should always assume good intentions.
10
- * Behaviour which can be reasonably considered harassment will not be tolerated.
data/Gemfile DELETED
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
- gemspec
5
-
6
- gem 'inch', '~> 0.8'
7
- gem 'pry', '~> 0.14.1'
8
- gem 'rake', '~> 13'
9
- gem 'rspec', '~> 3'
10
- gem 'rubocop', '< 1.68'
11
- gem 'rubocop-performance', require: false
12
- gem 'rubocop-rake', require: false
13
- gem 'rubocop-rspec', require: false
14
- gem 'simplecov', '~> 0.18'
15
- gem 'simplecov-lcov', '~> 0.8'
data/LICENSE.txt DELETED
@@ -1,20 +0,0 @@
1
- Copyright (c) 2011-2024 Roderick Monje
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md DELETED
@@ -1,113 +0,0 @@
1
- # GoogleMapsGeocoder
2
-
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)
6
- [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/92/badge)](https://bestpractices.coreinfrastructure.org/projects/92)
7
- [![Gem Version](https://badge.fury.io/rb/google_maps_geocoder.svg)](https://rubygems.org/gems/google_maps_geocoder)
8
-
9
- A simple Plain Old Ruby Object wrapper for geocoding with Google Maps.
10
-
11
- ## Installation
12
-
13
- 1. Set your Google Maps API key, which Google now requires, as an environment variable:
14
-
15
- ```bash
16
- export GOOGLE_MAPS_API_KEY=[your key]
17
- ```
18
-
19
- 2. Add `GoogleMapsGeocoder` to your Gemfile and run `bundle`:
20
-
21
- ```ruby
22
- gem 'google_maps_geocoder'
23
- ```
24
-
25
- Or try it out in `irb` with:
26
-
27
- ```ruby
28
- require './lib/google_maps_geocoder/google_maps_geocoder'
29
- ```
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
-
40
- ## Ready to Go in One Step
41
-
42
- ```ruby
43
- chez_barack = GoogleMapsGeocoder.new '1600 Pennsylvania DC'
44
- ```
45
-
46
- ## Usage
47
-
48
- Get the complete, formatted address:
49
-
50
- ```ruby
51
- chez_barack.formatted_address
52
- => "1600 Pennsylvania Avenue Northwest, President's Park, Washington, DC 20500, USA"
53
- ```
54
-
55
- ...standardized name of the city:
56
-
57
- ```ruby
58
- chez_barack.city
59
- => "Washington"
60
- ```
61
-
62
- ...full name of the state or region:
63
-
64
- ```ruby
65
- chez_barack.state_long_name
66
- => "District of Columbia"
67
- ```
68
-
69
- ...standard abbreviation for the state/region:
70
-
71
- ```ruby
72
- chez_barack.state_short_name
73
- => "DC"
74
- ```
75
-
76
- ## API
77
-
78
- The complete, hopefully self-explanatory, API is:
79
-
80
- * `GoogleMapsGeocoder#city`
81
- * `GoogleMapsGeocoder#country_long_name`
82
- * `GoogleMapsGeocoder#country_short_name`
83
- * `GoogleMapsGeocoder#county`
84
- * `GoogleMapsGeocoder#exact_match?`
85
- * `GoogleMapsGeocoder#formatted_address`
86
- * `GoogleMapsGeocoder#formatted_street_address`
87
- * `GoogleMapsGeocoder#lat`
88
- * `GoogleMapsGeocoder#lng`
89
- * `GoogleMapsGeocoder#partial_match?`
90
- * `GoogleMapsGeocoder#postal_code`
91
- * `GoogleMapsGeocoder#state_long_name`
92
- * `GoogleMapsGeocoder#state_short_name`
93
-
94
- For compatibility with [Geocoder](https://github.com/alexreisner/geocoder), the following aliases are also available:
95
-
96
- * `GoogleMapsGeocoder#address`
97
- * `GoogleMapsGeocoder#coordinates`
98
- * `GoogleMapsGeocoder#country`
99
- * `GoogleMapsGeocoder#country_code`
100
- * `GoogleMapsGeocoder#latitude`
101
- * `GoogleMapsGeocoder#longitude`
102
- * `GoogleMapsGeocoder#state`
103
- * `GoogleMapsGeocoder#state_code`
104
-
105
- ## Documentation
106
-
107
- Complete RDoc documentation is available at [RubyDoc.info](https://www.rubydoc.info/gems/google_maps_geocoder).
108
-
109
- ## [Contributing to GoogleMapsGeocoder](.github/CONTRIBUTING.md)
110
-
111
- ## Copyright
112
-
113
- Copyright © 2011-2024 Roderick Monje. See [LICENSE.txt](LICENSE.txt) for further details.
data/Rakefile DELETED
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'bundler'
4
- require 'bundler/gem_tasks'
5
- require 'rspec/core/rake_task'
6
- RSpec::Core::RakeTask.new(:test) do |t|
7
- t.pattern = 'spec/*/*_spec.rb'
8
- t.verbose = false
9
- end
10
- task default: :test
data/SECURITY.md DELETED
@@ -1,16 +0,0 @@
1
- # Security Policy
2
-
3
- ## Supported Versions
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/FoveaCentral/google_maps_geocoder/pulls?q=is%3Apr+is%3Aclosed+author%3Aapp%2Fdependabot).
6
-
7
- | Version | Supported |
8
- | ------- | ------------------ |
9
- | 1.0.1 | :white_check_mark: |
10
- | < 1.0.1 | :x: |
11
-
12
- ## Reporting a Vulnerability
13
-
14
- 1. To report a security vulnerability, [open an issue](https://github.com/FoveaCentral/google_maps_geocoder/issues/new/choose).
15
- 2. Updates are made within 48 hours.
16
- 3. If the vulnerability is accepted, we'll try to patch it within a week.
@@ -1,26 +0,0 @@
1
- -----BEGIN CERTIFICATE-----
2
- MIIEeDCCAuCgAwIBAgIBATANBgkqhkiG9w0BAQsFADBBMQwwCgYDVQQDDANyb2Qx
3
- HDAaBgoJkiaJk/IsZAEZFgxmb3ZlYWNlbnRyYWwxEzARBgoJkiaJk/IsZAEZFgNj
4
- b20wHhcNMjQwMzI5MjIzNDUxWhcNMjUwMzI5MjIzNDUxWjBBMQwwCgYDVQQDDANy
5
- b2QxHDAaBgoJkiaJk/IsZAEZFgxmb3ZlYWNlbnRyYWwxEzARBgoJkiaJk/IsZAEZ
6
- FgNjb20wggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQC6asLzbFQpchSv
7
- u+05KuCzQW39QZq65t3c0kfUsIx+WREjBw2QlM6jVItYj4euRRszLwxhSMCtMsno
8
- Fhas9eZ47esUhxIElQngrsBP0kwLUHQj/EYCDVN2xnMlicoE0zgOXiUkk6PTZZme
9
- 8SYSFJANVDOdRgr5Q17nWQKPS1l3OqoD+fkM+kO/ey2KTXvv4AFxfwe9o/bk6LjF
10
- f4AzxKPmxsYbtgJHiu38gYb2IMh5JE5B0dUQ5pnQJbdTNtHI9YWoVpyIhIj/aOwN
11
- t9lKjWhObPgfQ7Z5bEWSWvuPnGD1zj0/Y1MNJ99M4Bt1t5OkS3L1zjg1H3ulYRlB
12
- VWFIwC8esooXXWqG5s2XCtVjugOo1seXv8PIOCPM1HBLfYjlWAwGy0oA0kAtAs+4
13
- OlciDLHwCJO/ChIeLNaW3f6WiDmcwI8MeyxXxw64kX9QSKP0muM4+GtE9619hPFK
14
- RMXUFKNUlrZ6gcpyX5weP2OKwd9Z7LkVsK/lgyxyaDqGwuajBGkCAwEAAaN7MHkw
15
- CQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFO1rwHyxg39rlp0MN5Kj
16
- s1uxvHyiMB8GA1UdEQQYMBaBFHJvZEBmb3ZlYWNlbnRyYWwuY29tMB8GA1UdEgQY
17
- MBaBFHJvZEBmb3ZlYWNlbnRyYWwuY29tMA0GCSqGSIb3DQEBCwUAA4IBgQBg9aO1
18
- 1OhvQMbzefkcxE1QxuqwGzBh8kNiE2JL5FSGTtgFbXKqM1eeA0GWeZnksSVXOX40
19
- 01HDxW8CHdBnyNGorJPgbypZNI+gpi5bYKox0en7jj+88k9VA4fIbR+a/6sUSDsZ
20
- 82qpicz/Q+qkfnhQxHJ1Cj0lrZBq0Kuc+ooNxE4U3VT25CQCvUN9dlgyMZsH15ND
21
- DpektzMLDzH4suOVGK09j7C3sTyVdwI5UkN8ix27Me0N4zPxjjYo0HFXIRNhEjVF
22
- DWm9LGr9npmhQtd3A3ZyASawp+UUZ5pdc57YaBRDrJdFZr9056MpeByj+Fsg5Jkh
23
- 4o08iHs5bMPDyXBcj5XsYDLwAwTANPjGWGRNvrnY3KGGWdRMgtni3NJyMRCZ5tIT
24
- UNicoJ8NJMgduyTPvZBJtvUPddQr1yAL66/l+CFewbGb/1DbqfSvA2atfUobhDrG
25
- zYKOF/ofPEZhX7sqLK5GzDW4x1QDHAgr1YIdttVxhHADOxF4EVSJCHH0RGw=
26
- -----END CERTIFICATE-----
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require File.expand_path('lib/google_maps_geocoder/version', __dir__)
4
- Gem::Specification.new do |s|
5
- s.name = 'google_maps_geocoder'
6
- s.version = GoogleMapsGeocoder::VERSION.dup
7
- s.licenses = ['MIT']
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 " \
11
- 'Ruby object.'
12
- s.homepage = 'https://github.com/FoveaCentral/google_maps_geocoder'
13
- s.authors = ['Roderick Monje']
14
- s.cert_chain = ['certs/ivanoblomov.pem']
15
- s.email = 'rod@foveacentral.com'
16
- s.signing_key = File.expand_path('~/.ssh/gem-private_key.pem') if $PROGRAM_NAME.end_with?('gem')
17
-
18
- s.add_dependency 'rack', '>= 2.1.4', '< 3.2.0'
19
-
20
- s.files = `git ls-files`.split "\n"
21
- s.require_paths = ['lib']
22
- s.required_ruby_version = '>= 3.0'
23
- s.metadata['rubygems_mfa_required'] = 'true'
24
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # A simple PORO wrapper for geocoding with Google Maps.
4
- class GoogleMapsGeocoder
5
- # This gem's version.
6
- VERSION = '1.0.1' unless defined?(GoogleMapsGeocoder::VERSION)
7
- end
@@ -1,120 +0,0 @@
1
- # Copyright the GoogleMapsGeocoder contributors.
2
- # SPDX-License-Identifier: MIT
3
- # frozen_string_literal: true
4
-
5
- require "#{File.dirname(__FILE__)}/../spec_helper"
6
- # rubocop:disable Metrics/BlockLength
7
- RSpec.describe GoogleMapsGeocoder do
8
- describe '#new' do
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'
18
-
19
- pending 'waiting for query limit to pass'
20
- end
21
-
22
- it { is_expected.to be_partial_match }
23
- it { is_expected.not_to be_exact_match }
24
-
25
- describe '#formatted_street_address' do
26
- it { expect(geocoder.formatted_street_address).to eq '1600 Pennsylvania Avenue Northwest' }
27
- end
28
-
29
- describe '#city' do
30
- it { expect(geocoder.city).to eq 'Washington' }
31
- end
32
-
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
60
-
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
98
- end
99
- # rubocop:enable RSpec/NestedGroups
100
- end
101
-
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
-
109
- around do |example|
110
- original_key = ENV.fetch('GOOGLE_MAPS_API_KEY', nil)
111
- ENV['GOOGLE_MAPS_API_KEY'] = 'invalid_key'
112
- example.run
113
- ENV['GOOGLE_MAPS_API_KEY'] = original_key
114
- end
115
-
116
- it { expect { geocoder }.to raise_error GoogleMapsGeocoder::GeocodingError }
117
- end
118
- end
119
- end
120
- # rubocop:enable Metrics/BlockLength
data/spec/spec_helper.rb DELETED
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'pry'
4
- require 'simplecov'
5
- require 'rubygems'
6
- require 'bundler'
7
- begin
8
- Bundler.setup(:default, :development)
9
- rescue Bundler::BundlerError => e
10
- warn e.message
11
- warn 'Run `bundle install` to install missing gems'
12
- exit e.status_code
13
- end
14
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
15
- $LOAD_PATH.unshift(File.dirname(__FILE__))
16
- require 'google_maps_geocoder/google_maps_geocoder'
17
- # silence output
18
- RSpec.configure do |config|
19
- config.before do
20
- quiet_logger = Logger.new(IO::NULL)
21
- allow(Logger).to receive(:new).and_return(quiet_logger)
22
- end
23
-
24
- config.after do
25
- allow(Logger).to receive(:new).and_call_original
26
- end
27
- end