google_maps_geocoder 0.6.1 → 0.7

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
  SHA1:
3
- metadata.gz: a87dc3867dff7a2bb8e748d7438a0f40d1b5049d
4
- data.tar.gz: eb563b74b248ef2cfb77aef22f8cc19689410045
3
+ metadata.gz: 6f8038283c14ce1cd1991efd381e0ed95a38dea5
4
+ data.tar.gz: 8861a684bddf6016204a3a652cadd81c11136adb
5
5
  SHA512:
6
- metadata.gz: eb7588cff150c69b84d1190bb699a10cf81b756a0a9627e4558e5e8acfe65c038328ae37ea8862556421b972f7d2d7d259af299b43f3b1b72050bc64c91db6e6
7
- data.tar.gz: 9c914109a7f2b30c64713fd8ef4805f59ea558ff7b762360b06e038f77c44bd7359b1abbfa71b0e1e51335cb8b57186fd8d768459e2d34ac0c6d853d877a9da0
6
+ metadata.gz: c12d9c7fb0e086af148f102f00f14c72888019ff52d885319bbfabeab827d3a41ef383a0439432f181a77f7b7312b187fd2eaaf72b02ac69a2aca16dbd9cf203
7
+ data.tar.gz: 1e1f72808a2c9a75994f745f0719e4d7e673a81f72002c46641a4921196db418887fe4c353b332b6919272137c7f01f4abe7d3b489442833648885abe861a86e
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+
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
+ ```
@@ -0,0 +1,16 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+ ---
5
+
6
+ # Goal
7
+ 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."
8
+
9
+ # Description
10
+ 1. Provide as much background as you need to familiarize the implementer with the problem to be solved.
11
+ 2. Include:
12
+ * screenshots
13
+ * links to other issues or pull requests
14
+
15
+ # Success Criteria
16
+ How would a stakeholder test whether the feature was completed successfully?
data/README.md CHANGED
@@ -77,6 +77,17 @@ The complete, hopefully self-explanatory, API is:
77
77
  * `GoogleMapsGeocoder#state_long_name`
78
78
  * `GoogleMapsGeocoder#state_short_name`
79
79
 
80
+ For compatibility with [Geocoder](https://github.com/alexreisner/geocoder), the following aliases are also available:
81
+
82
+ * `GoogleMapsGeocoder#address`
83
+ * `GoogleMapsGeocoder#coordinates`
84
+ * `GoogleMapsGeocoder#country`
85
+ * `GoogleMapsGeocoder#country_code`
86
+ * `GoogleMapsGeocoder#latitude`
87
+ * `GoogleMapsGeocoder#longitude`
88
+ * `GoogleMapsGeocoder#state`
89
+ * `GoogleMapsGeocoder#state_code`
90
+
80
91
  ## Google Maps API Key (Optional)
81
92
 
82
93
  To have GoogleMapsGeocoder use your Google Maps API key, set it as an environment variable:
@@ -40,6 +40,21 @@ class GoogleMapsGeocoder
40
40
  # Self-explanatory
41
41
  attr_reader(*GOOGLE_ADDRESS_SEGMENTS)
42
42
 
43
+ # Returns the formatted address as a comma-delimited string.
44
+ alias address formatted_address
45
+ # Returns the address' country as a full string.
46
+ alias country country_long_name
47
+ # Returns the address' country as an abbreviated string.
48
+ alias country_code country_short_name
49
+ # Returns the address' latitude as a float.
50
+ alias latitude lat
51
+ # Returns the address' longitude as a float.
52
+ alias longitude lng
53
+ # Returns the address' state as a full string.
54
+ alias state state_long_name
55
+ # Returns the address' state as an abbreviated string.
56
+ alias state_code state_short_name
57
+
43
58
  # Geocodes the specified address and wraps the results in a GoogleMapsGeocoder
44
59
  # object.
45
60
  #
@@ -60,6 +75,11 @@ class GoogleMapsGeocoder
60
75
  end
61
76
  end
62
77
 
78
+ # Returns the address' coordinates as an array of floats.
79
+ def coordinates
80
+ [lat, lng]
81
+ end
82
+
63
83
  # Returns true if the address Google returns is an exact match.
64
84
  #
65
85
  # @return [boolean] whether the Google Maps result is an exact match
@@ -1,4 +1,4 @@
1
1
  # A simple PORO wrapper for geocoding with Google Maps.
2
2
  class GoogleMapsGeocoder
3
- VERSION = '0.6.1'.freeze unless defined?(GoogleMapsGeocoder::VERSION)
3
+ VERSION = '0.7'.freeze unless defined?(GoogleMapsGeocoder::VERSION)
4
4
  end
@@ -42,8 +42,18 @@ describe GoogleMapsGeocoder do
42
42
  it { expect(subject.lat).to be_within(0.005).of(38.8976633) }
43
43
  it { expect(subject.lng).to be_within(0.005).of(-77.0365739) }
44
44
  end
45
+ context 'Geocoder API' do
46
+ it { expect(subject.address).to eq subject.formatted_address }
47
+ it { expect(subject.coordinates).to eq [subject.lat, subject.lng] }
48
+ it { expect(subject.country).to eq subject.country_long_name }
49
+ it { expect(subject.country_code).to eq subject.country_short_name }
50
+ it { expect(subject.latitude).to eq subject.lat }
51
+ it { expect(subject.longitude).to eq subject.lng }
52
+ it { expect(subject.state).to eq subject.state_long_name }
53
+ it { expect(subject.state_code).to eq subject.state_short_name }
54
+ end
45
55
  end
46
- context 'with an invalid address' do
56
+ context 'when API key is invalid' do
47
57
  before do
48
58
  @key = ENV['GOOGLE_MAPS_API_KEY']
49
59
  ENV['GOOGLE_MAPS_API_KEY'] = 'invalid_key'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google_maps_geocoder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: '0.7'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roderick Monje
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-18 00:00:00.000000000 Z
11
+ date: 2018-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: codeclimate-test-reporter
@@ -118,6 +118,8 @@ files:
118
118
  - ".document"
119
119
  - ".github/CONTRIBUTING.md"
120
120
  - ".github/ISSUE_TEMPLATE.md"
121
+ - ".github/ISSUE_TEMPLATE/bug-report.md"
122
+ - ".github/ISSUE_TEMPLATE/feature_request.md"
121
123
  - ".github/PULL_REQUEST_TEMPLATE.md"
122
124
  - ".gitignore"
123
125
  - ".ruby-version"