The project is in a healthy, maintained state
A simple client for Google Books API. Provides a interface for searching and serializing volumes.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 7.1, >= 7.1.2
~> 2.8, >= 2.8.1
~> 2.1, >= 2.1.1
~> 2.9
~> 13.0
 Project Readme

GoogleBooksClient

The Google Books client is a simple Ruby gem that centralizes requests and communications with the Google Books API.

GitHub Workflow Status (with event) GitHub License GitHub release (with filter) Gem Total Downloads

Table of Contents

  1. Installation
  2. Usage
    • Configuration
    • Models
    • Resources
  3. Development
  4. Tools
  5. Contributing
  6. Versioning
  7. License
  8. Code of Conduct
  9. Contact

Installation

Install the gem and add to the application's Gemfile by executing:

bundle add google_books_client

Or add it manually to the Gemfile:

gem 'google_books_client'

If bundler is not being used to manage dependencies, install the gem by executing:

gem install google_books_client

Usage

Configuration

To use the gem, you must first configure it in an initializer file at your project, for example:

# frozen_string_literal: true

require 'google_books_client'

GoogleBooksClient.configure do |config|
  config.api_version = 'v1'
  config.max_results = 10
  config.timeout = 20
end

The configuration options are:

  • api_version: The version of the Google Books API to be used. The default is v1.
  • cacher: The cacher to be used. The default is ActiveSupport::Cache::MemoryStore.
  • logger: The logger to be used. The default is Logger.new($stdout).
  • max_results: The maximum number of results to be returned by the API. The default is 10.
  • timeout: The timeout in seconds to be used in the requests. The default is 20.

Models

The models objective is to centralize the attributes and methods of the Google Books API resources. And make it easy to serialize and validate the data returned by the API. The models are:

  • Volume: Represents a volume in the Google Books API.

You can use the models to serialize the data returned by the API, for example:

# frozen_string_literal: true

module GoogleBooks
  module Serializers
    class Volume < GoogleBooksCLient::Models::Volume
      def id
        id
      end

      def kind
        kind
      end

      def title
        volume_info.title
      end

      def publisher
        volume_info.publisher
      end
    end
  end
end

GoogleBooks::Serializers::Volume.serialize(volume)

Resources

The resources objective is to centralize the requests and communications with the Google Books API. The resources are:

  • Volumes: Represents the volumes resource in the Google Books API.

You can use the resources to make requests to the API, for example:

GoogleBooksClient::Resources::Volumes.list_by_isbn('8532516262')

GoogleBooksClient::Resources::Volumes.list_by_title('Coraline')

A full list of the available methods for each resource class can be found in the resources documentation.

Development

docker-compose build google_books_client # To build the image
docker-compose up -d google_books_client # To start the container detached
docker-compose exec google_books_client bash # To access the container

Tools

The tools can be used inside the container or locally.

./bin/setup # To install dependencies
./bin/console # To start the pry with the gem loaded
./bin/test # To run the tests, rubocop and coverage

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/betosardinha/google_books_client. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

Versioning

This project uses Semantic Versioning.

For a new release, update the version number in lib/google_books_client/version.rb, and then create a new release on GitHub. It will automatically be published to RubyGems.

License

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

Code of Conduct

Everyone interacting in the Google::Books::Client project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

Contact

If you have any questions about the project, please contact me at:

Support

If this project helped you, please consider giving it a star. It will mean a lot to me.

And if you consider my work valuable for your projects, you can support me on Buy Me a Coffee.