Project

dad_jokes

0.0
No commit activity in last 3 years
No release in over 3 years
Gem to generate random popular Dad Jokes. Features include: Generating jokes, Search for jokes, Save a random joke as image (as .png), etc
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.14
~> 5.0
~> 10.0

Runtime

~> 0.13.1
~> 1.8
 Project Readme

dad_jokes

License Gem Version Gem

Welcome to Dad Jokes!
( Wait, what's a Dad joke? )

Generate random dad jokes using this gem.

Installation

1. Add this line to your application's Gemfile:

gem 'dad_jokes'

and then execute:

$ bundle

OR,

2. Install it yourself as:

$ gem install dad_jokes

and require in your script as :

require 'dad_jokes'

Usage

1. Get a random Dad joke

# Get a random joke
DadJokes.random

Sample Output #1 : '"Dad, I'm hungry." "Hello, Hungry. I'm Dad."'

Sample Output #2 : 'My dog used to chase people on a bike a lot. It got so bad I had to take his bike away.'

2. Search for Dad jokes

# Get array of jokes by passing a search term ; and setting limit(optional)
DadJokes.search(term: "cannibal", limit: 1)

Output : ["A cannibal is someone who is fed up with people."]

  • term :
    • (*required)
    • Search term goes here
  • limit :
    • (*optional)
    • Set limit for the number of jokes (because, obviously you're tired of laughing!).
    • By default : 5 jokes

3. Generate & save a random joke as image (in .png format)

# Saves a random joke in png format
DadJokes.random_image

Sample Vector image :
Random Joke

Output to console :
"Dad died because he couldn't remember his blood type. I will never forget his last words. Be positive. ( Saved as image in location: joke_vX8MeFdUDlb.png !)"

NOTE: If you're inside a Rails project, image will be saved to root of the directory. Otherwise, if you're running the method in a ruby script, the image will be saved in the relative directory.

Contributing

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

Thanks to icanhazdadjoke for the free API. You can submit new jokes here.

License

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