Integrating libraries into your code in Ruby
One of the most useful skills you should acquire in your path to becoming a seasoned Ruby developer is integrating other gems into your code. As we’ve seen before, this is accomplished by using the Gemfile, but we’ll look at some additional options we can add to it and integrate them into our own scripts. Let’s write a script that takes the GitHub public API and lists all of the public repos for the user @PacktPublishing
. There are several ways we could do this, but for this example, I’ve chosen a gem called Faraday. You can take a look at the source code here: https://github.com/lostisland/faraday.
Faraday is a client library that can help us make Representational State Transfer (REST) calls that are much easier to read than using the native Net::HTTP
library that comes with Ruby. Let’s create a folder called integrating_gems
and navigate to that folder:
mkdir integrating_gems cd integrating_gems...