0.0
No release in over a year
Google Reviews Gem is a Ruby gem that provides an easy-to-use interface for fetching reviews for a specific location from the Google Places API. It allows you to retrieve reviews written by users for a given place and provides useful information such as the author's name, rating, and review text.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.0

Runtime

>= 0
 Project Readme

Google Reviews Gem

The Google Reviews gem is a Ruby library that provides a service to fetch reviews from Google based on a place name or place ID. It utilizes the Google Places API to retrieve the reviews and provides a convenient interface for accessing the review data.

Installation

Add this line to your Gemfile:

gem 'google_reviews'

And then execute:

$ bundle install

Or install it directly:

$ gem install google_reviews

Usage

To fetch reviews based on a place name or place ID, you can use the GoogleReviews::Reviews class provided by the gem. Here's an example of how to use it:

require 'google_reviews'

api_key = 'YOUR_API_KEY'
place_id = 'PLACE_ID'

response = GoogleReviews::Reviews.fetch_reviews_by_place_id(api_key, place_id)
reviews = response.data

reviews.each do |review|
  puts "Author: #{review.author_name}"
  puts "Rating: #{review.rating}"
  puts "Review Text: #{review.text}"
  puts "---"
end

Make sure to replace YOUR_API_KEY with your actual Google Places API key.

Error Handling

The gem provides custom method response.success? to check if the action was successful. If the action was successful, response.data will contain an array of GoogleReview::Review objects. In the case of an error, response.error will provide a descriptive error message explaining what went wrong.

Configuration

The gem doesn't require any additional configuration. However, it's recommended to configure the locale for translations. By default, the gem uses English (:en) as the locale. If you want to use a different locale, you can modify the lib/google_reviews/translations.rb file.

Submitting a Pull Request

  1. Fork the official repository.
  2. Create a topic branch.
  3. Implement your feature or bug fix.
  4. Add, commit, and push your changes.
  5. Submit a pull request.

License

The gem is available as open source under the terms of the MIT License.