edwardsamuel / google-maps-services-ruby

Ruby gem for Google Maps Web Service APIs
Apache License 2.0
91 stars 53 forks source link

Allow speed_unit to be passed to request #7

Open netuoso opened 7 years ago

netuoso commented 7 years ago

Explanation:

This change leaves KPH as the default while adding the ability to send 'MPH' to the roads.rb

Example request:

google_client = GoogleMapsService::Client.new
google_client.speed_limits('ChIJaw1TDuC22YgRf6hEN94cT58')
=> [{:placeId=>"ChIJaw1TDuC22YgRf6hEN94cT58", :speedLimit=>88.51392, :units=>"KPH"}]

google_client = GoogleMapsService::Client.new
google_client.speed_limits('ChIJaw1TDuC22YgRf6hEN94cT58', units: 'MPH')
=> [{:placeId=>"ChIJaw1TDuC22YgRf6hEN94cT58", :speedLimit=>55, :units=>"MPH"}]
coveralls commented 7 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 4e86596e0eb47d77bf3f581c994fca81db2aab4f on netuoso:master into 46746fd72e90c75855baa88aee04e41c84ff32c9 on edwardsamuel:master.

coveralls commented 7 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 4e86596e0eb47d77bf3f581c994fca81db2aab4f on netuoso:master into 46746fd72e90c75855baa88aee04e41c84ff32c9 on edwardsamuel:master.

coveralls commented 7 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 3a75f1076eae0bca9da7ce02b157bc8038df60c5 on netuoso:master into 46746fd72e90c75855baa88aee04e41c84ff32c9 on edwardsamuel:master.

coveralls commented 7 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 3a75f1076eae0bca9da7ce02b157bc8038df60c5 on netuoso:master into 46746fd72e90c75855baa88aee04e41c84ff32c9 on edwardsamuel:master.

coveralls commented 7 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 3a75f1076eae0bca9da7ce02b157bc8038df60c5 on netuoso:master into 46746fd72e90c75855baa88aee04e41c84ff32c9 on edwardsamuel:master.

edwardsamuel commented 7 years ago

Hi @netuoso Thanks for your PR. I just saw that Speed Limit have units. Before I merge, I have some reviews on yours (I'll write in separate comments).

coveralls commented 7 years ago

Coverage Status

Coverage decreased (-0.3%) to 99.73% when pulling ce77462ba8c27eb014fdb59f4fa9a944292eff23 on netuoso:master into 46746fd72e90c75855baa88aee04e41c84ff32c9 on edwardsamuel:master.

coveralls commented 7 years ago

Coverage Status

Coverage decreased (-0.3%) to 99.73% when pulling ce77462ba8c27eb014fdb59f4fa9a944292eff23 on netuoso:master into 46746fd72e90c75855baa88aee04e41c84ff32c9 on edwardsamuel:master.

coveralls commented 7 years ago

Coverage Status

Coverage decreased (-0.3%) to 99.73% when pulling ce77462ba8c27eb014fdb59f4fa9a944292eff23 on netuoso:master into 46746fd72e90c75855baa88aee04e41c84ff32c9 on edwardsamuel:master.

coveralls commented 7 years ago

Coverage Status

Coverage decreased (-0.3%) to 99.73% when pulling 02973b7c3936f1f73d57b4a56bf9a585576e9d57 on netuoso:master into 46746fd72e90c75855baa88aee04e41c84ff32c9 on edwardsamuel:master.

coveralls commented 7 years ago

Coverage Status

Coverage decreased (-0.3%) to 99.73% when pulling 02973b7c3936f1f73d57b4a56bf9a585576e9d57 on netuoso:master into 46746fd72e90c75855baa88aee04e41c84ff32c9 on edwardsamuel:master.

coveralls commented 7 years ago

Coverage Status

Coverage decreased (-0.3%) to 99.73% when pulling 02973b7c3936f1f73d57b4a56bf9a585576e9d57 on netuoso:master into 46746fd72e90c75855baa88aee04e41c84ff32c9 on edwardsamuel:master.

netuoso commented 7 years ago

@edwardsamuel ok waiting for you to review. the coverage decrease is due to changing the params sent to the generate_auth_url method in client.rb since it isn't receiving an array from the speed_limits method any longer.

if we wrapped the array to hash conversion inside a conditional that only executes if units is sent as a param to the speed_limits method it would retain 100% coverage.

coveralls commented 7 years ago

Coverage Status

Coverage decreased (-0.3%) to 99.73% when pulling 9c20a4228c8d5e4c0c79a2fd3cf234316bbc82ac on netuoso:master into 46746fd72e90c75855baa88aee04e41c84ff32c9 on edwardsamuel:master.

coveralls commented 7 years ago

Coverage Status

Coverage decreased (-0.3%) to 99.73% when pulling 9c20a4228c8d5e4c0c79a2fd3cf234316bbc82ac on netuoso:master into 46746fd72e90c75855baa88aee04e41c84ff32c9 on edwardsamuel:master.

edwardsamuel commented 7 years ago

Hi @netuoso, Sorry, my bad. I realize that we can't use Hash params in the speed_limits method, but it's fine on snapped_speed_limits. You are right, use array instead:

params << ['units', units] if units.match(/^mph$/i)

and no need to do:

params = Hash[params]

Thanks!

netuoso commented 7 years ago

@edwardsamuel No problem! That should do it.

coveralls commented 7 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 7493b02daba539969ac1cbce1d68fde0ec80928f on netuoso:master into 46746fd72e90c75855baa88aee04e41c84ff32c9 on edwardsamuel:master.

coveralls commented 7 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 7493b02daba539969ac1cbce1d68fde0ec80928f on netuoso:master into 46746fd72e90c75855baa88aee04e41c84ff32c9 on edwardsamuel:master.

coveralls commented 7 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 7493b02daba539969ac1cbce1d68fde0ec80928f on netuoso:master into 46746fd72e90c75855baa88aee04e41c84ff32c9 on edwardsamuel:master.

edwardsamuel commented 7 years ago

Will merge and publish it soon

rnestler commented 2 years ago

Will merge and publish it soon

What happened to this?