I think I am fundamentally missing something. I am learning ruby, and have been playing with Lita lately, and wrote(my first) a simple little gem to get some directions/distance from the bot. The problem I am having is where to put a gem dependency in my gem. To work, my gem requires the 'rest-client' gem. Where do I put this in my code so that it is available to my Directions class? Currently, to get it to run, I am requiring the gem in my bots actual gemfile. And when I bundle exec lita, it apparently becomes available for my gem to use... but if I remove it from there, I can't get it to work anywhere in my gem.. what am I missing? It is here if anyone wants to read the code and tell me where I should be adding it:
https://github.com/cashman04/lita-directions
EDIT: I added the dependency like spickermann suggested. Then had to add require 'rest-client'to my directions.rb. Not entirely sure if this is the correct way, but it works now. Thanks for the help spickermann
Including A Gem Within a Ruby Program. To install and make use of a gem, within a ruby program, the command is simple. gem install 'NameOfGem' I will use Faker as an example for the rest of this post. So to install the Faker gem I would run the command, gem install faker .
Common Attempts To Resolve Ruby Gem Dependencies Bundler can help to resolve dependencies when working with Ruby gems by allowing you to specify a set of gems in a Gemfile, then issue a single command to install them. Bundler then automatically resolves the dependencies for you.
To install a gem, use gem install [gem] . Browsing installed gems is done with gem list . For more information about the gem command, see below or head to RubyGems' docs. There are other sources of libraries though.
Put the following line into your lita-directions.gemspec
right next to the one that defines the dependency on lita:
spec.add_runtime_dependency 'rest-client'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With