0.0
No release in over a year
Easily get an advice
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

SimpleAdvice Build Status

Implementation of Advice Slip JSON API

Installation

Add this line to your application's Gemfile:

gem 'simple_advice'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install simple_advice

Usage

Everthing is as simple as it could be.

Get random advice

rnd = SimpleAdvice.random # => #<SimpleAdvice::Advice>

rnd.id # => 77
rnd.advice # => "Mercy is the better part of justice."

Find advice by id

SimpleAdvice.find(advice_id: 77) # => #<SimpleAdvice::Advice>

Find advice by text

result = SimpleAdvice.find_by(query: "nice") # => #<SimpleAdvice::Collection> 

result.data # => [#<SimpleAdvice::Advice>]

result.total # => 1

Config

SimpleAdvice uses Faraday to interact via HTTP, you can provide any HTTP adapter that Faraday supports(if you are using Rails put the following code into initializers/simple_advice.rb):

SimpleAdvice::Config.http_adapter = :test

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/DmytroHavryshGoTo/simple_advice.

License

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